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());
// remove inode from cache
if (m_inode_cache.contains(ino))
m_inode_cache.remove(ino);
auto it = m_inode_cache.find(ino);
if (it != m_inode_cache.end())
m_inode_cache.remove(it);
return {};
}

View File

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

View File

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