Closed tophf closed 10 years ago
I should talk to plorkyeran about a version that takes an array of indices rather than a list of arguments.
So now subs.delete is added which is good but:
ok, _ = pcall sub.delete sel
ok, _ = pcall -> sub.delete unpack sel unless ok
if not ok --pay the price
for i = #sel, 1, -1
sub.delete sel[i] -- BALEET (in reverse because they are not necessarily contiguous)
check_user_cancelled!
ok, _ = pcall -> sub.insert strt, unpack [v.data for v in *lines]
if not ok --pay the price
for i, v in ipairs lines
aegisub.progress.set i/#lines*100
sub.insert strt, v.data -- not sure this is the best place to do this but owell
strt += 1
check_user_cancelled!
I didn't even notice subs.insert(start, line1, line2, ...) existed. I wonder if that would be more efficient than inserting 1-by-1, though, because I imagine Lua has to copy memory around every time you insert an index into a table, which would get expensive with a big table full of dialog line tables.
That said, it would make sense for symmetric syntax to exist, and I could be wrong about it being slower, anyway.
You could be right. But we can try to reorganize processing of the 'lines' table like this (when and if subs.insert is extended):
sortF = ({
Time: (l, n) ->
l.key, l.num = l.start_time, n
l
...................
})[sor]
...................
ok, _ = pcall sub.insert strt, lines
if not ok --pay the price
for i, v in ipairs lines
aegisub.progress.set i/#lines*100
sub.insert strt, v
strt += 1
check_user_cancelled!