aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-11 15:29:59 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commit38f2d631ae89388ca96ebfbc66012c8c29a3d35b (patch)
tree85b8fa80448fe30cacd9c8acb35fe4cec90077bc /src
parent8577bb961b6819506619a0dff06f65796f56c86a (diff)
downloadserd-38f2d631ae89388ca96ebfbc66012c8c29a3d35b.tar.gz
serd-38f2d631ae89388ca96ebfbc66012c8c29a3d35b.tar.bz2
serd-38f2d631ae89388ca96ebfbc66012c8c29a3d35b.zip
Simplify reader stack pushing code
Diffstat (limited to 'src')
-rw-r--r--src/reader.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reader.h b/src/reader.h
index bded249a..3f830ef4 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -167,14 +167,14 @@ push_bytes(SerdReader* reader,
const uint8_t* bytes,
unsigned len)
{
- if (reader->stack.buf_size < reader->stack.size + len) {
- return SERD_BAD_STACK;
+ 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_BAD_STACK;
}
#endif // SERD_SRC_READER_H