Skip to content

Commit

Permalink
avoid resizing empty capture and value tables
Browse files Browse the repository at this point in the history
  • Loading branch information
dolik-rce committed Oct 10, 2023
1 parent b128a77 commit 118254f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/packcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4716,17 +4716,19 @@ static bool_t generate(context_t *ctx) {
" ctx->level++;\n",
ctx->rules.buf[i]->data.rule.name
);
stream__printf(
&sstream,
" pcc_value_table__resize(ctx->auxil, &chunk->values, " FMT_LU ");\n",
(ulong_t)ctx->rules.buf[i]->data.rule.vars.len
);
stream__printf(
&sstream,
" pcc_capture_table__resize(ctx->auxil, &chunk->capts, " FMT_LU ");\n",
(ulong_t)ctx->rules.buf[i]->data.rule.capts.len
);
if (ctx->rules.buf[i]->data.rule.capts.len > 0) {
stream__printf(
&sstream,
" pcc_capture_table__resize(ctx->auxil, &chunk->capts, " FMT_LU ");\n",
(ulong_t)ctx->rules.buf[i]->data.rule.capts.len
);
}
if (ctx->rules.buf[i]->data.rule.vars.len > 0) {
stream__printf(
&sstream,
" pcc_value_table__resize(ctx->auxil, &chunk->values, " FMT_LU ");\n",
(ulong_t)ctx->rules.buf[i]->data.rule.vars.len
);
stream__puts(
&sstream,
" pcc_value_table__clear(ctx->auxil, &chunk->values);\n"
Expand Down

0 comments on commit 118254f

Please sign in to comment.