Commit 93279812 by Olli Etuaho Committed by Commit Bot

Remove unnecessary checks when traversing nodes

All children of binary and ternary nodes are guaranteed to be non-null. We don't need to check for their existence when traversing the tree. BUG=angleproject:2662 TEST=angle_unittests Change-Id: I5575058e7213d0c4b4554ca616b4298e535842d6 Reviewed-on: https://chromium-review.googlesource.com/1098670Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent f462ac1b
...@@ -1047,6 +1047,7 @@ TIntermSwizzle::TIntermSwizzle(TIntermTyped *operand, const TVector<int> &swizzl ...@@ -1047,6 +1047,7 @@ TIntermSwizzle::TIntermSwizzle(TIntermTyped *operand, const TVector<int> &swizzl
mSwizzleOffsets(swizzleOffsets), mSwizzleOffsets(swizzleOffsets),
mHasFoldedDuplicateOffsets(false) mHasFoldedDuplicateOffsets(false)
{ {
ASSERT(mOperand);
ASSERT(mSwizzleOffsets.size() <= 4); ASSERT(mSwizzleOffsets.size() <= 4);
promote(); promote();
} }
...@@ -1054,12 +1055,15 @@ TIntermSwizzle::TIntermSwizzle(TIntermTyped *operand, const TVector<int> &swizzl ...@@ -1054,12 +1055,15 @@ TIntermSwizzle::TIntermSwizzle(TIntermTyped *operand, const TVector<int> &swizzl
TIntermUnary::TIntermUnary(TOperator op, TIntermTyped *operand, const TFunction *function) TIntermUnary::TIntermUnary(TOperator op, TIntermTyped *operand, const TFunction *function)
: TIntermOperator(op), mOperand(operand), mUseEmulatedFunction(false), mFunction(function) : TIntermOperator(op), mOperand(operand), mUseEmulatedFunction(false), mFunction(function)
{ {
ASSERT(mOperand);
promote(); promote();
} }
TIntermBinary::TIntermBinary(TOperator op, TIntermTyped *left, TIntermTyped *right) TIntermBinary::TIntermBinary(TOperator op, TIntermTyped *left, TIntermTyped *right)
: TIntermOperator(op), mLeft(left), mRight(right), mAddIndexClamp(false) : TIntermOperator(op), mLeft(left), mRight(right), mAddIndexClamp(false)
{ {
ASSERT(mLeft);
ASSERT(mRight);
promote(); promote();
} }
...@@ -1087,6 +1091,9 @@ TIntermTernary::TIntermTernary(TIntermTyped *cond, ...@@ -1087,6 +1091,9 @@ TIntermTernary::TIntermTernary(TIntermTyped *cond,
mTrueExpression(trueExpression), mTrueExpression(trueExpression),
mFalseExpression(falseExpression) mFalseExpression(falseExpression)
{ {
ASSERT(mCondition);
ASSERT(mTrueExpression);
ASSERT(mFalseExpression);
getTypePointer()->setQualifier( getTypePointer()->setQualifier(
TIntermTernary::DetermineQualifier(cond, trueExpression, falseExpression)); TIntermTernary::DetermineQualifier(cond, trueExpression, falseExpression));
} }
......
...@@ -254,13 +254,12 @@ void TIntermTraverser::traverseBinary(TIntermBinary *node) ...@@ -254,13 +254,12 @@ void TIntermTraverser::traverseBinary(TIntermBinary *node)
// //
if (visit) if (visit)
{ {
if (node->getLeft()) node->getLeft()->traverse(this);
node->getLeft()->traverse(this);
if (inVisit) if (inVisit)
visit = visitBinary(InVisit, node); visit = visitBinary(InVisit, node);
if (visit && node->getRight()) if (visit)
node->getRight()->traverse(this); node->getRight()->traverse(this);
} }
...@@ -301,8 +300,7 @@ void TLValueTrackingTraverser::traverseBinary(TIntermBinary *node) ...@@ -301,8 +300,7 @@ void TLValueTrackingTraverser::traverseBinary(TIntermBinary *node)
setOperatorRequiresLValue(true); setOperatorRequiresLValue(true);
} }
if (node->getLeft()) node->getLeft()->traverse(this);
node->getLeft()->traverse(this);
if (inVisit) if (inVisit)
visit = visitBinary(InVisit, node); visit = visitBinary(InVisit, node);
...@@ -320,7 +318,7 @@ void TLValueTrackingTraverser::traverseBinary(TIntermBinary *node) ...@@ -320,7 +318,7 @@ void TLValueTrackingTraverser::traverseBinary(TIntermBinary *node)
setInFunctionCallOutParameter(false); setInFunctionCallOutParameter(false);
} }
if (visit && node->getRight()) if (visit)
node->getRight()->traverse(this); node->getRight()->traverse(this);
setOperatorRequiresLValue(parentOperatorRequiresLValue); setOperatorRequiresLValue(parentOperatorRequiresLValue);
...@@ -715,10 +713,8 @@ void TIntermTraverser::traverseTernary(TIntermTernary *node) ...@@ -715,10 +713,8 @@ void TIntermTraverser::traverseTernary(TIntermTernary *node)
if (visit) if (visit)
{ {
node->getCondition()->traverse(this); node->getCondition()->traverse(this);
if (node->getTrueExpression()) node->getTrueExpression()->traverse(this);
node->getTrueExpression()->traverse(this); node->getFalseExpression()->traverse(this);
if (node->getFalseExpression())
node->getFalseExpression()->traverse(this);
} }
if (visit && postVisit) if (visit && postVisit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment