1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-28 08:13:17 +03:00

Speed up row runs for ranges function

This commit is contained in:
Tae Won Ha 2017-06-05 15:58:30 +02:00
parent c415df78e1
commit 5c713c8d97
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -206,13 +206,18 @@ extension NeoVimView {
let rowCells = self.grid.cells[row]
let startIdx = columnRange.lowerBound
var result = [RowRun(row: row, range: startIdx...startIdx, attrs: rowCells[startIdx].attrs)]
var result: [RowRun] = []
var last = RowRun(row: row, range: startIdx...startIdx, attrs: rowCells[startIdx].attrs)
columnRange.forEach { idx in
if rowCells[idx].attrs == result.last!.attrs {
let last = result.popLast()!
result.append(RowRun(row: row, range: last.range.lowerBound...idx, attrs: last.attrs))
if last.attrs == rowCells[idx].attrs {
last.range = last.range.lowerBound...idx
} else {
result.append(RowRun(row: row, range: idx...idx, attrs: rowCells[idx].attrs))
result.append(last)
last = RowRun(row: row, range: idx...idx, attrs: rowCells[idx].attrs)
}
if idx == columnRange.upperBound {
result.append(last)
}
}