Skip to content

Commit 76e64b0

Browse files
committed
Refactor: simplify cutoff calculation in metrics using ternary operator
1 parent a154d7f commit 76e64b0

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/cachier/metrics.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,7 @@ def _calculate_avg_latency(self, window: Optional[timedelta] = None) -> float:
252252
"""
253253
# Use monotonic clock for cutoff calculation
254254
now = time.perf_counter()
255-
if window is None:
256-
cutoff = 0
257-
else:
258-
cutoff = now - window.total_seconds()
255+
cutoff = 0.0 if window is None else now - window.total_seconds()
259256

260257
latencies = [metric.value for metric in self._latencies if metric.timestamp >= cutoff]
261258

0 commit comments

Comments
 (0)