1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:17:36 +00:00

Add a very naive block cache to the DiskBackedFileSystem.

This would be a lot better as an LRU. Right now it's a 32-slot
hash table with random eviction.
This commit is contained in:
Andreas Kling 2018-10-25 12:35:49 +02:00
parent 82bbfa8496
commit fdc782c1d1
4 changed files with 36 additions and 3 deletions

View file

@ -49,9 +49,12 @@ public:
bool isEmpty() const { return m_table.isEmpty(); }
unsigned size() const { return m_table.size(); }
unsigned capacity() const { return m_table.capacity(); }
void clear() { m_table.clear(); }
void set(const K&, const V&);
void set(const K&, V&&);
void remove(const K&);
void removeOneRandomly() { m_table.remove(m_table.begin()); }
typedef HashTable<Entry, EntryTraits> HashTableType;
typedef typename HashTableType::Iterator IteratorType;
@ -77,6 +80,12 @@ void HashMap<K, V>::set(const K& key, V&& value)
m_table.set(Entry{key, move(value)});
}
template<typename K, typename V>
void HashMap<K, V>::set(const K& key, const V& value)
{
m_table.set(Entry{key, value});
}
template<typename K, typename V>
void HashMap<K, V>::remove(const K& key)
{