mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-10 05:02:54 +00:00
Add CoreInode::lookup() for directory lookups.
Also add a name-to-inode lookup cache to Ext2Inode. This seems like a great speedup for filesystem traversal.
This commit is contained in:
parent
8fa2d7104a
commit
5f434bc00b
Notes:
sideshowbarker
2024-07-19 16:10:32 +09:00
Author: https://github.com/awesomekling
Commit: 5f434bc00b
7 changed files with 48 additions and 18 deletions
VirtualFileSystem
|
@ -1152,3 +1152,27 @@ InodeIdentifier Ext2FileSystem::find_parent_of_inode(InodeIdentifier inode_id) c
|
|||
|
||||
return foundParent;
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2Inode::lookup(const String& name)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
|
||||
if (m_child_cache.isEmpty()) {
|
||||
HashMap<String, unsigned> children;
|
||||
|
||||
traverse_as_directory([&children] (auto& entry) {
|
||||
children.set(String(entry.name, entry.name_length), entry.inode.index());
|
||||
return true;
|
||||
});
|
||||
|
||||
LOCKER(m_lock);
|
||||
m_child_cache = move(children);
|
||||
}
|
||||
|
||||
LOCKER(m_lock);
|
||||
auto it = m_child_cache.find(name);
|
||||
if (it != m_child_cache.end())
|
||||
return { fsid(), (*it).value };
|
||||
|
||||
return { };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue