From: Luke Kenneth Casson Leighton Date: Sat, 10 Jun 2023 22:50:03 +0000 (+0100) Subject: reduce number of lines slightly by using yield from filter(match, ...) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67a3df94a66a35aff711b9db824487d4bc318586;p=openpower-isa.git reduce number of lines slightly by using yield from filter(match, ...) --- diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 21f5cc48..d19f92a5 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -108,9 +108,8 @@ class Tuple(Node, tuple): if isinstance(clsself, type): yield ("[]", clsself.__datatype) else: - for (index, item) in enumerate(clsself): - if match(item): - yield (str(index), item) + for (index, item) in enumerate(filter(match, clsself)): + yield (str(index), item) class Dict(Node, dict): @@ -144,9 +143,7 @@ class Dict(Node, dict): if isinstance(clsself, type): yield ("{}", clsself.__datatype) else: - for (key, value) in clsself.items(): - if match(value): - yield (key, value) + yield from filter(lambda kv: match(kv[0]), clsself.items()) class VisitorMethod: