From: Andreas Sandberg Date: Tue, 5 Jun 2018 16:15:58 +0000 (+0100) Subject: sim: Use the canonical way of iterating over a dictionary X-Git-Tag: v19.0.0.0~2033 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7ad7ea26b5b11d4fa392282c2e6159d0089d0342;p=gem5.git sim: Use the canonical way of iterating over a dictionary Instead of using a convoluted getattr call, use the conventional iteritems() interface. Change-Id: I6d6bbccf865f8a0e8ff0767914157a7460099b09 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/10782 Reviewed-by: Jason Lowe-Power --- diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 0c9e738f6..47e647467 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -1520,11 +1520,10 @@ class SimObject(object): yield # make this function a (null) generator def recurseDeviceTree(self, state): - for child in [getattr(self, c) for c in self._children]: + for child in self._children.itervalues(): for item in child: # For looping over SimObjectVectors - if isinstance(item, SimObject): - for dt in item.generateDeviceTree(state): - yield dt + for dt in item.generateDeviceTree(state): + yield dt # Function to provide to C++ so it can look up instances based on paths def resolveSimObject(name):