aboutsummaryrefslogtreecommitdiff
path: root/lib/io/src/istream.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-11 15:40:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-11 15:40:26 +0200
commit366ccf20745b23f1eb8554cbe17e6972271de002 (patch)
tree93951efe96966db4c766c140431dd017fd15cf80 /lib/io/src/istream.c
parentad1691aa33cfc1b1558ce10e93552d0eb1cdcd63 (diff)
libio: remove precache from istream_advance_buffer
Since the user has to call istream_get_buffered_data afterwards anyway, we can do the precache lazily. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/src/istream.c')
-rw-r--r--lib/io/src/istream.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/io/src/istream.c b/lib/io/src/istream.c
index b4c709c..9340dd6 100644
--- a/lib/io/src/istream.c
+++ b/lib/io/src/istream.c
@@ -29,13 +29,10 @@ sqfs_s32 istream_read(istream_t *strm, void *data, size_t size)
diff = size;
memcpy(data, ptr, diff);
+ istream_advance_buffer(strm, diff);
data = (char *)data + diff;
size -= diff;
total += diff;
-
- ret = istream_advance_buffer(strm, diff);
- if (ret)
- return -1;
}
return total;
@@ -61,9 +58,7 @@ int istream_skip(istream_t *strm, sqfs_u64 size)
diff = size;
size -= diff;
-
- if (istream_advance_buffer(strm, diff))
- return -1;
+ istream_advance_buffer(strm, diff);
}
return 0;
@@ -92,11 +87,10 @@ sqfs_s32 istream_splice(istream_t *in, ostream_t *out, sqfs_u32 size)
if (ostream_append(out, ptr, diff))
return -1;
- if (istream_advance_buffer(in, diff))
- return -1;
total += diff;
size -= diff;
+ istream_advance_buffer(in, diff);
}
return total;