mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-28 08:36:15 +02:00
Make EvalState::inputAccessors keyed by the accessor number
This commit is contained in:
parent
f95c425db1
commit
30be6445e6
3 changed files with 7 additions and 11 deletions
|
@ -135,21 +135,15 @@ std::pair<SourcePath, uint32_t> findPackageFilename(EvalState & state, Value & v
|
||||||
size_t number = std::stoi(std::string(pos, 0, slash));
|
size_t number = std::stoi(std::string(pos, 0, slash));
|
||||||
pos = pos.substr(slash);
|
pos = pos.substr(slash);
|
||||||
|
|
||||||
std::shared_ptr<InputAccessor> accessor;
|
auto accessor = state.inputAccessors.find(number);
|
||||||
for (auto & i : state.inputAccessors)
|
if (accessor == state.inputAccessors.end()) fail();
|
||||||
if (i.second->number == number) {
|
|
||||||
accessor = i.second;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!accessor) fail();
|
|
||||||
|
|
||||||
auto colon = pos.rfind(':');
|
auto colon = pos.rfind(':');
|
||||||
if (colon == std::string::npos) fail();
|
if (colon == std::string::npos) fail();
|
||||||
std::string filename(pos, 0, colon);
|
std::string filename(pos, 0, colon);
|
||||||
auto lineno = std::stoi(std::string(pos, colon + 1, std::string::npos));
|
auto lineno = std::stoi(std::string(pos, colon + 1, std::string::npos));
|
||||||
|
|
||||||
return {SourcePath{ref(accessor), CanonPath(filename)}, lineno};
|
return {SourcePath{accessor->second, CanonPath(filename)}, lineno};
|
||||||
|
|
||||||
} catch (std::invalid_argument & e) {
|
} catch (std::invalid_argument & e) {
|
||||||
fail();
|
fail();
|
||||||
|
|
|
@ -114,7 +114,9 @@ public:
|
||||||
|
|
||||||
const SourcePath derivationInternal;
|
const SourcePath derivationInternal;
|
||||||
|
|
||||||
std::unordered_map<InputAccessor *, ref<InputAccessor>> inputAccessors;
|
/* A map keyed by InputAccessor::number that keeps input accessors
|
||||||
|
alive. */
|
||||||
|
std::unordered_map<size_t, ref<InputAccessor>> inputAccessors;
|
||||||
|
|
||||||
/* Store used to materialise .drv files. */
|
/* Store used to materialise .drv files. */
|
||||||
const ref<Store> store;
|
const ref<Store> store;
|
||||||
|
|
|
@ -11,7 +11,7 @@ SourcePath EvalState::rootPath(const Path & path)
|
||||||
|
|
||||||
void EvalState::registerAccessor(ref<InputAccessor> accessor)
|
void EvalState::registerAccessor(ref<InputAccessor> accessor)
|
||||||
{
|
{
|
||||||
inputAccessors.emplace(&*accessor, accessor);
|
inputAccessors.emplace(accessor->number, accessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue