diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-10-03 12:19:41 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-10-03 12:19:41 +0200 |
commit | 38c73e5f98a73b031330d7b0a5bc831e8d066d71 (patch) | |
tree | daf3802aea50b1c4aa1ad440a4e7c4f9845104bd | |
parent | 0c855ec9883c8f49cca892bed80358647c7cd9c0 (diff) |
Only check types when necessary
3 files changed, 5 insertions, 5 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. * diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/OperationNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/OperationNode.java index 0512e1dad2f..1c66686a9fe 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/OperationNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/OperationNode.java @@ -80,7 +80,7 @@ public final class OperationNode extends CompositeNode { @Override public TensorType type(TypeContext<Reference> context) { - // Compute type using tensor types as arithmetic operators are supported on tensors + // Compute type using tensor types as operation operators are supported on tensors // and is correct also in the special case of doubles. // As all our functions are type-commutative, we don't need to take operator precedence into account TensorType type = children.get(0).type(context); |