summaryrefslogtreecommitdiff
path: root/src/python/m5
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-09-25 15:24:00 -0700
committerGabe Black <gabeblack@google.com>2017-09-26 21:16:54 +0000
commitbe7ac177c57452ad3268a5d50ba4f7eb15e96279 (patch)
treeaf269f3577b77fc7c5757c28567729272271cb0f /src/python/m5
parent0c5c74c373058c2b1046ead06a40b9bd837c6969 (diff)
downloadgem5-be7ac177c57452ad3268a5d50ba4f7eb15e96279.tar.xz
sim: Check the SimObjectVector.has_parent function to use the "any" function.
The existing code was essentially doing the same thing, but in a more roundabout and obscure way. One difference between the two versions is that I believe this will stop as soon as it encounters an element without a parent, where the original version would call has_parent() on all the elements regardless. Change-Id: Ia1fef3083fc88fca11f8ecfca453476e33194695 Reviewed-on: https://gem5-review.googlesource.com/4842 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/python/m5')
-rw-r--r--src/python/m5/params.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index e5f47e694..7a28e63c7 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -270,8 +270,7 @@ class SimObjectVector(VectorParamValue):
v.set_parent(parent, "%s%0*d" % (name, width, i))
def has_parent(self):
- elements = [e for e in self if not isNullPointer(e)]
- return reduce(lambda x,y: x and y, [v.has_parent() for v in elements])
+ return any([e.has_parent() for e in self if not isNullPointer(e)])
# return 'cpu0 cpu1' etc. for print_ini()
def get_name(self):