Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove a ptr-to-int cast in
CommandQueue::apply
(#10475)
# Objective - `CommandQueue::apply` calculates the address of the end of the internal buffer as a `usize` rather than as a pointer, requiring two casts of `cursor` to `usize`. Casting pointers to integers is generally discouraged and may also prevent optimizations. It's also unnecessary here. ## Solution - Calculate the end address as a pointer rather than a `usize`. Small note: A trivial translation of the old code to use pointers would have computed `end_addr` as `cursor.add(self.bytes.len())`, which is not wrong but is an additional `unsafe` operation that also needs to be properly documented and proven correct. However this operation is already implemented in the form of the safe `as_mut_ptr_range`, so I just used that.
- Loading branch information