From 54734826e768f0df8f675323bb5cc305c9ffa250 Mon Sep 17 00:00:00 2001 From: Kampfkarren Date: Wed, 27 Jul 2022 23:36:45 -0700 Subject: [PATCH] Use TempVector --- Ast/include/Luau/Parser.h | 1 + Ast/src/Parser.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Ast/include/Luau/Parser.h b/Ast/include/Luau/Parser.h index 32e15c3b..504e19e6 100644 --- a/Ast/include/Luau/Parser.h +++ b/Ast/include/Luau/Parser.h @@ -365,6 +365,7 @@ private: std::vector matchRecoveryStopOnToken; std::vector scratchStat; + std::vector> scratchString; std::vector scratchExpr; std::vector scratchExprAux; std::vector scratchName; diff --git a/Ast/src/Parser.cpp b/Ast/src/Parser.cpp index e3139576..0efe650d 100644 --- a/Ast/src/Parser.cpp +++ b/Ast/src/Parser.cpp @@ -2642,8 +2642,8 @@ AstExpr* Parser::parseString() AstExpr* Parser::parseInterpString() { - std::vector> strings; - std::vector expressions; + TempVector> strings(scratchString); + TempVector expressions(scratchExpr); Location startLocation = lexer.current().location; @@ -2671,13 +2671,8 @@ AstExpr* Parser::parseInterpString() if (currentLexeme.type == Lexeme::InterpStringEnd) { - // INTERP CODE REVIEW: I figure this isn't the right way to do this. - // From what I could gather, I'm expected to have strings and expressions be TempVector from the beginning. - // Everything that does that uses a scratch value. - // But I would think I would also be expected to use an existing scratch, like `scratchExpr`, in which case - // my assumption is that a nested expression would clash the scratches? - AstArray> stringsArray = copy(strings.data(), strings.size()); - AstArray expressionsArray = copy(expressions.data(), expressions.size()); + AstArray> stringsArray = copy(strings); + AstArray expressionsArray = copy(expressions); return allocator.alloc(startLocation, stringsArray, expressionsArray); }