mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 08:12:29 +00:00
Faster flake.lock parsing
This PR reduces the creation of short-lived basic_json objects while parsing flake.lock files. For large flake.lock files (~1.5MB) I was observing ~60s being spent for trivial nix build operations while after this change it is now taking ~1.6s. (cherry picked from commit7fd0de38c6
) (cherry picked from commitf94fb636c0
)
This commit is contained in:
parent
f092ae4478
commit
2dd715ef0b
@ -89,7 +89,7 @@ LockFile::LockFile(const nlohmann::json & json, const Path & path)
|
|||||||
std::string inputKey = i.value();
|
std::string inputKey = i.value();
|
||||||
auto k = nodeMap.find(inputKey);
|
auto k = nodeMap.find(inputKey);
|
||||||
if (k == nodeMap.end()) {
|
if (k == nodeMap.end()) {
|
||||||
auto nodes = json["nodes"];
|
auto & nodes = json["nodes"];
|
||||||
auto jsonNode2 = nodes.find(inputKey);
|
auto jsonNode2 = nodes.find(inputKey);
|
||||||
if (jsonNode2 == nodes.end())
|
if (jsonNode2 == nodes.end())
|
||||||
throw Error("lock file references missing node '%s'", inputKey);
|
throw Error("lock file references missing node '%s'", inputKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user