mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +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:
parent
82bbfa8496
commit
fdc782c1d1
4 changed files with 36 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue