Closed tomka closed 9 years ago
I removed the this.
prefix and rebased on current master. Regarding the performance issues: Before adding the pull request, I compared timings of the Math.min
/Math.max
version with the existing if/then/else
version (factored into the clamp
method) and could not find any performance differences.
@dscho, even though there are no performance differences between the clamping implementation you suggested and I came up with (on my machine), I changed the commit to include your version. It doesn't hurt and might be safer if there are maybe Java versions out there that can't inline Math.min
and Math.max
. Thanks for the suggestion.
Thanks.
As stated in 0bee4e20 the introduced range checks could be improved. This change makes the code more readable and more DRY by factoring the clamping into its own function. Two more places were simplified additionally.