bt2: _EventConst.__getitem__(): use a single temporary variable
[babeltrace.git] / src / bindings / python / bt2 / bt2 / event.py
index 08d6ae0949b108ccb9be366740ebb98fa4d6cb94..e18f12cf5f965d24f78184cfc96dc30a3091c5d5 100644 (file)
@@ -108,25 +108,26 @@ class _EventConst(object._UniqueObject):
 
     def __getitem__(self, key):
         utils._check_str(key)
-        payload_field = self.payload_field
+        root_field = self.payload_field
 
-        if payload_field is not None and key in payload_field:
-            return payload_field[key]
+        if root_field is not None and key in root_field:
+            return root_field[key]
 
-        specific_context_field = self.specific_context_field
+        root_field = self.specific_context_field
 
-        if specific_context_field is not None and key in specific_context_field:
-            return specific_context_field[key]
+        if root_field is not None and key in root_field:
+            return root_field[key]
 
-        common_context_field = self.common_context_field
+        root_field = self.common_context_field
 
-        if common_context_field is not None and key in common_context_field:
-            return common_context_field[key]
+        if root_field is not None and key in root_field:
+            return root_field[key]
 
-        packet_context_field = self.packet.context_field
+        if self.packet:
+            root_field = self.packet.context_field
 
-        if packet_context_field is not None and key in packet_context_field:
-            return packet_context_field[key]
+            if root_field is not None and key in root_field:
+                return root_field[key]
 
         raise KeyError(key)
 
This page took 0.024597 seconds and 4 git commands to generate.