mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-30 00:09:01 +00:00
Kernel: Improve some low-memory situations with ext2
This commit is contained in:
parent
54c66b8f7b
commit
ae956edf6e
Notes:
sideshowbarker
2024-07-19 00:14:23 +09:00
Author: https://github.com/tomuta
Commit: ae956edf6e
Pull-request: https://github.com/SerenityOS/serenity/pull/4707
2 changed files with 9 additions and 7 deletions
|
@ -924,7 +924,6 @@ KResult Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
|
|||
#endif
|
||||
|
||||
auto buffer_or = read_entire();
|
||||
ASSERT(!buffer_or.is_error());
|
||||
if (buffer_or.is_error())
|
||||
return buffer_or.error();
|
||||
|
||||
|
@ -1537,11 +1536,11 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
|
|||
return inode.release_nonnull();
|
||||
}
|
||||
|
||||
void Ext2FSInode::populate_lookup_cache() const
|
||||
bool Ext2FSInode::populate_lookup_cache() const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (!m_lookup_cache.is_empty())
|
||||
return;
|
||||
return true;
|
||||
HashMap<String, unsigned> children;
|
||||
|
||||
KResult result = traverse_as_directory([&children](auto& entry) {
|
||||
|
@ -1549,17 +1548,20 @@ void Ext2FSInode::populate_lookup_cache() const
|
|||
return true;
|
||||
});
|
||||
|
||||
ASSERT(result.is_success());
|
||||
if (!result.is_success())
|
||||
return false;
|
||||
|
||||
if (!m_lookup_cache.is_empty())
|
||||
return;
|
||||
return false;
|
||||
m_lookup_cache = move(children);
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<Inode> Ext2FSInode::lookup(StringView name)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
populate_lookup_cache();
|
||||
if (!populate_lookup_cache())
|
||||
return {};
|
||||
LOCKER(m_lock);
|
||||
auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; });
|
||||
if (it != m_lookup_cache.end())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue