Skip to content

Commit 4e67132

Browse files
committed
kms/timing: Faster cleanup
1 parent 8aaaa12 commit 4e67132

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/kms/surface/timings.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Frame {
5151
}
5252

5353
impl Timings {
54-
const WINDOW_SIZE: usize = 360;
54+
const CLEANUP: usize = 360;
5555

5656
pub fn new(
5757
refresh_interval: Option<Duration>,
@@ -171,8 +171,9 @@ impl Timings {
171171
);
172172
}
173173
self.previous_frames.push_back(new_frame);
174-
while self.previous_frames.len() > Self::WINDOW_SIZE {
175-
self.previous_frames.pop_front();
174+
175+
if let Some(overflow) = self.previous_frames.len().checked_sub(Self::CLEANUP * 2) {
176+
self.previous_frames = self.previous_frames.split_off(overflow + Self::CLEANUP);
176177
}
177178
}
178179
}

0 commit comments

Comments
 (0)