diff --git a/sjsonnet/src-js/sjsonnet/Platform.scala b/sjsonnet/src-js/sjsonnet/Platform.scala index f5cac641..280a7882 100644 --- a/sjsonnet/src-js/sjsonnet/Platform.scala +++ b/sjsonnet/src-js/sjsonnet/Platform.scala @@ -40,9 +40,7 @@ object Platform { throw new Exception("hashFile not implemented in Scala.js") } - private val regexCache = new util.LinkedHashMap[String, Pattern](100, 0.75f, true) { - override def removeEldestEntry(eldest: util.Map.Entry[String, Pattern]): Boolean = size() > 100 - } + private val regexCache = new util.concurrent.ConcurrentHashMap[String, Pattern] def getPatternFromCache(pat: String) : Pattern = regexCache.computeIfAbsent(pat, _ => Pattern.compile(pat)) def regexQuote(s: String): String = Pattern.quote(s) diff --git a/sjsonnet/src-jvm/sjsonnet/Platform.scala b/sjsonnet/src-jvm/sjsonnet/Platform.scala index da9e4cba..9d7d6d27 100644 --- a/sjsonnet/src-jvm/sjsonnet/Platform.scala +++ b/sjsonnet/src-jvm/sjsonnet/Platform.scala @@ -111,9 +111,7 @@ object Platform { hash.getValue.toString } - private val regexCache = new util.LinkedHashMap[String, Pattern](100, 0.75f, true) { - override def removeEldestEntry(eldest: util.Map.Entry[String, Pattern]): Boolean = size() > 100 - } + private val regexCache = new util.concurrent.ConcurrentHashMap[String, Pattern] def getPatternFromCache(pat: String) : Pattern = regexCache.computeIfAbsent(pat, _ => Pattern.compile(pat)) def regexQuote(s: String): String = Pattern.quote(s) diff --git a/sjsonnet/src-native/sjsonnet/Platform.scala b/sjsonnet/src-native/sjsonnet/Platform.scala index 7baaea2f..6bcfed33 100644 --- a/sjsonnet/src-native/sjsonnet/Platform.scala +++ b/sjsonnet/src-native/sjsonnet/Platform.scala @@ -53,9 +53,7 @@ object Platform { scala.io.Source.fromFile(file).mkString } - private val regexCache = new util.LinkedHashMap[String, Pattern](100, 0.75f, true) { - override def removeEldestEntry(eldest: util.Map.Entry[String, Pattern]): Boolean = size() > 100 - } + private val regexCache = new util.concurrent.ConcurrentHashMap[String, Pattern] def getPatternFromCache(pat: String) : Pattern = regexCache.computeIfAbsent(pat, _ => Pattern.compile(pat)) def regexQuote(s: String): String = Pattern.quote(s)