Skip to contentSkip to conversation

rteval: Use get instead of setdefault for calculating range

PATCH New John Kacur 1 participant 1 message May 2, 2024

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 rteval: Use get instead of setdefault for calculating range

As Crystal Wood <[email protected]> points out, there is no need to setdefault when calculating the range, just use get if there is no value.

---
 rteval/modules/measurement/cyclictest.py | 2 +-
 rteval/modules/measurement/timerlat.py   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
rteval/modules/measurement/cyclictest.py +1 -1
index 925065367eaf..3301e1b45e11 100644
@@ -115,7 +115,7 @@ class RunData:
                 low = i
                 break
         high = keys[-1]
-        while high and self.__samples.setdefault(high, 0) == 0:
+        while high and self.__samples.get(high, 0) == 0:
             high -= 1
         self.__range = high - low
 
rteval/modules/measurement/timerlat.py +1 -1
index 9fa931043e40..e8345fab1ad7 100644
@@ -106,7 +106,7 @@ class TLRunData:
                 low = i
                 break
         high = keys[-1]
-        while high and self.__samples.setdefault(high, 0) == 0:
+        while high and self.__samples.get(high, 0) == 0:
             high -= 1
         self.__range = high - low
 
Signature · 1 line
2.44.0