diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-17 16:59:24 +0200 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-08 10:08:10 -0800 |
| commit | 3ddde0b6c97d42ee67e1beef6952bee4bde69668 (patch) | |
| tree | 0e9f271ea04277d678e7e75ef45dfd09f32a19ca /mesonbuild/mparser.py | |
| parent | c8ab1d29d62518c630e589941524e13643a4267a (diff) | |
| download | meson-3ddde0b6c97d42ee67e1beef6952bee4bde69668.tar.gz | |
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 <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/mparser.py')
| -rw-r--r-- | mesonbuild/mparser.py | 12 |
1 files changed, 6 insertions, 6 deletions
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. |
