From 1a9d284a5f21e9def137c2903dcc540064f7a884 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Fri, 8 Mar 2019 09:00:16 -0500 Subject: [PATCH] LineCollection: move meta/styles generation to the constructor This was originally moved out with https://github.com/TypesettingTools/Aegisub-Motion/commit/6931979a40082223167d14650d544df010fa3c1e for performance reasons when reusing a LineCollection instance, but changes since then have created a data flow where if the selection is empty, styles will never be generated. Looking at how people use this class in practice, I think it makes sense to just move this back to the constructor. --- src/LineCollection.moon | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/LineCollection.moon b/src/LineCollection.moon index 98a5ddf..8ec2399 100644 --- a/src/LineCollection.moon +++ b/src/LineCollection.moon @@ -46,6 +46,8 @@ class LineCollection else metaIndex[index] + @generateMetaAndStyles! + if type( sel ) == "table" and #sel > 0 @collectLines sel, validationCb, selectLines if frameFromMs 0 @@ -112,9 +114,6 @@ class LineCollection @hasMetaStyles = true collectLines: ( sel, validationCb = (( line ) -> return not line.comment), selectLines = true ) => - unless @hasMetaStyles - @generateMetaAndStyles! - dialogueStart = 0 for x = 1, #@sub if @sub[x].class == "dialogue"