You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Improved Long-Double Number Policy
The Parsing of a Double value was always executing a `Long.parseLong(value)`, which generated a `NumberFormatException`.
Identifying that a Number is a Double or a Long can be easily achieve (in a naive way) looking for the decimal separator.
This simple change avoids the extra `NumberFormatException`
A simple JUnit test, parsing a `Long` or a `Double` 10K times shows the next values:
* Double (old parsing): ~42 ms
* Double (new parsing): ~6 ms
* Long (old parsing): ~7 ms
* Long (new parsing): ~7 ms
As we can see, the parsing for `Long` values stays the same (±1ms), while the parsing for `Double` is dramatically improved.
Reducing the number of exceptions also has a positive side effect in memory consumption.
* Replace `contains(".")` by `indexOf('.') >= 0`
The usage of `indexOf(char)` is slightly faster
* Rename exception variables
0 commit comments