#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn binary_search_by<'a, F>(&'a self, mut f: F) -> Result<usize, usize>
where
F: FnMut(&'a T) -> Ordering,
{
// INVARIANTS:
// - 0 <= left <= left + size = right <= self.len()
// - f returns Less for everything in self[..left]
// - f returns Greater for everything in self[right..]
let mut size = self.len();
let mut left = 0;
let mut right = size;
while left < right {
let mid = left + size / 2;
// SAFETY: the while condition means `size` is strictly positive, so
// `size/2 < size`. Thus `left + size/2 < left + size`, which
// coupled with the `left + size <= self.len()` invariant means
// we have `left + size/2 < self.len()`, and this is in-bounds.
let cmp = f(unsafe { self.get_unchecked(mid) });
// The reason why we use if/else control flow rather than match
// is because match reorders comparison operations, which is perf sensitive.
// This is x86 asm for u8: https://rust.godbolt.org/z/8Y8Pra.
if cmp == Less {
left = mid + 1;
} else if cmp == Greater {
right = mid;
} else {
// SAFETY: same as the `get_unchecked` above
unsafe { crate::intrinsics::assume(mid < self.len()) };
return Ok(mid);
}
size = right - left;
}
// SAFETY: directly true from the overall invariant.
// Note that this is `<=`, unlike the assume in the `Ok` path.
unsafe { crate::intrinsics::assume(left <= self.len()) };
Err(left)
}
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn binary_search_by<'a, F>(&'a self, mut f: F) -> Result<usize, usize>
where
F: FnMut(&'a T) -> Ordering,
{
// INVARIANTS:
// - 0 <= left <= left + size = right <= self.len()
// - f returns Less for everything in self[..left]
// - f returns Greater for everything in self[right..]
let mut size = self.len();
let mut left = 0;
let mut right = size;
while left < right {
let mid = left + size / 2;
// SAFETY: the while condition means `size` is strictly positive, so
// `size/2 < size`. Thus `left + size/2 < left + size`, which
// coupled with the `left + size <= self.len()` invariant means
// we have `left + size/2 < self.len()`, and this is in-bounds.
let cmp = f(unsafe { self.get_unchecked(mid) });
// The reason why we use if/else control flow rather than match
// is because match reorders comparison operations, which is perf sensitive.
// This is x86 asm for u8: https://rust.godbolt.org/z/8Y8Pra.
if cmp == Less {
left = mid + 1;
} else if cmp == Greater {
right = mid;
} else {
// SAFETY: same as the `get_unchecked` above
unsafe { crate::intrinsics::assume(mid < self.len()) };
return Ok(mid);
}
size = right - left;
}
// SAFETY: directly true from the overall invariant.
// Note that this is `<=`, unlike the assume in the `Ok` path.
unsafe { crate::intrinsics::assume(left <= self.len()) };
Err(left)
}
if !true || true /* test */ || true {}
rustfmt doesnt like to format this as soon as there is a multiline comment inside the line, any command to force it?if !true || true /* test */ || true {}
rustfmt doesnt like to format this as soon as there is a multiline comment inside the line, any command to force it? ed1bf05
Update translations for upcoming 16.7 - def-
1cdbb1b
Version 16.7 - def-
09c21d5
For integrated and discrete GPUs always prefer what comes first in the list - Jupeyy
dbfaecc
Minor brazilian portuguese fix (by Akari) - def-
8cd3335
Update russian.txt to incoming 16.7 update - lolipodass
d4afa55
Update french translations - Chairn
99dae9e
Update spanish.txt - n0Ketchp
9ac6b39
Update spanish.txt - n0Ketchp
58558c4
Add error handling when enumerating physical devices - Jupeyy
31a69c5
Followup fixes for physical devices - Jupeyy
0aefd10
Add warning for missing integrated CPU driver - Jupeyy
2c2f319
Update Korean translations by CHaBek - cwh7435
47cb543
Add new french translations for 16.7 - Chairn
3cfefd1
Update brazilian_portuguese.txt - rffontenelle
50cefec
Add ui_smooth_scroll_time
variable to adjust smooth scrolling - Robyt3
5d04254
Update simplified_chinese.txt - Cheeser0613
9a882b4
Update traditional_chinese.txt - Cheeser0613
c5b020d
Missing parameter in error list - Jupeyy
d00fee3
Show current memory usage in assert too - Jupeyy
750129c
Version 16.7.1 - def-
8a75365
Quick fix for old client on new server - def-
8d04415
Version 16.7.2 - def-sv_vanilla_antispoof 1
(closes #2074).
The dummy map was not valid. The size of the tiles and game layers was calculated incorrectly. The last member variable included in CMapItemLayerTilemap
version 2 should be m_Data
. Previously only the size of the member m_aName
was subtracted from the total size, which was resulting in an incorrect item size, as the size of the following 5 members also needs...