Have to remember to evict nodes from our LRU cache

This commit is contained in:
ridiculousfish 2012-01-25 18:51:26 -08:00
parent 26b375a0de
commit d6545588a3
2 changed files with 9 additions and 5 deletions

View file

@ -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;
}

View file

@ -70,7 +70,7 @@ static bool function_remove_ignore_autoload(const wcstring &name);
/** Callback when an autoloaded function is removed */
void function_autoload_t::command_removed(const wcstring &cmd) {
function_remove(cmd);
function_remove_ignore_autoload(cmd);
}
/* Helper macro for vomiting */