Skip to content

Commit

Permalink
Minor performance improvement.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand committed Feb 14, 2023
1 parent d47c624 commit b968514
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ public ExprType getExprType() {
* @return An instance or inheritor of `OpenSearchDataType`.
*/
public static OpenSearchDataType of(MappingType mappingType) {
if (instances.containsKey(mappingType.toString())) {
return instances.get(mappingType.toString());
var res = instances.getOrDefault(mappingType.toString(), null);
if (res != null) {
return res;
}
ExprCoreType exprCoreType = mappingType.getExprCoreType();
if (exprCoreType == ExprCoreType.UNKNOWN) {
Expand All @@ -109,7 +110,7 @@ public static OpenSearchDataType of(MappingType mappingType) {
throw new IllegalArgumentException(mappingType.toString());
}
}
var res = new OpenSearchDataType(mappingType);
res = new OpenSearchDataType(mappingType);
res.exprCoreType = exprCoreType;
instances.put(mappingType.toString(), res);
return res;
Expand Down Expand Up @@ -149,10 +150,11 @@ public static OpenSearchDataType of(ExprType type) {
if (type instanceof OpenSearchDataType) {
return (OpenSearchDataType) type;
}
if (instances.containsKey(type.toString())) {
return instances.get(type.toString());
var res = instances.getOrDefault(type.toString(), null);
if (res != null) {
return res;
}
var res = new OpenSearchDataType((ExprCoreType) type);
res = new OpenSearchDataType((ExprCoreType) type);
instances.put(type.toString(), res);
return res;
}
Expand Down

0 comments on commit b968514

Please sign in to comment.