diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-07-01 00:28:54 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-07-01 01:28:09 +0200 |
| commit | 8aa611269f1a0c4ab0d18e65f1c0007a42a5800b (patch) | |
| tree | 2be6a003b84508e0b0e3ba7a9f18b6cda4043994 | |
| parent | 372b90946cdcc93fb9f0713e22c785d7437c4bdc (diff) | |
Use STR_TO_TRI for some n/m/y membership tests
20% faster lookup in line_profiler in _tokenize(). The test usually
fails.
| -rw-r--r-- | kconfiglib.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index c63abfe..944d153 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2290,9 +2290,8 @@ class Kconfig(object): else: i = match.end() - token = self.const_syms[name] \ - if name in ("y", "m", "n") else \ - self._lookup_sym(name) + token = self.const_syms[name] if name in STR_TO_TRI else \ + self._lookup_sym(name) else: # It's a case of missing quotes. For example, the @@ -5893,7 +5892,7 @@ def standard_sc_expr_str(sc): See expr_str(). """ if sc.__class__ is Symbol: - if sc.is_constant and sc.name not in ("n", "m", "y"): + if sc.is_constant and sc.name not in STR_TO_TRI: return '"{}"'.format(escape(sc.name)) return sc.name |
