summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorGravatar Gediminas Jakutis <gediminas@varciai.lt> 2021-03-15 02:39:41 +0200
committerGravatar Gediminas Jakutis <gediminas@varciai.lt> 2021-03-15 02:39:41 +0200
commita84c0f57b5efde85c195cbc706715bf4a4116018 (patch)
treed9c5715d637dd870ca5ffe6f3bb031297c8d2f45 /src/cache.c
parent111d08d814720966d12fd57b58331c149df7e6cf (diff)
downloadalgos-ld1-1.0.tar.gz
algos-ld1-1.0.tar.bz2
algos-ld1-1.0.zip
cleanup and optimizations.algos-ld1-1.0
· No longer rewinding a stream being split, just to skip half through it again, which was not only stupid, but inneficient. · No longer using "index" anywhere when working with lists, lest we get accused of not actually doing lists. Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
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;
}