From 51692a4967da8b9534089fbd9695e8eaa0a2fc36 Mon Sep 17 00:00:00 2001 From: NicolaiO Date: Sat, 1 Jun 2024 20:50:45 +0000 Subject: [PATCH] Improve ongoing pass calc See merge request main/Sumatra!1851 sumatra-commit: b0024ac73b72ff54acac61df698912d9ed90e55a --- .../edu/tigers/sumatra/data/TimeLimitedBuffer.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java b/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java index bb83d0cc..6290e4eb 100644 --- a/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java +++ b/modules/common/src/main/java/edu/tigers/sumatra/data/TimeLimitedBuffer.java @@ -73,7 +73,7 @@ private void reduceBySize() } while (data.size() > maxElements) { - data.remove(0); + data.removeFirst(); } } @@ -85,11 +85,11 @@ private void reduceByDuration() // no duration limit return; } - long maxTimestamp = data.get(data.size() - 1).timestamp; + long maxTimestamp = data.getLast().timestamp; long minTimestamp = maxTimestamp - (long) (maxDuration * 1e9); - while (!data.isEmpty() && data.get(0).timestamp < minTimestamp) + while (!data.isEmpty() && data.getFirst().timestamp < minTimestamp) { - data.remove(0); + data.removeFirst(); } } @@ -105,9 +105,9 @@ public void reduceByAbsoluteDuration(long currentTimestamp) // no duration limit return; } - while (!data.isEmpty() && data.get(0).timestamp < currentTimestamp - (long) (maxDuration * 1e9)) + while (!data.isEmpty() && data.getFirst().timestamp < currentTimestamp - (long) (maxDuration * 1e9)) { - data.remove(0); + data.removeFirst(); } }