mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Substitute trivial fallible conversions with infallible function calls (#10846)
Clippy for rust 1.75 will introduce the [`unnecessary_fallible_conversions`][1] lint. This PR solves the trivial ones. [1]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions
This commit is contained in:
parent
5a0c09d38f
commit
262b068bc3
1 changed files with 11 additions and 9 deletions
|
@ -553,12 +553,14 @@ impl Entities {
|
|||
// Use one atomic subtract to grab a range of new IDs. The range might be
|
||||
// entirely nonnegative, meaning all IDs come from the freelist, or entirely
|
||||
// negative, meaning they are all new IDs to allocate, or a mix of both.
|
||||
let range_end = self
|
||||
.free_cursor
|
||||
// Unwrap: these conversions can only fail on platforms that don't support 64-bit atomics
|
||||
// and use AtomicIsize instead (see note on `IdCursor`).
|
||||
.fetch_sub(IdCursor::try_from(count).unwrap(), Ordering::Relaxed);
|
||||
let range_start = range_end - IdCursor::try_from(count).unwrap();
|
||||
let range_end = self.free_cursor.fetch_sub(
|
||||
IdCursor::try_from(count)
|
||||
.expect("64-bit atomic operations are not supported on this platform."),
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
let range_start = range_end
|
||||
- IdCursor::try_from(count)
|
||||
.expect("64-bit atomic operations are not supported on this platform.");
|
||||
|
||||
let freelist_range = range_start.max(0) as usize..range_end.max(0) as usize;
|
||||
|
||||
|
@ -745,9 +747,9 @@ impl Entities {
|
|||
self.verify_flushed();
|
||||
|
||||
let freelist_size = *self.free_cursor.get_mut();
|
||||
// Unwrap: these conversions can only fail on platforms that don't support 64-bit atomics
|
||||
// and use AtomicIsize instead (see note on `IdCursor`).
|
||||
let shortfall = IdCursor::try_from(additional).unwrap() - freelist_size;
|
||||
let shortfall = IdCursor::try_from(additional)
|
||||
.expect("64-bit atomic operations are not supported on this platform.")
|
||||
- freelist_size;
|
||||
if shortfall > 0 {
|
||||
self.meta.reserve(shortfall as usize);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue