diff options
author | 2021-03-15 02:39:41 +0200 | |
---|---|---|
committer | 2021-03-15 02:39:41 +0200 | |
commit | a84c0f57b5efde85c195cbc706715bf4a4116018 (patch) | |
tree | d9c5715d637dd870ca5ffe6f3bb031297c8d2f45 /src/util.c | |
parent | 111d08d814720966d12fd57b58331c149df7e6cf (diff) | |
download | algos-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/util.c')
-rw-r--r-- | src/util.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -22,6 +22,21 @@ int stream_rewind(struct stream * const restrict in) return ret; } +int stream_skip(struct stream * const restrict in) +{ + int ret = 0; + size_t ss; + struct entry_l discard; + + ss = in->settings->ss; + + while (ss--) { + in->get(in, &discard); + } + + return ret; +} + int split(struct stream * const src, struct stream * const A, struct stream * const B) { int ret = 0; @@ -57,6 +72,7 @@ int split(struct stream * const src, struct stream * const A, struct stream * co try_s((ret = src->copy(src, A)), err); try_s((ret = cache_create(B)), err); try_s((ret = src->copy(src, B)), err); + stream_rewind(src); } else { A->name = B->name = src->name; A->type = B->type = stream_lite; @@ -64,6 +80,7 @@ int split(struct stream * const src, struct stream * const A, struct stream * co try_s((ret = src->copy(src, A)), err); try_s((ret = stream_open(B)), err); try_s((ret = src->copy(src, B)), err); + stream_rewind(src); } A->settings = B->settings = src->settings; |