Skip to content

Commit

Permalink
used for-ranged loop
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Aug 13, 2024
1 parent e4b7075 commit 11ff6da
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/orm/utils/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ QString String::snake(QString string, const QChar delimiter)
}

// Positions stay valid after inserts because reverse iterators used
std::ranges::for_each(positions.crbegin(), positions.crend(),
[&string, delimiter](const QString::size_type pos)
{
for (const QString::size_type pos : positions | ranges::views::reverse) {
const auto previousPos = pos - 1;

// Change space to _
Expand All @@ -199,7 +197,7 @@ QString String::snake(QString string, const QChar delimiter)
// Prepend the _ before A-Z
else
string.insert(pos, delimiter);
});
}

return (*snakeCache)[std::move(key)] = string.replace(SPACE, EMPTY).toLower();
}
Expand Down

0 comments on commit 11ff6da

Please sign in to comment.