diff options
author | David Robillard <d@drobilla.net> | 2018-11-11 15:29:59 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 23:04:24 -0500 |
commit | 86178f4cac2259cd2c26ef27488c3ea36a947c7d (patch) | |
tree | 7779166f6dfb5a72b22fe8f13dd296bf06df408c | |
parent | 41141360516e93101ae60bd737a3fb8f250f8f7d (diff) | |
download | serd-86178f4cac2259cd2c26ef27488c3ea36a947c7d.tar.gz serd-86178f4cac2259cd2c26ef27488c3ea36a947c7d.tar.bz2 serd-86178f4cac2259cd2c26ef27488c3ea36a947c7d.zip |
Simplify reader stack pushing code
-rw-r--r-- | src/reader.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reader.h b/src/reader.h index d9391ac8..252733cf 100644 --- a/src/reader.h +++ b/src/reader.h @@ -169,14 +169,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 |