Kernel: Remove unnecessary hash map lookups

This commit is contained in:
Bananymous 2024-12-15 20:47:40 +02:00
parent a7e06715ba
commit 1815a913c3
3 changed files with 9 additions and 6 deletions

View File

@ -295,8 +295,9 @@ namespace Kernel
TRY(sync_superblock()); TRY(sync_superblock());
// remove inode from cache // remove inode from cache
if (m_inode_cache.contains(ino)) auto it = m_inode_cache.find(ino);
m_inode_cache.remove(ino); if (it != m_inode_cache.end())
m_inode_cache.remove(it);
return {}; return {};
} }

View File

@ -24,8 +24,9 @@ namespace Kernel
BAN::ErrorOr<BAN::RefPtr<Ext2Inode>> Ext2Inode::create(Ext2FS& fs, uint32_t inode_ino) BAN::ErrorOr<BAN::RefPtr<Ext2Inode>> Ext2Inode::create(Ext2FS& fs, uint32_t inode_ino)
{ {
if (fs.inode_cache().contains(inode_ino)) auto it = fs.inode_cache().find(inode_ino);
return fs.inode_cache()[inode_ino]; if (it != fs.inode_cache().end())
return it->value;
auto inode_location = TRY(fs.locate_inode(inode_ino)); auto inode_location = TRY(fs.locate_inode(inode_ino));

View File

@ -68,8 +68,9 @@ namespace Kernel
{ {
LockGuard _(m_mutex); LockGuard _(m_mutex);
if (m_inode_cache.contains(ino)) auto it = m_inode_cache.find(ino);
return m_inode_cache[ino]; if (it != m_inode_cache.end())
return it->value;
TmpInodeInfo inode_info; TmpInodeInfo inode_info;