From 7cc5b9db564f2e7b4fd9c72932b22eb63c93bbf0 Mon Sep 17 00:00:00 2001 From: fintarin Date: Tue, 26 Sep 2023 16:44:02 +0300 Subject: [PATCH] Use const auto& instead of auto& in Expression --- src/fintamath/expressions/Expression.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fintamath/expressions/Expression.cpp b/src/fintamath/expressions/Expression.cpp index 32add543b..708588de5 100644 --- a/src/fintamath/expressions/Expression.cpp +++ b/src/fintamath/expressions/Expression.cpp @@ -308,7 +308,7 @@ void Expression::insertMultiplications(TermVector &terms) { void Expression::fixOperatorTypes(TermVector &terms) { bool isFixed = true; - if (auto &term = terms.front(); + if (const auto &term = terms.front(); is(term->value) && !isPrefixOperator(term->value)) { @@ -316,7 +316,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { isFixed = isFixed && term->value; } - if (auto &term = terms.back(); + if (const auto &term = terms.back(); is(term->value) && !isPostfixOperator(term->value)) { @@ -333,7 +333,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { } for (auto i : std::views::iota(1U, terms.size() - 1)) { - auto &term = terms[i]; + const auto &term = terms[i]; const auto &termPrev = terms[i - 1]; if (is(term->value) && @@ -347,7 +347,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { // TODO: use reverse(iota(1, terms.size() - 1)) when it is work for (size_t i = terms.size() - 2; i > 0; i--) { - auto &term = terms[i]; + const auto &term = terms[i]; const auto &termNext = terms[i + 1]; if (is(term->value) && @@ -366,7 +366,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { void Expression::collapseFactorials(TermVector &terms) { for (size_t i = 1; i + 1 < terms.size(); i++) { - auto &term = terms[i]; + const auto &term = terms[i]; const auto &termNext = terms[i + 1]; if (auto factorial = cast(term->value);