Message ID | 20220219164439.8534-1-zygmunt.krynicki@huawei.com |
---|---|
State | New |
Headers | show |
Series | wget: move loop-invariant load of BB_ORIGENV | expand |
> -----Original Message----- > From: bitbake-devel@lists.openembedded.org <bitbake- > devel@lists.openembedded.org> On Behalf Of Zygmunt Krynicki via > lists.openembedded.org > Sent: den 19 februari 2022 17:45 > To: bitbake-devel@lists.openembedded.org > Cc: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> > Subject: [bitbake-devel] [PATCH] wget: move loop-invariant load of > BB_ORIGENV > > BB_ORIGENV is used as a fallback environment block. It is repeatedly > access inside the loop. Since it is a loop invariant, move it out of the Change "access" to "accessed". > loop. > > Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> > --- > lib/bb/fetch2/wget.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py > index 253cabce..9a3a9d66 100644 > --- a/lib/bb/fetch2/wget.py > +++ b/lib/bb/fetch2/wget.py > @@ -316,10 +316,10 @@ class Wget(FetchMethod): > # to scope the changes to the build_opener request, which is when > the > # environment lookups happen. > newenv = {} > + origenv = d.getVar("BB_ORIGENV") > for name in bb.fetch2.FETCH_EXPORT_VARS: > value = d.getVar(name) > if not value: > - origenv = d.getVar("BB_ORIGENV") > if origenv: > value = origenv.getVar(name) You can simplify it to: if not value and origenv: value = origenv.getVar(name) > if value: > -- > 2.25.1
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py index 253cabce..9a3a9d66 100644 --- a/lib/bb/fetch2/wget.py +++ b/lib/bb/fetch2/wget.py @@ -316,10 +316,10 @@ class Wget(FetchMethod): # to scope the changes to the build_opener request, which is when the # environment lookups happen. newenv = {} + origenv = d.getVar("BB_ORIGENV") for name in bb.fetch2.FETCH_EXPORT_VARS: value = d.getVar(name) if not value: - origenv = d.getVar("BB_ORIGENV") if origenv: value = origenv.getVar(name) if value:
BB_ORIGENV is used as a fallback environment block. It is repeatedly access inside the loop. Since it is a loop invariant, move it out of the loop. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- lib/bb/fetch2/wget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)