Optimise for encoding String primitive data types
We typically have many more string primitives than anything else
This commit is contained in:
parent
8b84b8ffea
commit
1f253856cf
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue