mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-18 10:55:22 +00:00
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: {
|
case PRIMITIVE_DATATYPE: {
|
||||||
final IPrimitiveType<?> value = (IPrimitiveType<?>) theNextValue;
|
final IPrimitiveType<?> value = (IPrimitiveType<?>) theNextValue;
|
||||||
if (isBlank(value.getValueAsString())) {
|
final String valueStr = value.getValueAsString();
|
||||||
|
if (isBlank(valueStr)) {
|
||||||
if (theForceEmpty) {
|
if (theForceEmpty) {
|
||||||
theEventWriter.writeNull();
|
theEventWriter.writeNull();
|
||||||
}
|
}
|
||||||
break;
|
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 (value instanceof IBaseIntegerDatatype) {
|
||||||
if (theChildName != null) {
|
if (theChildName != null) {
|
||||||
write(theEventWriter, theChildName, ((IBaseIntegerDatatype) value).getValue());
|
write(theEventWriter, theChildName, ((IBaseIntegerDatatype) value).getValue());
|
||||||
@ -262,7 +273,6 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String valueStr = value.getValueAsString();
|
|
||||||
if (theChildName != null) {
|
if (theChildName != null) {
|
||||||
write(theEventWriter, theChildName, valueStr);
|
write(theEventWriter, theChildName, valueStr);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user