mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
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:
parent
5e8e554f94
commit
19b9401487
Notes:
sideshowbarker
2024-07-19 16:10:51 +09:00
Author: https://github.com/awesomekling
Commit: 19b9401487
10 changed files with 60 additions and 40 deletions
|
@ -250,12 +250,12 @@ void VirtualFileSystem::enumerateDirectoryInode(InodeIdentifier directoryInode,
|
|||
else
|
||||
resolvedInode = entry.inode;
|
||||
|
||||
if (directoryInode.isRootInode() && !isRoot(directoryInode) && entry.name == "..") {
|
||||
if (directoryInode.isRootInode() && !isRoot(directoryInode) && !strcmp(entry.name, "..")) {
|
||||
auto mount = findMountForGuest(entry.inode);
|
||||
ASSERT(mount);
|
||||
resolvedInode = mount->host();
|
||||
}
|
||||
callback({ entry.name, resolvedInode });
|
||||
callback(FileSystem::DirectoryEntry(entry.name, entry.name_length, resolvedInode, entry.fileType));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ void VirtualFileSystem::listDirectory(const String& path, InodeIdentifier base)
|
|||
|
||||
kprintf("%s%s%s",
|
||||
nameColorBegin,
|
||||
entry.name.characters(),
|
||||
entry.name,
|
||||
nameColorEnd);
|
||||
|
||||
if (metadata.isDirectory()) {
|
||||
|
@ -376,11 +376,11 @@ void VirtualFileSystem::listDirectoryRecursively(const String& path, InodeIdenti
|
|||
if (metadata.isDirectory()) {
|
||||
if (entry.name != "." && entry.name != "..") {
|
||||
char buf[4096];
|
||||
ksprintf(buf, "%s/%s", path.characters(), entry.name.characters());
|
||||
ksprintf(buf, "%s/%s", path.characters(), entry.name);
|
||||
listDirectoryRecursively(buf, base);
|
||||
}
|
||||
} else {
|
||||
kprintf("%s/%s\n", path.characters(), entry.name.characters());
|
||||
kprintf("%s/%s\n", path.characters(), entry.name);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue