Skip to content

Commit

Permalink
Use const auto& instead of auto& in Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Sep 26, 2023
1 parent 0c3d053 commit 7cc5b9d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fintamath/expressions/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ 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<IOperator>(term->value) &&
!isPrefixOperator(term->value)) {

term->value = IOperator::parse(term->name, IOperator::Priority::PrefixUnary);
isFixed = isFixed && term->value;
}

if (auto &term = terms.back();
if (const auto &term = terms.back();
is<IOperator>(term->value) &&
!isPostfixOperator(term->value)) {

Expand All @@ -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<IOperator>(term->value) &&
Expand All @@ -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<IOperator>(term->value) &&
Expand All @@ -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<Factorial>(term->value);
Expand Down

0 comments on commit 7cc5b9d

Please sign in to comment.