diff options
author | Khan M Rashedun-Naby <naby88@gmail.com> | 2018-09-23 19:28:51 +0800 |
---|---|---|
committer | Khan M Rashedun-Naby <naby88@gmail.com> | 2018-09-24 10:31:44 +0800 |
commit | 376ce079155265ee7bc1c1a624deea921f13906b (patch) | |
tree | 0a60664c0e1fbb187deb847faafc8283322b337d /libsolidity/analysis/SemVerHandler.cpp | |
parent | 5dd3ee2d9657f18b9b2797755e1216b93b67316c (diff) | |
download | dexon-solidity-376ce079155265ee7bc1c1a624deea921f13906b.tar.gz dexon-solidity-376ce079155265ee7bc1c1a624deea921f13906b.tar.zst dexon-solidity-376ce079155265ee7bc1c1a624deea921f13906b.zip |
Use 'switch' instead of 'if..else if'
Diffstat (limited to 'libsolidity/analysis/SemVerHandler.cpp')
-rw-r--r-- | libsolidity/analysis/SemVerHandler.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/libsolidity/analysis/SemVerHandler.cpp b/libsolidity/analysis/SemVerHandler.cpp index 42186396..29f6d5de 100644 --- a/libsolidity/analysis/SemVerHandler.cpp +++ b/libsolidity/analysis/SemVerHandler.cpp @@ -106,18 +106,22 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio } if (cmp == 0 && !_version.prerelease.empty() && didCompare) cmp = -1; - if (prefix == Token::Assign) + + switch (prefix) + { + case Token::Assign: return cmp == 0; - else if (prefix == Token::LessThan) + case Token::LessThan: return cmp < 0; - else if (prefix == Token::LessThanOrEqual) + case Token::LessThanOrEqual: return cmp <= 0; - else if (prefix == Token::GreaterThan) + case Token::GreaterThan: return cmp > 0; - else if (prefix == Token::GreaterThanOrEqual) + case Token::GreaterThanOrEqual: return cmp >= 0; - else + default: solAssert(false, "Invalid SemVer expression"); + } return false; } } @@ -196,21 +200,22 @@ SemVerMatchExpression::MatchComponent SemVerMatchExpressionParser::parseMatchCom { SemVerMatchExpression::MatchComponent component; Token::Value token = currentToken(); - if ( - token == Token::BitXor || - token == Token::BitNot || - token == Token::LessThan || - token == Token::LessThanOrEqual|| - token == Token::GreaterThan || - token == Token::GreaterThanOrEqual || - token == Token::Assign - ) + + switch (token) { + case Token::BitXor: + case Token::BitNot: + case Token::LessThan: + case Token::LessThanOrEqual: + case Token::GreaterThan: + case Token::GreaterThanOrEqual: + case Token::Assign: component.prefix = token; nextToken(); - } - else + break; + default: component.prefix = Token::Assign; + } component.levelsPresent = 0; while (component.levelsPresent < 3) |