From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 4/8] trace-cruncher: Code cleanup in the constructor of tc_synth
Date: Thu, 10 Feb 2022 17:23:35 +0200 [thread overview]
Message-ID: <20220210152339.363943-5-y.karadz@gmail.com> (raw)
In-Reply-To: <20220210152339.363943-1-y.karadz@gmail.com>
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 --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)
--
2.32.0
next prev parent reply other threads:[~2022-02-10 15:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 15:23 [PATCH 0/8] trace-cruncher:Fixes before v0.2 (Beta) Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 1/8] trace-cruncher: Prefix all python class names with 'tc_' Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 2/8] trace-cruncher: Fix bug in the constructor if tc_synth class Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 3/8] trace-cruncher: Add tests for synth helper APIs Yordan Karadzhov (VMware)
2022-02-10 15:23 ` Yordan Karadzhov (VMware) [this message]
2022-02-10 15:23 ` [PATCH 5/8] trace-cruncher: Rename python function argument in PyFtrace_eprobe Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 6/8] trace-cruncher: Add tc_eprobe class to ft_utiles Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 7/8] trace-cruncher: Check kernel support in the eprobe constructor Yordan Karadzhov (VMware)
2022-02-10 15:23 ` [PATCH 8/8] trace-cruncher: Add more comments to the examples Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220210152339.363943-5-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).