diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-02 07:39:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-02 07:39:11 -0700 |
commit | 9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a (patch) | |
tree | b25e6614e9f6c2ef05939f8c897a625b8a652c14 | |
parent | 7ef09a3af8246fdd17f27855a93803162562acf3 (diff) | |
download | txr-9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a.tar.gz txr-9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a.tar.bz2 txr-9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a.zip |
Slot cache fix: zero is a valid slot index.
struct.c (cacheline_lookup): return -1 when the id is not
found in the cacheline, rather than zero.
(lookup_slot): Test return value of cacheline_lookup
according to the above change.
-rw-r--r-- | struct.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -323,7 +323,7 @@ static int cache_set_lookup(slot_cache_entry_t *set, cnum id) return set[2].slot; } - return 0; + return -1; } static void cache_set_insert(slot_cache_entry_t *set, cnum id, cnum slot) @@ -352,7 +352,7 @@ static val *lookup_slot(struct struct_inst *si, val sym) slot_cache_set_t *set = &slot_cache[id % SLOT_CACHE_SIZE]; cnum slot = cache_set_lookup(*set, id); - if (slot) { + if (slot >= 0) { return &si->slot[slot]; } else { val key = cons(sym, num_fast(id)); |