Messages in this thread Patch in this message | | | From | Alexander Pantyukhin <> | Subject | [PATCH] /tools/../Core.py: move tasks states outside the method | Date | Mon, 16 Jan 2023 18:39:02 +0500 |
| |
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
| |