Scala performance fix: Use Double instead of Float to avoid autoboxing #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Your code gets twice as fast when you use Double instead of Float. I just replaced all occurrences via search+replace. In my case:
Rendering took: 2517.6652006ms (average over 5 repetitions)
Rendering took: 1254.6068284ms (average over 5 repetitions)
Among other things, autoboxing occurs when using tuples with Float. Only Doubles are spezialized: https://github.com/scala/scala/blob/v2.13.1/src/library/scala/Tuple2.scala#L24
Besides, your precision rises from 32 bit (Float) to 64 bit (Double), which results in a nicer output image.