diff options
author | 2012-01-25 18:51:26 -0800 | |
---|---|---|
committer | 2012-01-25 18:51:26 -0800 | |
commit | d6545588a3005074be0597396c077bc1a2435783 (patch) | |
tree | cac1d18ef9d15f3269f77224b9dd4e46b560d051 /autoload.cpp | |
parent | 26b375a0de3531f9a6c22299d3cdc15017daffeb (diff) |
Have to remember to evict nodes from our LRU cache
Diffstat (limited to 'autoload.cpp')
-rw-r--r-- | autoload.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/autoload.cpp b/autoload.cpp index 639eeca3..0bae1a26 100644 --- a/autoload.cpp +++ b/autoload.cpp @@ -8,7 +8,7 @@ The classes responsible for autoloading functions and completions. #include "wutil.h" #include <assert.h> -const size_t kLRULimit = 256; +static const size_t kLRULimit = 16; file_access_attempt_t access_file(const wcstring &path, int mode) { file_access_attempt_t result = {0}; @@ -93,14 +93,18 @@ bool lru_cache_impl_t::add_node(lru_node_t *node) { if (! node_set.insert(node).second) return false; - /* Update the count */ - node_count++; - /* Add the node after the mouth */ node->next = mouth.next; node->prev = &mouth; mouth.next = node; + /* Update the count */ + node_count++; + + /* Evict */ + while (node_count > kLRULimit) + evict_last_node(); + /* Success */ return true; } |