linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Pantyukhin <apantykhin@gmail.com>
To: akpm@linux-foundation.org
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Alexander Pantyukhin <apantykhin@gmail.com>
Subject: [PATCH] /tools/../Core.py: move tasks states outside the method
Date: Mon, 16 Jan 2023 18:39:02 +0500	[thread overview]
Message-ID: <20230116133902.4143-1-apantykhin@gmail.com> (raw)

The states variable is invariant for the taskState method. It could be
brought out of the taskState.

Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
---
 .../Perf-Trace-Util/lib/Perf/Trace/Core.py    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
index 54ace2f6bc36..ecb5087e5583 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
+++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
@@ -85,18 +85,15 @@ def trace_flag_str(value):
     return string
 
 
-def taskState(state):
-	states = {
-		0 : "R",
-		1 : "S",
-		2 : "D",
-		64: "DEAD"
-	}
-
-	if state not in states:
-		return "Unknown"
+tasks_states = {
+    0 : "R",
+    1 : "S",
+    2 : "D",
+    64: "DEAD"
+}
 
-	return states[state]
+def taskState(state):
+    return tasks_states.get(state, "Unknown")
 
 
 class EventHeaders:
-- 
2.25.1


                 reply	other threads:[~2023-01-16 13:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230116133902.4143-1-apantykhin@gmail.com \
    --to=apantykhin@gmail.com \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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).