From 347039f64509e77ad5f6ef52ae70950c91886f8e Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 13 Feb 2025 18:56:46 +0100 Subject: src: add symbol range expression to further compact intervals Update parser to use a new symbol range expression with smaller memory footprint than range expression + two symbol expressions. The evaluation step translates this into EXPR_RANGE_VALUE for interval sets. Note that maps or concatenations still use the less compact range expressions representation, those require more work to use this new symbol range expression. The parser also uses the classic range expression if variables are used. Testing with a 100k intervals, worst case scenario: no prefix or singleton elements. This shows a reduction from 49.58 Mbytes to 35.47 Mbytes (-29.56% memory footprint for this case). This follow up work to previous commits: 91dc281a82ea ("src: rework singleton interval transformation to reduce memory consumption") c9ee9032b0ee ("src: add EXPR_RANGE_VALUE expression and use it") Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index fa8dc83f..f5512783 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -4425,7 +4425,16 @@ prefix_rhs_expr : basic_rhs_expr SLASH NUM range_rhs_expr : basic_rhs_expr DASH basic_rhs_expr { - $$ = range_expr_alloc(&@$, $1, $3); + if ($1->etype == EXPR_SYMBOL && + $1->symtype == SYMBOL_VALUE && + $3->etype == EXPR_SYMBOL && + $3->symtype == SYMBOL_VALUE) { + $$ = symbol_range_expr_alloc(&@$, $1->symtype, $1->scope, $1->identifier, $3->identifier); + expr_free($1); + expr_free($3); + } else { + $$ = range_expr_alloc(&@$, $1, $3); + } } ; -- cgit v1.2.3