mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 22:09:49 +00:00
Use iterateAssumeFirstIteration in Walker.next to avoid unnecessary lseek calls
Since we are opening each directory for iteration, we know that we don't need to reset the cursor's directory before iterating. Using `iterateAssumeFirstIteration` skips the cursor resetting which eliminates an `lseek` syscall for every directory opened on non-Windows platforms. This doesn't seem to actually matter much for performance (1.01 ± 0.02 times faster when walking /home/ on my system) but avoiding unnecessary syscalls is always nice anyway.
This commit is contained in:
parent
00ff653576
commit
2f188290e2
@ -972,7 +972,7 @@ pub const IterableDir = struct {
|
||||
{
|
||||
errdefer new_dir.close();
|
||||
try self.stack.append(StackItem{
|
||||
.iter = new_dir.iterate(),
|
||||
.iter = new_dir.iterateAssumeFirstIteration(),
|
||||
.dirname_len = self.name_buffer.items.len,
|
||||
});
|
||||
top = &self.stack.items[self.stack.items.len - 1];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user