* [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* [PATCH 2/2] data_smart: allow removal of multiple words at once with _remove
2013-08-27 23:27 [PATCH 1/2] data_smart: use a split/filter/rejoin for _remove Christopher Larson
@ 2013-08-27 23:27 ` Christopher Larson
0 siblings, 0 replies; 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>
FOO = "foo bar baz"
FOO_remove = "foo baz"
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
lib/bb/data_smart.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 6229fbf..d325018 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -418,7 +418,7 @@ class DataSmart(MutableMapping):
self.setVar(append, sval)
elif op == "_remove":
removes = self.getVarFlag(append, "_removeactive", False) or []
- removes.append(a)
+ removes.extend(a.split())
self.setVarFlag(append, "_removeactive", removes, ignore=True)
# We save overrides that may be applied at some later stage
--
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