aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-12 01:15:58 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-12 01:15:58 +0200
commitfaf04402985b1a964298a51985d91ae348015230 (patch)
treebc8d34f2929737fa8fe5dcec216d131bf9357d17
parent3d058de9cc8e58081d6c0eda410183388e26b85c (diff)
Use smaller default capacities in debug mode
-rw-r--r--src/lexer.c8
-rw-r--r--src/parser.c20
2 files changed, 15 insertions, 13 deletions
diff --git a/src/lexer.c b/src/lexer.c
index 400d1e4..790d7bf 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -13,8 +13,12 @@
#include "lexer.h"
#include "unicode.h"
-#define LEXEMES_DFLT_CAP (2048)
-#define SIZE_WDTH (sizeof(size_t) * CHAR_BIT)
+#if DEBUG
+# define LEXEMES_DFLT_CAP (8)
+#else
+# define LEXEMES_DFLT_CAP (2048)
+#endif
+#define SIZE_WDTH (sizeof(size_t) * CHAR_BIT)
static bool skip_comment(const uchar **, const uchar *);
diff --git a/src/parser.c b/src/parser.c
index a1028aa..6273fd7 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -11,17 +11,15 @@
#include "errors.h"
#include "parser.h"
-/* #define AST_DFLT_CAP (2048) */
-#define AST_DFLT_CAP (8)
-#define SIZE_WDTH (sizeof(size_t) * CHAR_BIT)
-
-typedef idx_t_ parsefn(struct ast *, struct lexemes);
-static parsefn parseblk,
- parsedecl,
- parseexpr,
- parseproto,
- parsestmt,
- parsetype;
+#if DEBUG
+# define AST_DFLT_CAP (8)
+#else
+# define AST_DFLT_CAP (2048)
+#endif
+#define SIZE_WDTH (sizeof(size_t) * CHAR_BIT)
+
+typedef idx_t_ parsefn(struct ast *, struct lexemes) __attribute__((nonnull));
+static parsefn parseblk, parsedecl, parseexpr, parseproto, parsestmt, parsetype;
static struct ast mkast(void);
static idx_t_ astalloc(struct ast *) __attribute__((nonnull));