diff --git a/src/renderer/atlas/AtlasEngine.cpp b/src/renderer/atlas/AtlasEngine.cpp index c6fad7ca09b9..c4b331d36485 100644 --- a/src/renderer/atlas/AtlasEngine.cpp +++ b/src/renderer/atlas/AtlasEngine.cpp @@ -7,7 +7,6 @@ #include #include -#include "../base/FontCache.h" #include "../../interactivity/win32/CustomWindowMessages.h" // #### NOTE #### @@ -192,42 +191,41 @@ try const auto nothingInvalid = _api.invalidatedRows.x == _api.invalidatedRows.y; const auto offset = static_cast(_api.scrollOffset) * _api.cellCount.x; auto count = _r.cells.size(); - ptrdiff_t srcOffset = 0; - ptrdiff_t dstOffset = 0; if (_api.scrollOffset < 0) { // Scroll up (for instance when new text is being written at the end of the buffer). - srcOffset = -offset; - dstOffset = 0; - count += offset; - const u16 endRow = _api.cellCount.y + _api.scrollOffset; _api.invalidatedRows.x = nothingInvalid ? endRow : std::min(_api.invalidatedRows.x, endRow); _api.invalidatedRows.y = _api.cellCount.y; + + { + const auto beg = _r.cells.begin(); + const auto end = beg + count; + std::move(beg - offset, end, beg); + } + { + const auto beg = _r.cellGlyphMapping.begin(); + const auto end = beg + count; + std::move(beg - offset, end, beg); + } } else { // Scroll down. - srcOffset = 0; - dstOffset = offset; - count -= offset; - _api.invalidatedRows.x = 0; _api.invalidatedRows.y = nothingInvalid ? _api.scrollOffset : std::max(_api.invalidatedRows.y, _api.scrollOffset); - } - { - const auto beg = _r.cells.begin(); - const auto src = beg + srcOffset; - const auto dst = beg + dstOffset; - std::move(src, src + count, dst); - } - { - const auto beg = _r.cellGlyphMapping.begin(); - const auto src = beg + srcOffset; - const auto dst = beg + dstOffset; - std::move(src, src + count, dst); + { + const auto beg = _r.cells.begin(); + const auto end = beg + count; + std::move_backward(beg, end - offset, end); + } + { + const auto beg = _r.cellGlyphMapping.begin(); + const auto end = beg + count; + std::move_backward(beg, end - offset, end); + } } } }