aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-12-19 14:28:39 -0500
committerDavid Robillard <d@drobilla.net>2020-06-21 18:12:04 +0200
commitad76a6b3ebbfccfc73d8f9bf4def9a3f72a5b433 (patch)
tree5cd2eb03664b68092958a7fe55243ba6858a6508
parent1da462d0fceeb18690601398bb224c0f92143341 (diff)
downloadserd-ad76a6b3ebbfccfc73d8f9bf4def9a3f72a5b433.tar.gz
serd-ad76a6b3ebbfccfc73d8f9bf4def9a3f72a5b433.tar.bz2
serd-ad76a6b3ebbfccfc73d8f9bf4def9a3f72a5b433.zip
Improve push_byte() performance
-rw-r--r--src/reader.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/reader.h b/src/reader.h
index dd78d5c0..c6a0ca24 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -154,14 +154,14 @@ push_byte(SerdReader* reader, SerdNode* node, const int c)
assert(c != EOF);
SERD_STACK_ASSERT_TOP(reader, node);
- char* const s = (char*)serd_stack_push(&reader->stack, 1);
- if (!s) {
+ if (reader->stack.size + 1 > reader->stack.buf_size) {
return SERD_ERR_OVERFLOW;
}
+ ((uint8_t*)reader->stack.buf)[reader->stack.size - 1] = (uint8_t)c;
+ ++reader->stack.size;
++node->n_bytes;
- *(s - 1) = (uint8_t)c;
- *s = '\0';
+
return SERD_SUCCESS;
}