sim: Use the canonical way of iterating over a dictionary
authorAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 5 Jun 2018 16:15:58 +0000 (17:15 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Thu, 21 Jun 2018 14:21:44 +0000 (14:21 +0000)
Instead of using a convoluted getattr call, use the conventional
iteritems() interface.

Change-Id: I6d6bbccf865f8a0e8ff0767914157a7460099b09
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/10782
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/python/m5/SimObject.py

index 0c9e738f623268229872ccee582f031f5b797837..47e64746762ec344bbaa884e8e57093bc2509dd7 100644 (file)
@@ -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):