aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-13 23:47:44 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commit3fc450d7f586388135028ac83870d288834c34a1 (patch)
treea80cbe021ff2b946b1126a4b79c835d98fecbea3 /src/reader.h
parentfb95ceca3b744e47e973585aa682515365ac9eb0 (diff)
downloadserd-3fc450d7f586388135028ac83870d288834c34a1.tar.gz
serd-3fc450d7f586388135028ac83870d288834c34a1.tar.bz2
serd-3fc450d7f586388135028ac83870d288834c34a1.zip
Simplify stack management by popping in bulk at higher levels
Since all memory used by the reader is POD in the stack, there is no benefit to forcing code to explicitly pop everything pushed to the stack, since any function can record an offset and pop back down to it regardless of what its callers pushed if it knows that it does not need those items. This is slightly more efficient (due to avoiding many pop calls), but also more resilient since "leaks" at deeper levels of recursion get nuked by some caller regardless of what was pushed. This should help prevent future regressions like f6437f606 (Fix memory consumption when reading documents).
Diffstat (limited to 'src/reader.h')
-rw-r--r--src/reader.h15
1 files changed, 0 insertions, 15 deletions
diff --git a/src/reader.h b/src/reader.h
index a39fc278..d126aeaa 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -22,13 +22,6 @@
#include <stdint.h>
#include <stdio.h>
-#ifdef SERD_STACK_CHECK
-# define SERD_STACK_ASSERT_TOP(reader, ref) \
- assert(ref == reader->allocs[reader->n_allocs - 1]);
-#else
-# define SERD_STACK_ASSERT_TOP(reader, ref)
-#endif
-
typedef struct {
SerdNode* graph;
SerdNode* subject;
@@ -56,10 +49,6 @@ struct SerdReaderImpl {
size_t bprefix_len;
bool strict; ///< True iff strict parsing
bool seen_genid;
-#ifdef SERD_STACK_CHECK
- SerdNode** allocs; ///< Stack of push offsets
- size_t n_allocs; ///< Number of stack pushes
-#endif
};
SERD_LOG_FUNC(3, 4)
@@ -88,9 +77,6 @@ blank_id(SerdReader* reader);
void
set_blank_id(SerdReader* reader, SerdNode* node, size_t buf_size);
-SerdNode*
-pop_node(SerdReader* reader, const SerdNode* node);
-
SerdStatus
emit_statement(SerdReader* reader, ReadContext ctx, SerdNode* o);
@@ -161,7 +147,6 @@ static inline SerdStatus
push_byte(SerdReader* reader, SerdNode* node, const int c)
{
assert(c != EOF);
- SERD_STACK_ASSERT_TOP(reader, ref);
char* const s = (char*)serd_stack_push(&reader->stack, 1);
if (!s) {