-
-
Notifications
You must be signed in to change notification settings - Fork 820
Closed
Labels
2.18Issues planned at earliest for 2.18Issues planned at earliest for 2.18
Description
I've got a high performance streaming use case where I'm handling some of the lower-level details. For example, translating a VALUE_STRING into a double. I'm relying on NumberInput with the appropriate useFastParser config, and would like to avoid extraneous String allocation when possible. The BigDecimal case is currently the most complete, as it works with JsonParser#hasTextCharacters:
static BigDecimal parseStringAsBigDecimal(JsonParser parser) throws IOException {
final boolean useFastParser = parser.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER);
return parser.hasTextCharacters()
? NumberInput.parseBigDecimal(parser.getTextCharacters(), parser.getTextOffset(), parser.getTextLength(), useFastParser)
: NumberInput.parseBigDecimal(parser.getText(), useFastParser);
}The other similar cases aren't able to take advantage since the underlying char[] parsing methods aren't exposed:
static float parseStringAsFloat(JsonParser parser) throws IOException {
// TODO: improve when parser.hasTextCharacters()
return NumberInput.parseFloat(parser.getText(), parser.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER));
}
static double parseStringAsDouble(JsonParser parser) throws IOException {
// TODO: improve when parser.hasTextCharacters()
return NumberInput.parseDouble(parser.getText(), parser.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER));
}
static BigInteger parseStringAsBigInteger(JsonParser parser) throws IOException {
// TODO: improve when parser.hasTextCharacters()
return NumberInput.parseBigInteger(parser.getText(), parser.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
}It would be great to add char[] versions NumberInput#parseFloat, NumberInput#parseDouble, and NumberInput#parseBigInteger.
Metadata
Metadata
Assignees
Labels
2.18Issues planned at earliest for 2.18Issues planned at earliest for 2.18