mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
lru to use std::map, not std::unordered_map
We depend on pointer stability here and it just seems easier to think about it with std::map.
This commit is contained in:
parent
624e76ae89
commit
10ac83ae32
1 changed files with 2 additions and 4 deletions
|
@ -44,8 +44,6 @@ class lru_cache_t {
|
|||
explicit lru_node_t(Contents &&v) : value(std::move(v)) {}
|
||||
};
|
||||
|
||||
typedef typename std::unordered_map<wcstring, lru_node_t>::iterator node_iter_t;
|
||||
|
||||
// Max node count. This may be (transiently) exceeded by add_node_without_eviction, which is
|
||||
// used from background threads.
|
||||
const size_t max_node_count;
|
||||
|
@ -53,7 +51,7 @@ class lru_cache_t {
|
|||
// All of our nodes
|
||||
// Note that our linked list contains pointers to these nodes in the map
|
||||
// We are dependent on the iterator-noninvalidation guarantees of std::map
|
||||
std::unordered_map<wcstring, lru_node_t> node_map;
|
||||
std::map<wcstring, lru_node_t> node_map;
|
||||
|
||||
// Head of the linked list
|
||||
// The list is circular!
|
||||
|
@ -227,7 +225,7 @@ class lru_cache_t {
|
|||
}
|
||||
|
||||
// Tell the node where it is in the map
|
||||
node_iter_t iter = iter_inserted.first;
|
||||
auto iter = iter_inserted.first;
|
||||
lru_node_t *node = &iter->second;
|
||||
node->key = &iter->first;
|
||||
|
||||
|
|
Loading…
Reference in a new issue