From 3ddde0b6c97d42ee67e1beef6952bee4bde69668 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 17 Oct 2025 16:59:24 +0200 Subject: interpreterbase: make ArithmeticNode and MesonOperator both use operator names This avoids creating a dictionary every time an arithmetic operator is evaluated. Signed-off-by: Paolo Bonzini --- mesonbuild/mparser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mesonbuild/mparser.py') diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index eee6ffc04..b5792d251 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -674,7 +674,7 @@ class ParenthesizedNode(BaseNode): if T.TYPE_CHECKING: COMPARISONS = Literal['==', '!=', '<', '<=', '>=', '>', 'in', 'not in'] - ARITH_OPERATORS = Literal['add', 'sub', 'mul', 'div', 'mod'] + ARITH_OPERATORS = Literal['+', '-', '*', '/', '%'] ALL_STRINGS = frozenset({'string', 'fstring', 'multiline_string', 'multiline_fstring'}) @@ -690,14 +690,14 @@ COMPARISON_MAP: T.Mapping[str, COMPARISONS] = { } ADDSUB_MAP: T.Mapping[str, ARITH_OPERATORS] = { - 'plus': 'add', - 'dash': 'sub', + 'plus': '+', + 'dash': '-', } MULDIV_MAP: T.Mapping[str, ARITH_OPERATORS] = { - 'percent': 'mod', - 'star': 'mul', - 'fslash': 'div', + 'percent': '%', + 'star': '*', + 'fslash': '/', } # Recursive descent parser for Meson's definition language. -- cgit v1.2.3