summaryrefslogtreecommitdiff
path: root/src/main/scala/spray
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/spray')
-rw-r--r--src/main/scala/spray/json/JsonParser.scala10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/scala/spray/json/JsonParser.scala b/src/main/scala/spray/json/JsonParser.scala
index 8e7a83e..ea48842 100644
--- a/src/main/scala/spray/json/JsonParser.scala
+++ b/src/main/scala/spray/json/JsonParser.scala
@@ -132,11 +132,13 @@ class JsonParser(input: ParserInput) {
}
private def `char`() =
- cursorChar match {
- case '"' => false
+ // simple bloom-filter that quick-matches the most frequent case of characters that are ok to append
+ // (it doesn't match control chars, EOI, '"', '?', '\', 'b' and certain higher, non-ASCII chars)
+ if (((1L << cursorChar) & ((31 - cursorChar) >> 31) & 0x7ffffffbefffffffL) != 0L) appendSB(cursorChar)
+ else cursorChar match {
+ case '"' | EOI => false
case '\\' => advance(); `escaped`()
- case c if cursorChar >= ' ' => appendSB(cursorChar)
- case _ => false
+ case c => (c >= ' ') && appendSB(c)
}
private def `escaped`() = {