From 8aa611269f1a0c4ab0d18e65f1c0007a42a5800b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 1 Jul 2019 00:28:54 +0200 Subject: Use STR_TO_TRI for some n/m/y membership tests 20% faster lookup in line_profiler in _tokenize(). The test usually fails. --- kconfiglib.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'kconfiglib.py') 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 -- cgit v1.2.3