diff mbox series

[4/8] trace-cruncher: Code cleanup in the constructor of tc_synth

Message ID 20220210152339.363943-5-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series trace-cruncher:Fixes before v0.2 (Beta) | expand

Commit Message

Yordan Karadzhov Feb. 10, 2022, 3:23 p.m. UTC
No functional changes are introduced. Just simplifying the code and
making it have more pythonic style.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 tracecruncher/ft_utils.py | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/tracecruncher/ft_utils.py b/tracecruncher/ft_utils.py
index 6db426e..67e020f 100644
--- a/tracecruncher/ft_utils.py
+++ b/tracecruncher/ft_utils.py
@@ -331,24 +331,16 @@  class tc_synth(tc_event):
                               end_match=end_event['match'],
                               match_name=match_name)
 
-        start_fields = end_fields = []
-
-        if 'fields' in start_event:
-            start_fields = start_event['fields']
-
-        start_field_names = [None] * len(start_fields)
-        if 'field_names' in start_event:
-            start_field_names = start_event['field_names']
+        start_fields = ([], start_event['fields'])['fields' in start_event]
+        start_field_names = ([None] * len(start_fields),
+                             start_event['field_names'])['field_names' in start_event]
 
         self.synth.add_start_fields(fields=start_fields,
                                     names=start_field_names)
 
-        if 'fields' in end_event:
-            end_fields = end_event['fields']
-
-        end_field_names = [None] * len(end_fields)
-        if 'field_names' in end_event:
-            end_field_names = end_event['field_names']
+        end_fields = ([], end_event['fields'])['fields' in end_event]
+        end_field_names = ([None] * len(end_fields),
+                           end_event['field_names'])['field_names' in end_event]
 
         self.synth.add_end_fields(fields=end_fields,
                                   names=end_field_names)