From: Gabe Black Date: Mon, 25 Sep 2017 22:24:00 +0000 (-0700) Subject: sim: Check the SimObjectVector.has_parent function to use the "any" function. X-Git-Tag: v19.0.0.0~2625 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be7ac177c57452ad3268a5d50ba4f7eb15e96279;p=gem5.git 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 Maintainer: Gabe Black --- 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):