Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 1/2] data_smart: use a split/filter/rejoin for _remove
@ 2013-08-27 23:27 Christopher Larson
  2013-08-27 23:27 ` [PATCH 2/2] data_smart: allow removal of multiple words at once with _remove Christopher Larson
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Larson @ 2013-08-27 23:27 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

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>
---
 lib/bb/data_smart.py | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 3fb88a9..6229fbf 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -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):
-- 
1.8.3.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-27 23:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 23:27 [PATCH 1/2] data_smart: use a split/filter/rejoin for _remove Christopher Larson
2013-08-27 23:27 ` [PATCH 2/2] data_smart: allow removal of multiple words at once with _remove Christopher Larson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox