summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-10-03 12:19:41 +0200
committerJon Bratseth <bratseth@gmail.com>2022-10-03 12:19:41 +0200
commit38c73e5f98a73b031330d7b0a5bc831e8d066d71 (patch)
treedaf3802aea50b1c4aa1ad440a4e7c4f9845104bd /config-model
parent0c855ec9883c8f49cca892bed80358647c7cd9c0 (diff)
Only check types when necessary
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java6
-rw-r--r--config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java2
2 files changed, 4 insertions, 4 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
index 49fb48225e7..3d5d29fb3c7 100644
--- a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
+++ b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
@@ -65,11 +65,11 @@ public class BooleanExpressionTransformer extends ExpressionTransformer<Transfor
ChildNode rhs = stack.pop();
ChildNode lhs = stack.peek();
- boolean primitives = isDefinitelyPrimitive(lhs.child, context) && isDefinitelyPrimitive(rhs.child, context);
+ // isDefinitelyPrimitive is expensive so only invoke it when necessary
ExpressionNode combination;
- if (primitives && rhs.op == Operator.and)
+ if (rhs.op == Operator.and && isDefinitelyPrimitive(lhs.child, context) && isDefinitelyPrimitive(rhs.child, context))
combination = andByIfNode(lhs.child, rhs.child);
- else if (primitives && rhs.op == Operator.or)
+ else if (rhs.op == Operator.or && isDefinitelyPrimitive(lhs.child, context) && isDefinitelyPrimitive(rhs.child, context))
combination = orByIfNode(lhs.child, rhs.child);
else {
combination = resolve(lhs, rhs);
diff --git a/config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java b/config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java
index d985089b2cb..d1404d86a91 100644
--- a/config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java
+++ b/config-model/src/main/java/com/yahoo/schema/processing/RankingExpressionTypeResolver.java
@@ -22,7 +22,7 @@ import java.util.logging.Level;
/**
* Resolves and assigns types to all functions in a ranking expression, and
- * validates the types of all ranking expressions under a search instance:
+ * validates the types of all ranking expressions under a schema instance:
* Some operators constrain the types of inputs, and first-and second-phase expressions
* must return scalar values.
*