compute_line_modifications: avoid potentially long iteration

This commit is contained in:
Maxime Coste 2018-05-16 20:41:02 +10:00
parent fcce76ba57
commit 4cc9c9997e

View File

@ -73,10 +73,13 @@ Vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t
} }
next = res.erase(next, delend); next = res.erase(next, delend);
for (auto it = next; it != res.end(); ++it) if (diff != 0)
it->new_line -= diff; {
for (auto it = next; it != res.end(); ++it)
it->new_line -= diff;
}
} }
else else if (diff != 0)
{ {
for (auto it = next; it != res.end(); ++it) for (auto it = next; it != res.end(); ++it)
it->new_line += diff; it->new_line += diff;