]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
data_smart: use a split/filter/rejoin for _remove
authorChristopher Larson <chris_larson@mentor.com>
Tue, 27 Aug 2013 23:27:40 +0000 (16:27 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 27 Aug 2013 23:33:50 +0000 (00:33 +0100)
This is more idiomatic, and from the limited performance testing I did, is
faster as well. See https://gist.github.com/kergoth/6360248 for the naive
benchmark.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/data_smart.py

index 3fb88a93dfc9cb4a31969aec4ed9956457cadb0a..6229fbf69363810b4be80b8faf4e482bd2b528d2 100644 (file)
@@ -589,13 +589,9 @@ class DataSmart(MutableMapping):
         if expand and value:
             value = self.expand(value, None)
         if value and flag == "_content" and local_var and "_removeactive" in local_var:
-            for i in local_var["_removeactive"]:
-                if " " + i + " " in value:
-                    value = value.replace(" " + i + " ", " ")
-                if value.startswith(i + " "):
-                    value = value[len(i + " "):]
-                if value.endswith(" " + i):
-                    value = value[:-len(" " + i)]
+            filtered = filter(lambda v: v not in local_var["_removeactive"],
+                              value.split(" "))
+            value = " ".join(filtered)
         return value
 
     def delVarFlag(self, var, flag, **loginfo):