Optimise for encoding String primitive data types

We typically have many more string primitives than anything else
This commit is contained in:
David Maplesden 2019-09-17 09:48:34 +12:00 committed by James Agnew
parent 8b84b8ffea
commit 1f253856cf
1 changed files with 12 additions and 2 deletions

View File

@ -224,13 +224,24 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
}
case PRIMITIVE_DATATYPE: {
final IPrimitiveType<?> value = (IPrimitiveType<?>) theNextValue;
if (isBlank(value.getValueAsString())) {
final String valueStr = value.getValueAsString();
if (isBlank(valueStr)) {
if (theForceEmpty) {
theEventWriter.writeNull();
}
break;
}
// check for the common case first - String value types
if (value.getValue() instanceof String) {
if (theChildName != null) {
theEventWriter.write(theChildName, valueStr);
} else {
theEventWriter.write(valueStr);
}
break;
}
if (value instanceof IBaseIntegerDatatype) {
if (theChildName != null) {
write(theEventWriter, theChildName, ((IBaseIntegerDatatype) value).getValue());
@ -262,7 +273,6 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
}
}
} else {
String valueStr = value.getValueAsString();
if (theChildName != null) {
write(theEventWriter, theChildName, valueStr);
} else {