diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-06-11 02:22:57 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-11 02:22:57 (GMT) |
| commit | d5f13f7bd9b567d2e934c549d7096f74b6e06031 (patch) | |
| tree | 94bab1d0718d201bb8c3d9c57815e01707bec2dd | |
| parent | 4d91012fcc8af48d3cf3f1cc6ab16c3f38a582a4 (diff) | |
Further simplify code
| -rw-r--r-- | src/displayapp/screens/Calculator.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/displayapp/screens/Calculator.cpp b/src/displayapp/screens/Calculator.cpp index 979d12b..e1f36f6 100644 --- a/src/displayapp/screens/Calculator.cpp +++ b/src/displayapp/screens/Calculator.cpp @@ -188,9 +188,7 @@ bool Calculator::Eval() { } } - char next = input.top(); - input.pop(); - + char next = input.pop(); switch (next) { case '+': case '-': @@ -206,8 +204,7 @@ bool Calculator::Eval() { // or (the operator at the top of the operator stack has equal precedence and the token is left associative)) || (getPrecedence(operators.top()) == getPrecedence(next) && leftAssociative(next)))) { // need two elements on the output stack to add a binary operator - if (!output.pushOperator(operators.top())) return false; - operators.pop(); + if (!output.pushOperator(operators.pop())) return false; } operators.push(next); expectingNumber = true; @@ -232,8 +229,7 @@ bool Calculator::Eval() { case ')': while (operators.top() != '(') { // need two elements on the output stack to add a binary operator - if (!output.pushOperator(operators.top())) return false; - operators.pop(); + if (!output.pushOperator(operators.pop())) return false; if (operators.empty()) return false; } // discard the left parentheses |
