[PATCH] data: Optimise renameVar when a variable doesn't exist
Richard Purdie <[email protected]> Wed, 1 Jul 2026 14:55:57 +0100
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <[email protected]> |
Currently, if a variable doesn't exist, a history entry for the rename is still created, even if you're renaming nothing to nothing. That extra data is pretty pointless and we can improve renameVar speed around 20% in normal parsing operations if we skip it. It will also lower memory consuption and data store size which will help too. Signed-off-by: Richard Purdie <[email protected]> --- lib/bb/data_smart.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 110dfa11162..9961269a3f8 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -669,6 +669,8 @@ class DataSmart(MutableMapping): bb.warn("Calling renameVar with equivalent keys (%s) is invalid" % key) return + found = False + val = self.getVar(key, 0, parsing=True) if val is not None: self.varhistory.rename_variable_hist(key, newkey) @@ -677,6 +679,7 @@ class DataSmart(MutableMapping): loginfo['detail'] = val self.varhistory.record(**loginfo) self.setVar(newkey, val, ignore=True, parsing=True) + found = True srcflags = self.getVarFlags(key, False, True) or {} for i in srcflags: @@ -688,13 +691,20 @@ class DataSmart(MutableMapping): dest = self.getVarFlag(newkey, i, False) or [] dest.extend(src) self.setVarFlag(newkey, i, dest, ignore=True) + found = True if key in self.overridedata: + found = True self.overridedata[newkey] = [] for (v, o) in self.overridedata[key]: self.overridedata[newkey].append([v.replace(key, newkey), o]) self.renameVar(v, v.replace(key, newkey)) + if not found: + # No variable to rename so not worth the work in writing extra + # history data for performance + return + if ':' in newkey and val is None: self._setvar_update_overrides(newkey, **loginfo)