mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK: Enable fast path for removal by hash-compatible key in HashMap/Table
This commit is contained in:
parent
b429f9c7aa
commit
c673b7220a
Notes:
sideshowbarker
2024-07-17 22:44:33 +09:00
Author: https://github.com/Hendiadyoin1
Commit: c673b7220a
Pull-request: https://github.com/SerenityOS/serenity/pull/11268
Reviewed-by: https://github.com/alimpfard
2 changed files with 22 additions and 0 deletions
11
AK/HashMap.h
11
AK/HashMap.h
|
@ -63,6 +63,17 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
template<Concepts::HashCompatible<K> Key>
|
||||
requires(IsSame<KeyTraits, Traits<K>>) bool remove(Key const& key)
|
||||
{
|
||||
auto it = find(key);
|
||||
if (it != end()) {
|
||||
m_table.remove(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
using HashTableType = HashTable<Entry, EntryTraits, IsOrdered>;
|
||||
using IteratorType = typename HashTableType::Iterator;
|
||||
using ConstIteratorType = typename HashTableType::ConstIterator;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue