Skip to content

Commit

Permalink
input/cache: use simpler intrusive::set API
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobvosmaer committed Dec 18, 2019
1 parent 65bbb97 commit 83acbe1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/input/cache/Manager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ InputCacheManager::Get(const char *uri, bool create)
if (!PathTraitsUTF8::IsAbsolute(uri))
return {};

UriMap::insert_commit_data hint;
auto result = items_by_uri.insert_check(uri, items_by_uri.key_comp(),
hint);
if (!result.second) {
auto &item = *result.first;
auto iter = items_by_uri.find(uri, items_by_uri.key_comp());
if (iter != items_by_uri.end()) {
auto &item = *iter;

/* refresh */
items_by_time.erase(items_by_time.iterator_to(item));
Expand All @@ -112,7 +110,7 @@ InputCacheManager::Get(const char *uri, bool create)
while (total_size > max_total_size && EvictOldestUnused()) {}

auto *item = new InputCacheItem(std::move(is));
items_by_uri.insert_commit(*item, hint);
items_by_uri.insert(*item);
items_by_time.push_back(*item);

return InputCacheLease(*item);
Expand Down

0 comments on commit 83acbe1

Please sign in to comment.