3 ms·
This reminded me of spray-json's JsonParser. It has a bit of Scala code to seek past whitespace: @tailrec private def ws(): Unit = // fast test whether c
by brianpgordon 10y ago
This reminded me of spray-json's JsonParser. It has a bit of Scala code to seek past whitespace:
@tailrec private def ws(): Unit =
// fast test whether cursorChar is one of " \n\r\t"
if (((1L << cursorChar) & ((cursorChar - 64) >> 31) & 0x100002600L) != 0L) { advance(); ws() }
https://github.com/spray/spray-json/blob/765c83248e0bbe867ddc9d479b4fe79493569a54/src/main/scala/spray/json/JsonParser.scala#L186 https://github.com/spray/spray-json/blob/765c83248e0bbe867dd...
- hota_mazi 10y agoThe compiler needs to be extremely clever on @tailrec for not blowing up the L1 cache on this code. To me, this looks like a perfect example of a developer thinking they're very smart while they're actually writing code that's worse that its naive counterpart version (a good summary of Scala in my experience).
- jnordwick 10y agoCan you please explain why it would blow up the L1 cache?