linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] /tools/../Core.py: move tasks states outside the method
@ 2023-01-16 13:39 Alexander Pantyukhin
  0 siblings, 0 replies; only message in thread
From: Alexander Pantyukhin @ 2023-01-16 13:39 UTC (permalink / raw)
  To: akpm
  Cc: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	linux-perf-users, linux-kernel, Alexander Pantyukhin

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-16 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 13:39 [PATCH] /tools/../Core.py: move tasks states outside the method Alexander Pantyukhin

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).