aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-11 15:29:59 +0100
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commitadcc570e4829c918798d3ccd7da9c8f5e0d137b6 (patch)
treecad3b1d779f3e297bc42a84f7364b89635f2e228 /src/reader.h
parent1cb902b98bdbdbcae1217b0d189c9dce3ffe3bb0 (diff)
downloadserd-adcc570e4829c918798d3ccd7da9c8f5e0d137b6.tar.gz
serd-adcc570e4829c918798d3ccd7da9c8f5e0d137b6.tar.bz2
serd-adcc570e4829c918798d3ccd7da9c8f5e0d137b6.zip
Simplify reader stack pushing code
Diffstat (limited to 'src/reader.h')
-rw-r--r--src/reader.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reader.h b/src/reader.h
index 6e9ac513..7865fb39 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -176,14 +176,14 @@ push_bytes(SerdReader* reader,
const uint8_t* bytes,
unsigned len)
{
- if (reader->stack.buf_size < reader->stack.size + len) {
- return SERD_ERR_OVERFLOW;
+ const bool has_space = reader->stack.buf_size >= reader->stack.size + len;
+ if (has_space) {
+ for (unsigned i = 0; i < len; ++i) {
+ push_byte(reader, ref, bytes[i]);
+ }
}
- for (unsigned i = 0; i < len; ++i) {
- push_byte(reader, ref, bytes[i]);
- }
- return SERD_SUCCESS;
+ return has_space ? SERD_SUCCESS : SERD_ERR_OVERFLOW;
}
#endif // SERD_READER_H