idk look at the changes
This commit is contained in:
parent
1746f7d940
commit
16adfd7cc5
10 changed files with 303 additions and 53 deletions
15
src/cache.c3
15
src/cache.c3
|
|
@ -62,8 +62,9 @@ fn Value*! Cache.search(&cache, Key id)
|
|||
// get_entry() faults on miss
|
||||
IdTableEntry* entry = cache.table.get_entry(id)!;
|
||||
|
||||
/* MISS */
|
||||
/* MISS, wrong key */
|
||||
if (entry.key != id) {
|
||||
cache.table.remove(id)!;
|
||||
return SearchResult.MISSING?;
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +80,18 @@ fn Value*! Cache.search(&cache, Key id)
|
|||
return &(cache.pool[entry.value]);
|
||||
}
|
||||
|
||||
fn void Cache.remove(&cache, Key id)
|
||||
{
|
||||
IdTableEntry*! entry = cache.table.get_entry(id);
|
||||
if (catch entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
// found, remove it
|
||||
cache.present[entry.value] = false;
|
||||
(void)cache.table.remove(id);
|
||||
}
|
||||
|
||||
/* Look for a free spot in the present bitmap and return its index */
|
||||
/* If there is no free space left then just return the first position */
|
||||
fn usz Cache.get_free_spot(&cache) @private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue