lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230116133902.4143-1-apantykhin@gmail.com>
Date:   Mon, 16 Jan 2023 18:39:02 +0500
From:   Alexander Pantyukhin <apantykhin@...il.com>
To:     akpm@...ux-foundation.org
Cc:     peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        namhyung@...nel.org, linux-perf-users@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Alexander Pantyukhin <apantykhin@...il.com>
Subject: [PATCH] /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.

Signed-off-by: Alexander Pantyukhin <apantykhin@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ