summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-02 09:02:15 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-03 10:12:42 +0000
commit34e4eebc32c4836fc40098e90b17c00f51398967 (patch)
tree20f3ba43c0341cbed8b454c92d60e0fc326b9d50 /bitbake/lib/bb/fetch2/__init__.py
parent791d6e63be09b361dd3397707a0507399b9a9ce7 (diff)
downloadpoky-34e4eebc32c4836fc40098e90b17c00f51398967.tar.gz
bitbake: lib/bb: Fix string concatination potential performance issues
Python scales badly when concatinating strings in loops. Most of these references aren't problematic but at least one (in data.py) is probably a performance issue as the issue is compounded as strings become large. The way to handle this in python is to create lists which don't reconstruct all the objects when appending to them. We may as well fix all the references since it stops them being copy/pasted into something problematic in the future. This patch was based on issues highligthted by a report from AWS Codeguru. (Bitbake rev: d654139a833127b16274dca0ccbbab7e3bb33ed0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 1d6e4e0964..43b312ce7e 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -402,24 +402,24 @@ def encodeurl(decoded):
402 402
403 if not type: 403 if not type:
404 raise MissingParameterError('type', "encoded from the data %s" % str(decoded)) 404 raise MissingParameterError('type', "encoded from the data %s" % str(decoded))
405 url = '%s://' % type 405 url = ['%s://' % type]
406 if user and type != "file": 406 if user and type != "file":
407 url += "%s" % user 407 url.append("%s" % user)
408 if pswd: 408 if pswd:
409 url += ":%s" % pswd 409 url.append(":%s" % pswd)
410 url += "@" 410 url.append("@")
411 if host and type != "file": 411 if host and type != "file":
412 url += "%s" % host 412 url.append("%s" % host)
413 if path: 413 if path:
414 # Standardise path to ensure comparisons work 414 # Standardise path to ensure comparisons work
415 while '//' in path: 415 while '//' in path:
416 path = path.replace("//", "/") 416 path = path.replace("//", "/")
417 url += "%s" % urllib.parse.quote(path) 417 url.append("%s" % urllib.parse.quote(path))
418 if p: 418 if p:
419 for parm in p: 419 for parm in p:
420 url += ";%s=%s" % (parm, p[parm]) 420 url.append(";%s=%s" % (parm, p[parm]))
421 421
422 return url 422 return "".join(url)
423 423
424def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): 424def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None):
425 if not ud.url or not uri_find or not uri_replace: 425 if not ud.url or not uri_find or not uri_replace: