build_stage_source - use std::string reserve and append, significantly

faster
This commit is contained in:
twinaphex 2021-04-10 22:10:59 +02:00
parent 0b52823f2c
commit 0aa266a6ca

View File

@ -47,10 +47,11 @@ static std::string build_stage_source(
if (lines->size < 1)
return "";
str.reserve(lines->size);
/* Version header. */
str += lines->elems[0].data;
str += '\n';
str.append(lines->elems[0].data);
str.append("\n");
for (i = 1; i < lines->size; i++)
{
@ -82,12 +83,12 @@ static std::string build_stage_source(
/* Ignore */
}
else if (active)
str += line;
str.append(line);
}
else if (active)
str += line;
str.append(line);
str += '\n';
str.append("\n");
}
return str;