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
|
@ -41,7 +41,7 @@ InodeIdentifier FileSystem::childOfDirectoryInodeWithName(InodeIdentifier inode,
|
|||
{
|
||||
InodeIdentifier foundInode;
|
||||
enumerateDirectoryInode(inode, [&] (const DirectoryEntry& entry) {
|
||||
if (entry.name == name) {
|
||||
if (!strcmp(entry.name, name.characters())) {
|
||||
foundInode = entry.inode;
|
||||
return false;
|
||||
}
|
||||
|
@ -101,3 +101,20 @@ ByteBuffer FileSystem::readEntireInode(InodeIdentifier inode, FileDescriptor* ha
|
|||
return contents;
|
||||
}
|
||||
|
||||
FileSystem::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
|
||||
: name_length(strlen(name))
|
||||
, inode(i)
|
||||
, fileType(ft)
|
||||
{
|
||||
memcpy(name, n, name_length);
|
||||
name[name_length] = '\0';
|
||||
}
|
||||
|
||||
FileSystem::DirectoryEntry::DirectoryEntry(const char* n, Unix::size_t nl, InodeIdentifier i, byte ft)
|
||||
: name_length(nl)
|
||||
, inode(i)
|
||||
, fileType(ft)
|
||||
{
|
||||
memcpy(name, n, nl);
|
||||
name[nl] = '\0';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue