speeding up copy, attempt 1
Problem: repeatedly copying (relatively large) sections of text quickly makes the app sluggish until it has to be killed. (Thanks John Blommers for the report.) When I instrument with prints, the sluggishness seems to happen in random draw() calls many times after I perform the copy. I don't know for sure, but I'm initially checking if the cause is garbage generated by repeated string concatenation. This attempt doesn't seem to make any difference.
This commit is contained in:
parent
ac4879bb85
commit
e77157d316
|
@ -163,14 +163,14 @@ function Text.selection()
|
|||
return Lines[minl].data:sub(min_offset, max_offset-1)
|
||||
end
|
||||
assert(minl < maxl)
|
||||
local result = Lines[minl].data:sub(min_offset)..'\n'
|
||||
local result = {Lines[minl].data:sub(min_offset)}
|
||||
for i=minl+1,maxl-1 do
|
||||
if Lines[i].mode == 'text' then
|
||||
result = result..Lines[i].data..'\n'
|
||||
table.insert(result, Lines[i].data)
|
||||
end
|
||||
end
|
||||
result = result..Lines[maxl].data:sub(1, max_offset-1)
|
||||
return result
|
||||
table.insert(result, Lines[maxl].data:sub(1, max_offset-1))
|
||||
return table.concat(result, '\n')
|
||||
end
|
||||
|
||||
function Text.cut_selection()
|
||||
|
|
Loading…
Reference in New Issue