Skip to content

Commit e8912c0

Browse files
committed
symbol-table: reference entries instead of allocating Values
1 parent ade063d commit e8912c0

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

src/libexpr/eval.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,6 @@ void Value::mkStringMove(const char * s, const NixStringContext & context)
919919
mkString(s, encodeContext(context));
920920
}
921921

922-
void Value::mkString(const SymbolStr & s)
923-
{
924-
mkString(s.c_str(), nullptr);
925-
}
926-
927922
void Value::mkPath(const SourcePath & path)
928923
{
929924
mkPath(&*path.accessor, makeImmutableString(path.path.abs()));

src/libexpr/include/nix/expr/value.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ struct ExprLambda;
6464
struct ExprBlackHole;
6565
struct PrimOp;
6666
class Symbol;
67-
class SymbolStr;
6867
class PosIdx;
6968
struct Pos;
7069
class StorePath;
@@ -331,8 +330,6 @@ public:
331330

332331
void mkStringMove(const char * s, const NixStringContext & context);
333332

334-
void mkString(const SymbolStr & s);
335-
336333
void mkPath(const SourcePath & path);
337334
void mkPath(std::string_view path);
338335

src/libexpr/primops.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ static void prim_attrNames(EvalState & state, const PosIdx pos, Value * * args,
27102710
auto list = state.buildList(args[0]->attrs()->size());
27112711

27122712
for (const auto & [n, i] : enumerate(*args[0]->attrs()))
2713-
(list[n] = state.allocValue())->mkString(state.symbols[i.name]);
2713+
list[n] = state.symbols[i.name].value_ptr();
27142714

27152715
std::sort(list.begin(), list.end(),
27162716
[](Value * v1, Value * v2) { return strcmp(v1->c_str(), v2->c_str()) < 0; });
@@ -3170,9 +3170,8 @@ static void prim_mapAttrs(EvalState & state, const PosIdx pos, Value * * args, V
31703170
auto attrs = state.buildBindings(args[1]->attrs()->size());
31713171

31723172
for (auto & i : *args[1]->attrs()) {
3173-
Value * vName = state.allocValue();
3173+
Value * vName = state.symbols[i.name].value_ptr();
31743174
Value * vFun2 = state.allocValue();
3175-
vName->mkString(state.symbols[i.name]);
31763175
vFun2->mkApp(args[0], vName);
31773176
attrs.alloc(i.name).mkApp(vFun2, i.value);
31783177
}
@@ -3236,8 +3235,7 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value * * arg
32363235
auto attrs = state.buildBindings(attrsSeen.size());
32373236

32383237
for (auto & [sym, elem] : attrsSeen) {
3239-
auto name = state.allocValue();
3240-
name->mkString(state.symbols[sym]);
3238+
auto name = state.symbols[sym].value_ptr();
32413239
auto call1 = state.allocValue();
32423240
call1->mkApp(args[0], name);
32433241
auto call2 = state.allocValue();

0 commit comments

Comments
 (0)