mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
speed up sliceTo when end == sentinel
This commit is contained in:
parent
d525c59808
commit
6ebeb85abd
1 changed files with 4 additions and 1 deletions
|
|
@ -861,7 +861,10 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
|
|||
},
|
||||
.Many => if (ptr_info.sentinel) |sentinel_ptr| {
|
||||
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
|
||||
// We may be looking for something other than the sentinel,
|
||||
if (sentinel == end) {
|
||||
return indexOfSentinel(ptr_info.child, end, ptr);
|
||||
}
|
||||
// We're looking for something other than the sentinel,
|
||||
// but iterating past the sentinel would be a bug so we need
|
||||
// to check for both.
|
||||
var i: usize = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue