From be7ac177c57452ad3268a5d50ba4f7eb15e96279 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 25 Sep 2017 15:24:00 -0700 Subject: [PATCH] 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 --- src/python/m5/params.py | 3 +-- 1 file changed, 1 insertion(+), 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): -- 2.30.2