Skip to content
Browse files

Do not escape unnecessarily ranges which JSON spec does not require. …

…Fix memoization
  • Loading branch information...
1 parent d983cae commit 67cd3cfea98af1be01047abbdc81c936fe1d76c2 Joni Freeman committed with nafg Oct 10, 2012
View
2 core/json/src/main/scala/net/liftweb/json/JsonAST.scala
@@ -427,7 +427,7 @@ object JsonAST {
case '\n' => "\\n"
case '\r' => "\\r"
case '\t' => "\\t"
- case c if ((c >= '\u0000' && c < '\u0020') || (c >= '\u0080' && c < '\u00a0') || (c >= '\u2000' && c < '\u2100')) => "\\u%04x".format(c: Int)
+ case c if ((c >= '\u0000' && c < '\u0020')) => "\\u%04x".format(c: Int)
case c => c
})
}
View
10 core/json/src/main/scala/net/liftweb/json/Meta.scala
@@ -191,14 +191,16 @@ private[json] object Meta {
private[json] def fail(msg: String, cause: Exception = null) = throw new MappingException(msg, cause)
private class Memo[A, R] {
- @volatile private var cache = Map[A, R]()
+ private val cache = new java.util.concurrent.atomic.AtomicReference(Map[A, R]())
- def memoize(x: A, f: A => R): R =
- if (cache contains x) cache(x) else {
+ def memoize(x: A, f: A => R): R = {
+ val c = cache.get
+ if (c contains x) c(x) else {
val ret = f(x)
- cache += (x -> ret)
+ cache.set(c + (x -> ret))
ret
}
+ }
}
object Reflection {

0 comments on commit 67cd3cf

Please sign in to comment.
Something went wrong with that request. Please try again.