summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/cache.c b/src/cache.c
index 2b24dd0..3a169b8 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -122,10 +122,9 @@ struct entry_l *cached_get_list(struct stream * const in, struct entry_l * const
{
struct entry_l *ret = NULL;
- if (in->index < in->n) {
+ if (in->cnode) {
ret = in->cnode;
- in->cnode = ret->next ? ret->next : in->cnode;
- ++in->index;
+ in->cnode = ret->next;
*store = *ret;
ret = store;
}
@@ -163,17 +162,14 @@ int cached_put_list(struct stream * const restrict in, const struct entry_l * co
if (!in->cnode) { /* if this is the very first one */
in->cnode = in->cache_l;
- in->cnode->val = node->val;
- in->cnode->next = NULL;
- in->index = 1;
} else {
in->cnode->next = in->cnode + 1; /* lol says librin, lmao */
in->cnode = in->cnode->next;
- in->cnode->val = node->val;
- in->cnode->next = NULL;
- ++in->index;
}
+ in->cnode->val = node->val;
+ in->cnode->next = NULL;
+
err:
return ret;
}