Skip to content

Commit

Permalink
bitbake: data_smart: Small optimisation to _findVar()
Browse files Browse the repository at this point in the history
Some users of _findVar don't need the override data and even
getVarFlag doesn't need it in some common cases (parsing=True).

Rearrange the code as the current overridedata approach doesn't need
to be in the _findVar code anyway. This removes some search overhead
from a critical path.

(Bitbake rev: 60e4c2745e9fb81df5cf85a019e8748b28c7e5f8)

Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
rpurdie committed Jan 23, 2023
1 parent a47fe95 commit 3f53768
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bitbake/lib/bb/data_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,18 @@ def _findVar(self, var):
dest = self.dict
while dest:
if var in dest:
return dest[var], self.overridedata.get(var, None)
return dest[var]

if "_data" not in dest:
break
dest = dest["_data"]
return None, self.overridedata.get(var, None)
return None

def _makeShadowCopy(self, var):
if var in self.dict:
return

local_var, _ = self._findVar(var)
local_var = self._findVar(var)

if local_var:
self.dict[var] = copy.copy(local_var)
Expand Down Expand Up @@ -782,10 +782,12 @@ def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False,
if expand and cachename in self.expand_cache:
return self.expand_cache[cachename].value

local_var, overridedata = self._findVar(var)
local_var = self._findVar(var)
value = None
removes = set()
if flag == "_content" and overridedata is not None and not parsing:
if flag == "_content" and not parsing:
overridedata = self.overridedata.get(var, None)
if flag == "_content" and not parsing and overridedata is not None:
match = False
active = {}
self.need_overrides()
Expand Down Expand Up @@ -900,7 +902,7 @@ def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False,
def delVarFlag(self, var, flag, **loginfo):
self.expand_cache = {}

local_var, _ = self._findVar(var)
local_var = self._findVar(var)
if not local_var:
return
if not var in self.dict:
Expand Down Expand Up @@ -943,7 +945,7 @@ def setVarFlags(self, var, flags, **loginfo):
self.dict[var][i] = flags[i]

def getVarFlags(self, var, expand = False, internalflags=False):
local_var, _ = self._findVar(var)
local_var = self._findVar(var)
flags = {}

if local_var:
Expand Down

0 comments on commit 3f53768

Please sign in to comment.