mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Reserve format capacity
This commit is contained in:
parent
d4dce498f7
commit
90f7bf6f72
1 changed files with 7 additions and 0 deletions
|
@ -1482,7 +1482,14 @@ struct Compiler
|
||||||
|
|
||||||
void compileExprInterpString(AstExprInterpString* expr, uint8_t target, bool targetTemp)
|
void compileExprInterpString(AstExprInterpString* expr, uint8_t target, bool targetTemp)
|
||||||
{
|
{
|
||||||
|
size_t formatCapacity = 0;
|
||||||
|
for (AstArray<char> string : expr->strings)
|
||||||
|
{
|
||||||
|
formatCapacity += string.size + std::count(string.data, string.data + string.size, '%');
|
||||||
|
}
|
||||||
|
|
||||||
std::string formatString;
|
std::string formatString;
|
||||||
|
formatString.reserve(formatCapacity);
|
||||||
|
|
||||||
size_t stringsLeft = expr->strings.size;
|
size_t stringsLeft = expr->strings.size;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue