scalajson icon indicating copy to clipboard operation
scalajson copied to clipboard

Add in JNumber number conversions

Open mdedetrich opened this issue 8 years ago • 5 comments

In response to https://github.com/mdedetrich/scalajson/issues/17#issuecomment-312140277, we should add JNumber converters to various number formats (since its likely most users will get this wrong)

mdedetrich avatar Jul 11 '17 20:07 mdedetrich

+1

axel22 avatar Jul 19 '17 12:07 axel22

@axel22 What are your opinions of this PR https://github.com/mdedetrich/scalajson/pull/38?

mdedetrich avatar Jul 19 '17 16:07 mdedetrich

I like it, would be good to have that! About the ScalaMeter tests, it's possible that you would get a better accuracy by adding a loop inside the benchmarked snippet (to increase the number of iterations).

About the @inline annotations on constants, if you use defs everywhere, it's almost certain that the JIT compiler will inline all invocations to them.

axel22 avatar Jul 19 '17 18:07 axel22

I like it, would be good to have that! About the ScalaMeter tests, it's possible that you would get a better accuracy by adding a loop inside the benchmarked snippet (to increase the number of iterations).

Thanks, I will add more benchmarks + add this inner loop

About the @inline annotations on constants, if you use defs everywhere, it's almost certain that the JIT compiler will inline all invocations to them.

Try, I use @inline for 2 reasons

  • This is a cross platform library (so it will target scala-native and it currently targets Scala.js). So I wan't really make sure that it inlines (although I am fairly sure that these projects should inline such code)
  • It shows the intent of what is meant to happen, i.e. they really are constants

mdedetrich avatar Jul 20 '17 09:07 mdedetrich

Makes sense!

axel22 avatar Jul 20 '17 10:07 axel22