mirror of https://github.com/odrling/Aegisub
Don't build the dialogue lexer on every use
Building the lexer takes much longer than actually lexing, and since the lexer is stateless there's no reason not to just make it static.
This commit is contained in:
parent
706a72d5c1
commit
92b8b2851b
|
@ -206,10 +206,12 @@ namespace parser {
|
|||
|
||||
namespace ass {
|
||||
std::vector<DialogueToken> TokenizeDialogueBody(std::string const& str, bool karaoke_templater) {
|
||||
dialogue_tokens<lex::lexertl::actor_lexer<>> tokenizer(karaoke_templater);
|
||||
static const dialogue_tokens<lex::lexertl::actor_lexer<>> kt(true);
|
||||
static const dialogue_tokens<lex::lexertl::actor_lexer<>> not_kt(false);
|
||||
auto const& tokenizer = karaoke_templater ? kt : not_kt;
|
||||
|
||||
char const* first = str.c_str();
|
||||
char const* last = first + str.size();
|
||||
char const *first = str.c_str();
|
||||
char const *last = first + str.size();
|
||||
std::vector<DialogueToken> data;
|
||||
auto it = tokenizer.begin(first, last), end = tokenizer.end();
|
||||
|
||||
|
|
Loading…
Reference in New Issue