Skip to contentSkip to conversation

/tools/../Core.py: move tasks states outside the method

PATCH New Alexander Pantyukhin 1 participant 1 message Jan 16, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /tools/../Core.py: move tasks states outside the method

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

---
 .../Perf-Trace-Util/lib/Perf/Trace/Core.py    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py +8 -11
index 54ace2f6bc36..ecb5087e5583 100644
@@ -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:
Signature · 1 line
2.25.1