From ac7a559d96edd52f650fe01fcc847fbf77f21f64 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 24 Aug 2019 22:39:12 +0200 Subject: [PATCH] Ext2FS: Avoid a String allocation in lookup() By using find() with a custom finder, we can avoid creating a temporary key value that's only used for the hash lookup. --- Kernel/FileSystem/Ext2FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 842e11dc15..20b1d307ff 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1263,7 +1263,7 @@ InodeIdentifier Ext2FSInode::lookup(StringView name) ASSERT(is_directory()); populate_lookup_cache(); LOCKER(m_lock); - auto it = m_lookup_cache.find(name); + auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; }); if (it != m_lookup_cache.end()) return { fsid(), (*it).value }; return {};