diff options
| author | Maxime Coste <mawww@kakoune.org> | 2020-11-07 10:14:18 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2020-11-07 10:14:18 +1100 |
| commit | b1745ee8d353bdbe154666aadddccae87359dddf (patch) | |
| tree | a193f2c84a769dfe29c4c81c96e6c109c9ea0a3a | |
| parent | 94ac3084e156b87869f8b336ae0a3fd752743179 (diff) | |
Fix performance issue when pasting many selection
The previous code was advancing from the general insertion point
for all selection, instead of iterating only once from insertion
point until the end of inserted text.
| -rw-r--r-- | src/normal.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc index bd520cb6..618c0008 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -748,12 +748,14 @@ void paste_all(Context& context, NormalParams params) Vector<Selection> result; for (auto& ins_pos : insert_pos) { - ByteCount pos = 0; + ByteCount pos_offset = 0; + BufferCoord pos = ins_pos; for (auto offset : offsets) { - result.emplace_back(buffer.advance(ins_pos, pos), - buffer.advance(ins_pos, offset-1)); - pos = offset; + BufferCoord end = buffer.advance(pos, offset - pos_offset - 1); + result.emplace_back(pos, end); + pos = buffer.next(end); + pos_offset = offset; } } if (not result.empty()) |
