diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-05-16 20:41:02 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-05-17 07:41:32 +1000 |
| commit | 4cc9c9997e5d9f190a5cfaa28ea1aac0fae34b4b (patch) | |
| tree | 2de623a0c5e67a6f27d6b154fa6ea3effe1866dd /src/line_modification.cc | |
| parent | fcce76ba5718cd3ab22a2d7707e9714ed923aea7 (diff) | |
compute_line_modifications: avoid potentially long iteration
Diffstat (limited to 'src/line_modification.cc')
| -rw-r--r-- | src/line_modification.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/line_modification.cc b/src/line_modification.cc index df2b9cbc..da3ee87f 100644 --- a/src/line_modification.cc +++ b/src/line_modification.cc @@ -73,10 +73,13 @@ Vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t } next = res.erase(next, delend); - for (auto it = next; it != res.end(); ++it) - it->new_line -= diff; + if (diff != 0) + { + 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) it->new_line += diff; |
