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>
This commit is contained in:
Gabe Black
2017-09-25 15:24:00 -07:00
parent 0c5c74c373
commit be7ac177c5

View File

@@ -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):