Skip to content

Commit

Permalink
Fixes for SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Sep 26, 2023
1 parent 0c3d053 commit 382e53b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions include/fintamath/expressions/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ inline void Expression::registerFunctionExpressionMaker(auto &&maker) {
std::unique_ptr<IMathObject> res;

if constexpr (IsFunctionTypeAny<Function>::value) {
res = maker(std::move(args));
res = maker(std::forward<ArgumentPtrVector>(args));
}
else if constexpr (isPolynomial) {
if (size_t(type) <= args.size()) {
res = maker(std::move(args));
res = maker(std::forward<ArgumentPtrVector>(args));
}
}
else {
if (size_t(type) == args.size()) {
res = maker(std::move(args));
res = maker(std::forward<ArgumentPtrVector>(args));
}
}

Expand Down
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 382e53b

Please sign in to comment.