From 45377a81c0af1379a71ec343391dea38d70abf21 Mon Sep 17 00:00:00 2001 From: boubou19 Date: Mon, 3 Aug 2026 17:03:37 +0200 Subject: [PATCH] make sure tu use the same size --- src/main/scala/mrtjp/relocation/movement.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/scala/mrtjp/relocation/movement.scala b/src/main/scala/mrtjp/relocation/movement.scala index f30ad69..a72a458 100644 --- a/src/main/scala/mrtjp/relocation/movement.scala +++ b/src/main/scala/mrtjp/relocation/movement.scala @@ -248,14 +248,15 @@ class WorldStructsMap { } def foreach(f: (Int, WorldStructs) => Unit) { - val ds = new Array[Int](size) - val ss = new Array[WorldStructs](size) + val n = synchronized { size } + val ds = new Array[Int](n) + val ss = new Array[WorldStructs](n) synchronized { - System.arraycopy(dims, 0, ds, 0, size) - System.arraycopy(structs, 0, ss, 0, size) + System.arraycopy(dims, 0, ds, 0, n) + System.arraycopy(structs, 0, ss, 0, n) } var i = 0 - while (i < ds.length) { + while (i < n) { f(ds(i), ss(i)) i += 1 }