From d5f13f7bd9b567d2e934c549d7096f74b6e06031 Mon Sep 17 00:00:00 2001 From: Michele Bini Date: Sat, 11 Jun 2022 04:22:57 +0200 Subject: Further simplify code 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 -- cgit v0.10.2