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:
parent
c415df78e1
commit
5c713c8d97
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user