From 4c567e54c31548cbb556f61c95798fedcb2cf4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 12 Aug 2015 19:11:04 -0700 Subject: [PATCH] Synchronize cache access, to be on the safe side. --- src/main/scala/li/cil/oc/util/RotationHelper.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/li/cil/oc/util/RotationHelper.scala b/src/main/scala/li/cil/oc/util/RotationHelper.scala index d55528182..0561b6867 100644 --- a/src/main/scala/li/cil/oc/util/RotationHelper.scala +++ b/src/main/scala/li/cil/oc/util/RotationHelper.scala @@ -21,12 +21,12 @@ object RotationHelper { inverseTranslationFor(pitch, yaw)(value.ordinal) def translationFor(pitch: ForgeDirection, yaw: ForgeDirection) = - translationCache. + translationCache.synchronized(translationCache. getOrElseUpdate(pitch, mutable.Map.empty). - getOrElseUpdate(yaw, translations(pitch.ordinal)(yaw.ordinal - 2)) + getOrElseUpdate(yaw, translations(pitch.ordinal)(yaw.ordinal - 2))) def inverseTranslationFor(pitch: ForgeDirection, yaw: ForgeDirection) = - inverseTranslationCache. + inverseTranslationCache.synchronized(inverseTranslationCache. getOrElseUpdate(pitch, mutable.Map.empty). getOrElseUpdate(yaw, { val t = translationFor(pitch, yaw) @@ -35,7 +35,7 @@ object RotationHelper { map(t.indexOf). map(ForgeDirection.getOrientation). toArray - }) + })) // ----------------------------------------------------------------------- //