Reduce kmalloc() traffic in directory iteration.

Pass the file name in a stack-allocated buffer instead of using an AK::String
when iterating directories. This dramatically reduces the amount of cycles
spent traversing the filesystem.
This commit is contained in:
Andreas Kling 2018-11-13 00:17:30 +01:00
parent 5e8e554f94
commit 19b9401487
Notes: sideshowbarker 2024-07-19 16:10:51 +09:00
10 changed files with 60 additions and 40 deletions
VirtualFileSystem

View file

@ -147,11 +147,11 @@ bool SyntheticFileSystem::enumerateDirectoryInode(InodeIdentifier inode, Functio
if (!synInode.metadata.isDirectory())
return false;
callback({ ".", synInode.metadata.inode });
callback({ "..", synInode.parent });
callback({ ".", 1, synInode.metadata.inode, 2 });
callback({ "..", 2, synInode.parent, 2 });
for (auto& child : synInode.children)
callback({ child->name, child->metadata.inode });
callback({ child->name.characters(), child->name.length(), child->metadata.inode, child->metadata.isDirectory() ? (byte)2 : (byte)1 });
return true;
}