bool TreePatternNode::isIsomorphicTo(const TreePatternNode *N,
const MultipleUseVarSet &DepVars) const {
if (N == this) return true;
- if (N->isLeaf() != isLeaf() || getExtTypes() != N->getExtTypes() ||
+ if (N->isLeaf() != isLeaf())
+ return false;
+
+ // Check operator of non-leaves early since it can be cheaper than checking
+ // types.
+ if (!isLeaf())
+ if (N->getOperator() != getOperator() ||
+ N->getNumChildren() != getNumChildren())
+ return false;
+
+ if (getExtTypes() != N->getExtTypes() ||
getPredicateCalls() != N->getPredicateCalls() ||
getTransformFn() != N->getTransformFn())
return false;
return getLeafValue() == N->getLeafValue();
}
- if (N->getOperator() != getOperator() ||
- N->getNumChildren() != getNumChildren()) return false;
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
if (!getChild(i)->isIsomorphicTo(N->getChild(i), DepVars))
return false;