From faf04402985b1a964298a51985d91ae348015230 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 12 Jun 2024 01:15:58 +0200 Subject: Use smaller default capacities in debug mode --- src/lexer.c | 8 ++++++-- src/parser.c | 20 +++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src') 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)); -- cgit v1.2.3