From 40e3e36f41b211d89edbbedfbfb1e4ab8b102d49 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 21 Oct 2018 08:38:06 +0200 Subject: Sort _parse_properties() cases by frequency Use the Linux x86 Kconfig frequencies. Most cases were already sorted, but the blank line case was treated specially. 'imply' was checked too early too (though it's used more in some other projects). --- kconfiglib.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 9fd9e9f..8d0e61c 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2663,8 +2663,6 @@ class Kconfig(object): while self._next_line(): t0 = self._next_token() - if t0 is None: - continue if t0 in _TYPE_TOKENS: self._set_type(node, _TOKEN_TO_TYPE[t0]) @@ -2688,12 +2686,9 @@ class Kconfig(object): node.selects.append((self._expect_nonconst_sym(), self._parse_cond())) - elif t0 is _T_IMPLY: - if not isinstance(node.item, Symbol): - self._parse_error("only symbols can imply") - - node.implies.append((self._expect_nonconst_sym(), - self._parse_cond())) + elif t0 is None: + # Blank line + continue elif t0 is _T_DEFAULT: node.defaults.append((self._parse_expr(False), @@ -2713,6 +2708,21 @@ class Kconfig(object): self._expect_sym(), self._parse_cond())) + elif t0 is _T_IMPLY: + if not isinstance(node.item, Symbol): + self._parse_error("only symbols can imply") + + node.implies.append((self._expect_nonconst_sym(), + self._parse_cond())) + + elif t0 is _T_VISIBLE: + if not self._check_token(_T_IF): + self._parse_error('expected "if" after "visible"') + + node.visibility = self._make_and(node.visibility, + self._expect_expr_and_eol()) + + elif t0 is _T_OPTION: if self._check_token(_T_ENV): if not self._check_token(_T_EQUAL): @@ -2778,13 +2788,6 @@ class Kconfig(object): else: self._parse_error("unrecognized option") - elif t0 is _T_VISIBLE: - if not self._check_token(_T_IF): - self._parse_error('expected "if" after "visible"') - - node.visibility = self._make_and(node.visibility, - self._expect_expr_and_eol()) - elif t0 is _T_OPTIONAL: if not isinstance(node.item, Choice): self._parse_error('"optional" is only valid for choices') -- cgit v1.2.3