summaryrefslogtreecommitdiff
path: root/src/stream.h
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2021-09-12 20:55:21 +1000
committerDonovan Baarda <abo@minkirri.apana.org.au>2021-09-12 20:55:21 +1000
commit8ca6145d1d6247e64db0c185f2a08e1bd7101ca4 (patch)
tree8d70e398ff285da8879580074406d7287b80ae31 /src/stream.h
parentb8d9421a97488fd8d45d27c84da0ae20057d8a6f (diff)
downloadlibrsync-8ca6145d1d6247e64db0c185f2a08e1bd7101ca4.tar.gz
Only shuffle the scoop buffer if it's necessary to make space.
Rename rs_scoop_total_avail() to rs_scoop_avail() and make it a static inline in stream.h Remove rs_job_input_is_ending() from job.[hc] and replace it with a rs_scoop_eof() static inline in stream.h. In scoop.c make rs_scoop_input() only shuffle data to the start of the buffer if necessary to free up space. Also make an assert() check more strict about the data being within the buffer. Slightly tidy up rs_scoop_read_rest(). In delta.c make rs_delta_s_slack() neater by using the new rs_scoop_*() functions.
Diffstat (limited to 'src/stream.h')
-rw-r--r--src/stream.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/stream.h b/src/stream.h
index be6e286..e5f6a44 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -75,6 +75,7 @@
* nothing else can be done. */
#ifndef STREAM_H
# define STREAM_H
+# include "job.h"
size_t rs_buffers_copy(rs_buffers_t *stream, size_t len);
@@ -88,6 +89,16 @@ void rs_scoop_advance(rs_job_t *job, size_t len);
rs_result rs_scoop_readahead(rs_job_t *job, size_t len, void **ptr);
rs_result rs_scoop_read(rs_job_t *job, size_t len, void **ptr);
rs_result rs_scoop_read_rest(rs_job_t *job, size_t *len, void **ptr);
-size_t rs_scoop_total_avail(rs_job_t *job);
+
+static inline size_t rs_scoop_avail(rs_job_t *job)
+{
+ return job->scoop_avail + job->stream->avail_in;
+}
+
+/** Test if the scoop has reached eof. */
+static inline bool rs_scoop_eof(rs_job_t *job)
+{
+ return !rs_scoop_avail(job) && job->stream->eof_in;
+}
#endif /* !STREAM_H */