Skip to content

Commit b226638

Browse files
committed
Auto merge of #211 - cuviper:fallibility, r=Amanieu
typo: fallability -> fallibility
2 parents 02d73f8 + 19afc3e commit b226638

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/raw/mod.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ fn cold() {}
5454
#[cfg(not(feature = "nightly"))]
5555
#[inline]
5656
fn likely(b: bool) -> bool {
57-
if !b { cold() }
57+
if !b {
58+
cold()
59+
}
5860
b
5961
}
6062
#[cfg(not(feature = "nightly"))]
6163
#[inline]
6264
fn unlikely(b: bool) -> bool {
63-
if b { cold() }
65+
if b {
66+
cold()
67+
}
6468
b
6569
}
6670

@@ -431,18 +435,18 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
431435
unsafe fn new_uninitialized(
432436
alloc: A,
433437
buckets: usize,
434-
fallability: Fallibility,
438+
fallibility: Fallibility,
435439
) -> Result<Self, TryReserveError> {
436440
debug_assert!(buckets.is_power_of_two());
437441

438442
// Avoid `Option::ok_or_else` because it bloats LLVM IR.
439443
let (layout, ctrl_offset) = match calculate_layout::<T>(buckets) {
440444
Some(lco) => lco,
441-
None => return Err(fallability.capacity_overflow()),
445+
None => return Err(fallibility.capacity_overflow()),
442446
};
443447
let ptr: NonNull<u8> = match do_alloc(&alloc, layout) {
444448
Ok(block) => block.cast(),
445-
Err(_) => return Err(fallability.alloc_err(layout)),
449+
Err(_) => return Err(fallibility.alloc_err(layout)),
446450
};
447451
let ctrl = NonNull::new_unchecked(ptr.as_ptr().add(ctrl_offset));
448452
Ok(Self {
@@ -460,7 +464,7 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
460464
fn fallible_with_capacity(
461465
alloc: A,
462466
capacity: usize,
463-
fallability: Fallibility,
467+
fallibility: Fallibility,
464468
) -> Result<Self, TryReserveError> {
465469
if capacity == 0 {
466470
Ok(Self::new_in(alloc))
@@ -469,9 +473,9 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
469473
// Avoid `Option::ok_or_else` because it bloats LLVM IR.
470474
let buckets = match capacity_to_buckets(capacity) {
471475
Some(buckets) => buckets,
472-
None => return Err(fallability.capacity_overflow()),
476+
None => return Err(fallibility.capacity_overflow()),
473477
};
474-
let result = Self::new_uninitialized(alloc, buckets, fallability)?;
478+
let result = Self::new_uninitialized(alloc, buckets, fallibility)?;
475479
result.ctrl(0).write_bytes(EMPTY, result.num_ctrl_bytes());
476480

477481
Ok(result)
@@ -794,12 +798,12 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
794798
&mut self,
795799
additional: usize,
796800
hasher: impl Fn(&T) -> u64,
797-
fallability: Fallibility,
801+
fallibility: Fallibility,
798802
) -> Result<(), TryReserveError> {
799803
// Avoid `Option::ok_or_else` because it bloats LLVM IR.
800804
let new_items = match self.items.checked_add(additional) {
801805
Some(new_items) => new_items,
802-
None => return Err(fallability.capacity_overflow()),
806+
None => return Err(fallibility.capacity_overflow()),
803807
};
804808
let full_capacity = bucket_mask_to_capacity(self.bucket_mask);
805809
if new_items <= full_capacity / 2 {
@@ -813,7 +817,7 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
813817
self.resize(
814818
usize::max(new_items, full_capacity + 1),
815819
hasher,
816-
fallability,
820+
fallibility,
817821
)
818822
}
819823
}
@@ -923,14 +927,14 @@ impl<T, A: AllocRef + Clone> RawTable<T, A> {
923927
&mut self,
924928
capacity: usize,
925929
hasher: impl Fn(&T) -> u64,
926-
fallability: Fallibility,
930+
fallibility: Fallibility,
927931
) -> Result<(), TryReserveError> {
928932
unsafe {
929933
debug_assert!(self.items <= capacity);
930934

931935
// Allocate and initialize the new table.
932936
let mut new_table =
933-
Self::fallible_with_capacity(self.alloc.clone(), capacity, fallability)?;
937+
Self::fallible_with_capacity(self.alloc.clone(), capacity, fallibility)?;
934938
new_table.growth_left -= self.items;
935939
new_table.items = self.items;
936940

0 commit comments

Comments
 (0)