Fixed return strict const iterator, replace to range-based loop C++17 and code refactor (#548)

Signed-off-by: Herman Semenov <GermanAizek@yandex.ru>
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
Herman Semenoff
2024-10-18 08:06:11 +00:00
committed by GitHub
parent 9814a1b788
commit 96ea686eb6
8 changed files with 31 additions and 32 deletions

View File

@@ -163,10 +163,10 @@ void CFG::EmitDivergenceLabels() {
}
void CFG::EmitBlocks() {
for (auto it = labels.begin(); it != labels.end(); it++) {
for (auto it = labels.cbegin(); it != labels.cend(); ++it) {
const Label start = *it;
const auto next_it = std::next(it);
const bool is_last = next_it == labels.end();
const bool is_last = (next_it == labels.cend());
if (is_last) {
// Last label is special.
return;
@@ -193,7 +193,7 @@ void CFG::EmitBlocks() {
void CFG::LinkBlocks() {
const auto get_block = [this](u32 address) {
auto it = blocks.find(address, Compare{});
ASSERT_MSG(it != blocks.end() && it->begin == address);
ASSERT_MSG(it != blocks.cend() && it->begin == address);
return &*it;
};