From 8105b8b04cb1d90efaf7e0c20946c956ee85f5ed Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 1 Jul 2019 17:49:59 +0200 Subject: Merge orig_type and _visited assignments in constructors Small optimization. We know that UNKNOWN == 0, and it's always tested for by checking truthiness rather than identity within the library, so there can't be trouble even without small integer optimization. --- kconfiglib.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 1bbc24a..12471a9 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4645,14 +4645,17 @@ class Symbol(object): # rev_dep # weak_rev_dep - self.orig_type = UNKNOWN + # - UNKNOWN == 0 + # - _visited is used during tree iteration and dep. loop detection + self.orig_type = self._visited = 0 + + self.nodes = [] + self.defaults = [] self.selects = [] self.implies = [] self.ranges = [] - self.nodes = [] - self.user_value = \ self.choice = \ self.env_var = \ @@ -4669,10 +4672,6 @@ class Symbol(object): # See Kconfig._build_dep() self._dependents = set() - # Used during dependency loop detection and (independently) in - # node_iter() - self._visited = 0 - def _assignable(self): # Worker function for the 'assignable' attribute @@ -5221,12 +5220,15 @@ class Choice(object): # direct_dep # kconfig - self.orig_type = UNKNOWN - self.syms = [] - self.defaults = [] + # - UNKNOWN == 0 + # - _visited is used during dep. loop detection + self.orig_type = self._visited = 0 self.nodes = [] + self.syms = [] + self.defaults = [] + self.name = \ self.user_value = self.user_selection = \ self._cached_vis = self._cached_assignable = None @@ -5240,9 +5242,6 @@ class Choice(object): # See Kconfig._build_dep() self._dependents = set() - # Used during dependency loop detection - self._visited = 0 - def _assignable(self): # Worker function for the 'assignable' attribute -- cgit v1.2.3