Speed up highlighter notify
Avoid calling `table.{insert,remove}` multiple times, as this causes multiple shifts in the `self.lines` table.
This commit is contained in:
parent
a7bbd3d6f7
commit
23a0f6ca79
|
@ -1,4 +1,5 @@
|
||||||
local core = require "core"
|
local core = require "core"
|
||||||
|
local common = require "core.common"
|
||||||
local config = require "core.config"
|
local config = require "core.config"
|
||||||
local tokenizer = require "core.tokenizer"
|
local tokenizer = require "core.tokenizer"
|
||||||
local Object = require "core.object"
|
local Object = require "core.object"
|
||||||
|
@ -51,16 +52,16 @@ end
|
||||||
|
|
||||||
function Highlighter:insert_notify(line, n)
|
function Highlighter:insert_notify(line, n)
|
||||||
self:invalidate(line)
|
self:invalidate(line)
|
||||||
|
local blanks = { }
|
||||||
for i = 1, n do
|
for i = 1, n do
|
||||||
table.insert(self.lines, line, false)
|
blanks[i] = false
|
||||||
end
|
end
|
||||||
|
common.splice(self.lines, line, 0, blanks)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Highlighter:remove_notify(line, n)
|
function Highlighter:remove_notify(line, n)
|
||||||
self:invalidate(line)
|
self:invalidate(line)
|
||||||
for i = 1, n do
|
common.splice(self.lines, line, n)
|
||||||
table.remove(self.lines, line)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue