mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std.mem.indexOfSentinel: don't ask the OS the page size
simply use page_size_min instead. better yet, this logic would avoid depending on page size entirely...
This commit is contained in:
parent
e18c7f9cca
commit
faf256e429
@ -1098,12 +1098,12 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
|
||||
// as we don't read into a new page. This should be the case for most architectures
|
||||
// which use paged memory, however should be confirmed before adding a new arch below.
|
||||
.aarch64, .x86, .x86_64 => if (std.simd.suggestVectorLength(T)) |block_len| {
|
||||
const page_size = std.heap.pageSize();
|
||||
const page_size = std.heap.page_size_min;
|
||||
const block_size = @sizeOf(T) * block_len;
|
||||
const Block = @Vector(block_len, T);
|
||||
const mask: Block = @splat(sentinel);
|
||||
|
||||
comptime assert(std.heap.page_size_max % @sizeOf(Block) == 0);
|
||||
comptime assert(std.heap.page_size_min % @sizeOf(Block) == 0);
|
||||
assert(page_size % @sizeOf(Block) == 0);
|
||||
|
||||
// First block may be unaligned
|
||||
@ -1153,7 +1153,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
|
||||
test "indexOfSentinel vector paths" {
|
||||
const Types = [_]type{ u8, u16, u32, u64 };
|
||||
const allocator = std.testing.allocator;
|
||||
const page_size = std.heap.pageSize();
|
||||
const page_size = std.heap.page_size_min;
|
||||
|
||||
inline for (Types) |T| {
|
||||
const block_len = std.simd.suggestVectorLength(T) orelse continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user