nfsantos opened a new pull request, #1599:
URL: https://github.com/apache/jackrabbit-oak/pull/1599
The current logic first tries to parse numbers as Long, catching a
NumberFormatException if that fails and then parsing them as double.
```
try {
type = PropertyType.LONG;
values.add(Long.parseLong(number));
} catch (NumberFormatException e) {
type = PropertyType.DOUBLE;
values.add(Double.parseDouble(number));
}
```
This is very expensive because the constructor of an exceptions captures a
stack trace.
This PR changes the parsing logic to not throw an exception when the number
is not a long. In a benchmark that iterates over 10 million json strings
representing the contents of a typical Oak repository, the implementation in
this PR is almost 30% faster:
- current logic: 70s (raising 127K exceptions per second, as measured in a
JFR recording)
- This PR, without exception in the common case: 50s (no significant number
of exceptions raised)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]