mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
auto cleanup
This commit is contained in:
parent
310adedc90
commit
c770cac964
4 changed files with 8 additions and 8 deletions
|
@ -595,7 +595,7 @@ const Lexeme Lexer::nextInterpolatedString()
|
||||||
Position start = position();
|
Position start = position();
|
||||||
unsigned int startOffset = offset;
|
unsigned int startOffset = offset;
|
||||||
|
|
||||||
if (auto readSection = readInterpolatedStringSection(start, Lexeme::InterpStringMid))
|
if (std::optional<Lexeme> readSection = readInterpolatedStringSection(start, Lexeme::InterpStringMid))
|
||||||
{
|
{
|
||||||
lexeme = *readSection;
|
lexeme = *readSection;
|
||||||
return lexeme;
|
return lexeme;
|
||||||
|
@ -646,7 +646,7 @@ std::optional<Lexeme> Lexer::readInterpolatedStringSection(Position start, Lexem
|
||||||
return Lexeme(Location(start, position()), Lexeme::BrokenInterpDoubleBrace);
|
return Lexeme(Location(start, position()), Lexeme::BrokenInterpDoubleBrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lexemeOutput = Lexeme(Location(start, position()), Lexeme::InterpStringBegin, &buffer[startOffset], offset - startOffset);
|
Lexeme lexemeOutput(Location(start, position()), Lexeme::InterpStringBegin, &buffer[startOffset], offset - startOffset);
|
||||||
consume();
|
consume();
|
||||||
return lexemeOutput;
|
return lexemeOutput;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2647,7 +2647,7 @@ AstExpr* Parser::parseInterpString()
|
||||||
Location startLocation = lexer.current().location;
|
Location startLocation = lexer.current().location;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
auto currentLexeme = lexer.current();
|
Lexeme currentLexeme = lexer.current();
|
||||||
LUAU_ASSERT(currentLexeme.type == Lexeme::InterpStringBegin || currentLexeme.type == Lexeme::InterpStringMid || currentLexeme.type == Lexeme::InterpStringEnd);
|
LUAU_ASSERT(currentLexeme.type == Lexeme::InterpStringBegin || currentLexeme.type == Lexeme::InterpStringMid || currentLexeme.type == Lexeme::InterpStringEnd);
|
||||||
|
|
||||||
Location location = currentLexeme.location;
|
Location location = currentLexeme.location;
|
||||||
|
@ -2691,7 +2691,7 @@ AstExpr* Parser::parseInterpString()
|
||||||
|
|
||||||
expressions.push_back(expression);
|
expressions.push_back(expression);
|
||||||
|
|
||||||
auto next = lexer.nextInterpolatedString();
|
Lexeme next = lexer.nextInterpolatedString();
|
||||||
|
|
||||||
switch (next.type)
|
switch (next.type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1507,15 +1507,15 @@ struct Compiler
|
||||||
formatString += "%*";
|
formatString += "%*";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto formatStringSize = formatString.size();
|
size_t formatStringSize = formatString.size();
|
||||||
|
|
||||||
// We can't use formatStringRef.data() directly, because short strings don't have their data
|
// We can't use formatStringRef.data() directly, because short strings don't have their data
|
||||||
// pinned in memory, so when interpFormatStrings grows, these pointers will move and become invalid.
|
// pinned in memory, so when interpFormatStrings grows, these pointers will move and become invalid.
|
||||||
std::shared_ptr<char[]> formatStringPtr(new char[formatStringSize]);
|
std::shared_ptr<char[]> formatStringPtr(new char[formatStringSize]);
|
||||||
memcpy(formatStringPtr.get(), formatString.data(), formatStringSize);
|
memcpy(formatStringPtr.get(), formatString.data(), formatStringSize);
|
||||||
|
|
||||||
auto formatStringPtrRef = interpFormatStrings.emplace_back(formatStringPtr);
|
interpFormatStrings.emplace_back(formatStringPtr);
|
||||||
AstArray<char> formatStringArray{formatStringPtrRef.get(), formatStringSize};
|
AstArray<char> formatStringArray{formatStringPtr.get(), formatStringSize};
|
||||||
|
|
||||||
int32_t formatStringIndex = bytecode.addConstantString(sref(formatStringArray));
|
int32_t formatStringIndex = bytecode.addConstantString(sref(formatStringArray));
|
||||||
if (formatStringIndex < 0)
|
if (formatStringIndex < 0)
|
||||||
|
|
|
@ -222,7 +222,7 @@ struct CostVisitor : AstVisitor
|
||||||
// Baseline cost of string.format
|
// Baseline cost of string.format
|
||||||
Cost cost = 3;
|
Cost cost = 3;
|
||||||
|
|
||||||
for (auto innerExpression : expr->expressions)
|
for (AstExpr* innerExpression : expr->expressions)
|
||||||
cost += model(innerExpression);
|
cost += model(innerExpression);
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
|
|
Loading…
Add table
Reference in a new issue