diff options
author | pennae <github@quasiparticle.net> | 2022-03-04 19:31:59 +0100 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-04-21 21:46:06 +0200 |
commit | 6526d1676ba5a645f65d751e7529ccd273579017 (patch) | |
tree | 62e94d270447a99ba7ea4a4093b6235c721f1985 /src/libcmd | |
parent | 34b72775cfe755db1bc61cb950c25759c0694be4 (diff) |
replace most Pos objects/ptrs with indexes into a position table
Pos objects are somewhat wasteful as they duplicate the origin file name and
input type for each object. on files that produce more than one Pos when parsed
this a sizeable waste of memory (one pointer per Pos). the same goes for
ptr<Pos> on 64 bit machines: parsing enough source to require 8 bytes to locate
a position would need at least 8GB of input and 64GB of expression memory. it's
not likely that we'll hit that any time soon, so we can use a uint32_t index to
locate positions instead.
Diffstat (limited to 'src/libcmd')
-rw-r--r-- | src/libcmd/installables.cc | 4 | ||||
-rw-r--r-- | src/libcmd/installables.hh | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 4250c321e..6197f4be4 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -473,7 +473,7 @@ struct InstallableAttrPath : InstallableValue std::string what() const override { return attrPath; } - std::pair<Value *, Pos> toValue(EvalState & state) override + std::pair<Value *, PosIdx> toValue(EvalState & state) override { auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v); state.forceValue(*vRes, pos); @@ -613,7 +613,7 @@ std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations() return res; } -std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state) +std::pair<Value *, PosIdx> InstallableFlake::toValue(EvalState & state) { return {&getCursor(state)->forceValue(), noPos}; } diff --git a/src/libcmd/installables.hh b/src/libcmd/installables.hh index b847f8939..de8b08525 100644 --- a/src/libcmd/installables.hh +++ b/src/libcmd/installables.hh @@ -68,7 +68,7 @@ struct Installable UnresolvedApp toApp(EvalState & state); - virtual std::pair<Value *, Pos> toValue(EvalState & state) + virtual std::pair<Value *, PosIdx> toValue(EvalState & state) { throw Error("argument '%s' cannot be evaluated", what()); } @@ -178,7 +178,7 @@ struct InstallableFlake : InstallableValue std::vector<DerivationInfo> toDerivations() override; - std::pair<Value *, Pos> toValue(EvalState & state) override; + std::pair<Value *, PosIdx> toValue(EvalState & state) override; /* Get a cursor to every attrpath in getActualAttrPaths() that exists. */ |