[PATCHv2] wget: move loop-invariant load of BB_ORIGENV

Message ID 20220219165946.9355-1-zygmunt.krynicki@huawei.com
State New
Headers show
Series [PATCHv2] wget: move loop-invariant load of BB_ORIGENV | expand

Commit Message

Zygmunt Krynicki Feb. 19, 2022, 4:59 p.m. UTC
BB_ORIGENV is used as a fallback environment block. It is repeatedly
accessed 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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 253cabce..2579a65c 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -316,12 +316,11 @@  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 not value and origenv:
+                value = origenv.getVar(name)
             if value:
                 newenv[name] = value