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.
This commit is contained in:
Tomas Babej 2021-04-23 22:42:41 -04:00
parent c3f9d09d22
commit e7487c8a63

View file

@ -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 ())