summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.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/data_smart.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/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 8d235da121..7ed7112bdc 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -810,7 +810,7 @@ class DataSmart(MutableMapping):
810 expanded_removes[r] = self.expand(r).split() 810 expanded_removes[r] = self.expand(r).split()
811 811
812 parser.removes = set() 812 parser.removes = set()
813 val = "" 813 val = []
814 for v in __whitespace_split__.split(parser.value): 814 for v in __whitespace_split__.split(parser.value):
815 skip = False 815 skip = False
816 for r in removes: 816 for r in removes:
@@ -819,8 +819,8 @@ class DataSmart(MutableMapping):
819 skip = True 819 skip = True
820 if skip: 820 if skip:
821 continue 821 continue
822 val = val + v 822 val.append(v)
823 parser.value = val 823 parser.value = "".join(val)
824 if expand: 824 if expand:
825 value = parser.value 825 value = parser.value
826 826