From 08539a025adedac1ce4bac03d635537bb90edcb2 Mon Sep 17 00:00:00 2001 From: Fingercomp Date: Fri, 7 Jul 2023 00:20:12 +0700 Subject: [PATCH] Fix a memory leak `drop` does not remove an element in-place. To learn what it does, I'll refer you to the scala collection docs. --- src/main/scala/ocelot/desktop/windows/ComputerWindow.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/ocelot/desktop/windows/ComputerWindow.scala b/src/main/scala/ocelot/desktop/windows/ComputerWindow.scala index 9509e22..2841c0d 100644 --- a/src/main/scala/ocelot/desktop/windows/ComputerWindow.scala +++ b/src/main/scala/ocelot/desktop/windows/ComputerWindow.scala @@ -51,10 +51,11 @@ class ComputerWindow(computerAware: ComputerAware) extends BasicWindow { private var lastTick = OcelotDesktop.ticker.tick def appendHistoryValue(value: Float): Unit = { - history.append(value) + if (history.length > historySize) { + history.remove(0) + } - if (history.length > historySize) - history.drop(0) + history.append(value) } def tickUpdate(): Unit = {}