From e7487c8a63ccebbb4cc09d0b83bec6a1ac6888d1 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 23 Apr 2021 22:42:41 -0400 Subject: [PATCH] performance: Avoid lexing input when not needed in getDOM Lexing a token can be expensive operation. Perform lexing only if a UUID/ID reference could have been provided. --- src/DOM.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DOM.cpp b/src/DOM.cpp index 86dde5904..442a05de7 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -265,7 +265,10 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) Lexer lexer (elements[0]); std::string token; Lexer::Type type; - if (lexer.token (token, type)) + + // If this can be ID/UUID reference (the name contains '.'), + // lex it to figure out. Otherwise don't lex, as lexing can be slow. + if ((elements.size() > 1) and lexer.token (token, type)) { if (type == Lexer::Type::uuid && token.length () == elements[0].length ())