From 121d4a95ed0cd6cf64d64b92eedfb163a531d672 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 5 Jun 2015 04:43:06 +0200 Subject: Improve tokenization performance by removing a single character. strip() instead of lstrip() makes the loop terminate earlier, saving lots of calls. Shaves a few % of parsing the x86 Kconfigs. --- kconfiglib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index fbeaad5..4679126 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -614,7 +614,11 @@ class Config(object): for_eval -- True when parsing an expression for a call to Config.eval(), in which case we should not treat the first token specially nor register new symbols.""" - s = s.lstrip() + + # lstrip() would work here too, but removing the '\n' at the end leads + # to earlier termination in the 'while' loop below, saving lots of + # calls + s = s.strip() if s == "" or s[0] == "#": return _Feed([]) -- cgit v1.2.3