Skip to content

Commit

Permalink
Merge pull request #70 from dolik-rce/optimize-table-resizing
Browse files Browse the repository at this point in the history
Avoid resizing empty capture and value tables
  • Loading branch information
arithy authored Oct 22, 2023
2 parents b128a77 + 118254f commit 80b9485
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 80b9485

Please sign in to comment.