From e06e409dc16cd98e0353b6bd33b311efbc792000 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 21 Jun 2023 17:36:33 +1000 Subject: [PATCH] Another small structured binding conversion --- src/buffer.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index c968690f..4460bab7 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -221,36 +221,36 @@ void Buffer::reload(BufferLines lines, ByteOrderMark bom, EolFormat eolformat, F auto it = m_lines.begin(); auto new_it = lines.begin(); - for (auto& d : diff) + for (auto& [op, len] : diff) { - if (d.op == DiffOp::Keep) + if (op == DiffOp::Keep) { - it += d.len; - new_it += d.len; + it += len; + new_it += len; } - else if (d.op == DiffOp::Add) + else if (op == DiffOp::Add) { const LineCount cur_line = (int)(it - m_lines.begin()); - for (LineCount line = 0; line < d.len; ++line) + for (LineCount line = 0; line < len; ++line) m_current_undo_group.push_back({Modification::Insert, cur_line + line, *(new_it + (int)line)}); - m_changes.push_back({Change::Insert, cur_line, cur_line + d.len}); - m_lines.insert(it, new_it, new_it + d.len); - it = m_lines.begin() + (int)(cur_line + d.len); - new_it += d.len; + m_changes.push_back({Change::Insert, cur_line, cur_line + len}); + m_lines.insert(it, new_it, new_it + len); + it = m_lines.begin() + (int)(cur_line + len); + new_it += len; } - else if (d.op == DiffOp::Remove) + else if (op == DiffOp::Remove) { const LineCount cur_line = (int)(it - m_lines.begin()); - for (LineCount line = d.len-1; line >= 0; --line) + for (LineCount line = len-1; line >= 0; --line) m_current_undo_group.push_back({ Modification::Erase, cur_line + line, m_lines.get_storage(cur_line + line)}); - it = m_lines.erase(it, it + d.len); - m_changes.push_back({ Change::Erase, cur_line, cur_line + d.len }); + it = m_lines.erase(it, it + len); + m_changes.push_back({ Change::Erase, cur_line, cur_line + len }); } } }