mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
libutil: Use heterogeneous lookup for LRUCache
This gets rid of some ugly std::string_view -> std::string conversions, which are an eye-sore and lead to extra copying.
This commit is contained in:
parent
90d70aa4c9
commit
cd61e922ff
2 changed files with 13 additions and 10 deletions
|
@ -570,7 +570,7 @@ bool Store::isValidPath(const StorePath & storePath)
|
|||
{
|
||||
{
|
||||
auto state_(state.lock());
|
||||
auto res = state_->pathInfoCache.get(std::string(storePath.to_string()));
|
||||
auto res = state_->pathInfoCache.get(storePath.to_string());
|
||||
if (res && res->isKnownNow()) {
|
||||
stats.narInfoReadAverted++;
|
||||
return res->didExist();
|
||||
|
@ -582,7 +582,7 @@ bool Store::isValidPath(const StorePath & storePath)
|
|||
if (res.first != NarInfoDiskCache::oUnknown) {
|
||||
stats.narInfoReadAverted++;
|
||||
auto state_(state.lock());
|
||||
state_->pathInfoCache.upsert(std::string(storePath.to_string()),
|
||||
state_->pathInfoCache.upsert(storePath.to_string(),
|
||||
res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{} : PathInfoCacheValue { .value = res.second });
|
||||
return res.first == NarInfoDiskCache::oValid;
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ std::optional<std::shared_ptr<const ValidPathInfo>> Store::queryPathInfoFromClie
|
|||
auto hashPart = std::string(storePath.hashPart());
|
||||
|
||||
{
|
||||
auto res = state.lock()->pathInfoCache.get(std::string(storePath.to_string()));
|
||||
auto res = state.lock()->pathInfoCache.get(storePath.to_string());
|
||||
if (res && res->isKnownNow()) {
|
||||
stats.narInfoReadAverted++;
|
||||
if (res->didExist())
|
||||
|
@ -657,7 +657,7 @@ std::optional<std::shared_ptr<const ValidPathInfo>> Store::queryPathInfoFromClie
|
|||
stats.narInfoReadAverted++;
|
||||
{
|
||||
auto state_(state.lock());
|
||||
state_->pathInfoCache.upsert(std::string(storePath.to_string()),
|
||||
state_->pathInfoCache.upsert(storePath.to_string(),
|
||||
res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{} : PathInfoCacheValue{ .value = res.second });
|
||||
if (res.first == NarInfoDiskCache::oInvalid ||
|
||||
!goodStorePath(storePath, res.second->path))
|
||||
|
@ -701,7 +701,7 @@ void Store::queryPathInfo(const StorePath & storePath,
|
|||
|
||||
{
|
||||
auto state_(state.lock());
|
||||
state_->pathInfoCache.upsert(std::string(storePath.to_string()), PathInfoCacheValue { .value = info });
|
||||
state_->pathInfoCache.upsert(storePath.to_string(), PathInfoCacheValue { .value = info });
|
||||
}
|
||||
|
||||
if (!info || !goodStorePath(storePath, info->path)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue