1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

In EvalState::concatLists, local variable s -> strings

It deserves a better name.

Co-Authored-By: Aspen Smith <root@gws.fyi>
This commit is contained in:
John Ericson 2025-11-01 13:41:50 -04:00
parent 0ba1aa34dc
commit ca9fde1b88

View file

@ -2021,7 +2021,7 @@ void EvalState::concatLists(
void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v) void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
{ {
NixStringContext context; NixStringContext context;
std::vector<BackedStringView> s; std::vector<BackedStringView> strings;
size_t sSize = 0; size_t sSize = 0;
NixInt n{0}; NixInt n{0};
NixFloat nf = 0; NixFloat nf = 0;
@ -2032,7 +2032,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
const auto str = [&] { const auto str = [&] {
std::string result; std::string result;
result.reserve(sSize); result.reserve(sSize);
for (const auto & part : s) for (const auto & part : strings)
result += *part; result += *part;
return result; return result;
}; };
@ -2042,7 +2042,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
const auto c_str = [&] { const auto c_str = [&] {
char * result = allocString(sSize + 1); char * result = allocString(sSize + 1);
char * tmp = result; char * tmp = result;
for (const auto & part : s) { for (const auto & part : strings) {
memcpy(tmp, part->data(), part->size()); memcpy(tmp, part->data(), part->size());
tmp += part->size(); tmp += part->size();
} }
@ -2097,15 +2097,15 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
.withFrame(env, *this) .withFrame(env, *this)
.debugThrow(); .debugThrow();
} else { } else {
if (s.empty()) if (strings.empty())
s.reserve(es.size()); strings.reserve(es.size());
/* skip canonization of first path, which would only be not /* skip canonization of first path, which would only be not
canonized in the first place if it's coming from a ./${foo} type canonized in the first place if it's coming from a ./${foo} type
path */ path */
auto part = state.coerceToString( auto part = state.coerceToString(
i_pos, vTmp, context, "while evaluating a path segment", false, firstType == nString, !first); i_pos, vTmp, context, "while evaluating a path segment", false, firstType == nString, !first);
sSize += part->size(); sSize += part->size();
s.emplace_back(std::move(part)); strings.emplace_back(std::move(part));
} }
first = false; first = false;