Refactoring: Replace Expression::op check followed by static cast to Expression::is<ExpressionType> (#3141)

This may negatively impact performance, as the (final, i.e.,
non-virtual) Expression::is... family is implemented in D and not
available inline in the C++ headers.
This commit is contained in:
Martin Kinkelin 2020-01-15 12:54:05 +01:00 committed by GitHub
parent ec1c37a5a4
commit 26673c174f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 112 additions and 132 deletions

View file

@ -56,14 +56,14 @@ RVals evalSides(DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) {
Expression *extractNoStrideInc(Expression *e, d_uns64 baseSize, bool &negate) {
MulExp *mul;
while (true) {
if (e->op == TOKneg) {
if (auto ne = e->isNegExp()) {
negate = !negate;
e = static_cast<NegExp *>(e)->e1;
e = ne->e1;
continue;
}
if (e->op == TOKmul) {
mul = static_cast<MulExp *>(e);
if (auto me = e->isMulExp()) {
mul = me;
break;
}