diff --git a/src/cache.cc b/src/cache.cc index a5905dab..e9af9179 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -18,7 +18,7 @@ std::string GetCachedBaseFileName(Config* config, size_t len = config->projectRoot.size(); if (StartsWith(source_file, config->projectRoot)) { cache_file = EscapeFileName(config->projectRoot) + '/' + - EscapeFileName(source_file.substr(len)); + EscapeFileName(source_file.substr(len)); } else cache_file = EscapeFileName(source_file); @@ -32,8 +32,8 @@ std::unique_ptr LoadCachedIndex(Config* config, if (!config->enableCacheRead) return nullptr; - optional file_content = ReadContent( - GetCachedBaseFileName(config, filename) + ".json"); + optional file_content = + ReadContent(GetCachedBaseFileName(config, filename) + ".json"); if (!file_content) return nullptr; @@ -52,8 +52,7 @@ void WriteToCache(Config* config, IndexFile& file) { if (!config->enableCacheWrite) return; - std::string cache_basename = - GetCachedBaseFileName(config, file.path); + std::string cache_basename = GetCachedBaseFileName(config, file.path); if (file.file_contents_.empty()) { LOG_S(ERROR) << "No cached file contents; performing potentially stale " diff --git a/src/lru_cache.h b/src/lru_cache.h index 6b3de44e..336ca514 100644 --- a/src/lru_cache.h +++ b/src/lru_cache.h @@ -9,7 +9,8 @@ template struct LruCache { explicit LruCache(int max_entries); - // Fetches an entry for |key|. If it does not exist, |allocator| will be invoked to create one. + // Fetches an entry for |key|. If it does not exist, |allocator| will be + // invoked to create one. template std::shared_ptr Get(const TKey& key, TAllocator allocator); // Fetches the entry for |filename| and updates it's usage so it is less @@ -47,7 +48,8 @@ LruCache::LruCache(int max_entries) : max_entries_(max_entries) { template template -std::shared_ptr LruCache::Get(const TKey& key, TAllocator allocator) { +std::shared_ptr LruCache::Get(const TKey& key, + TAllocator allocator) { std::shared_ptr result = TryGet(key); if (!result) Insert(key, result = allocator()); @@ -82,7 +84,8 @@ std::shared_ptr LruCache::TryTake(const TKey& key) { } template -void LruCache::Insert(const TKey& key, const std::shared_ptr& value) { +void LruCache::Insert(const TKey& key, + const std::shared_ptr& value) { if (entries_.size() >= max_entries_) { // Find entry with the lowest score. size_t lowest_idx = 0; @@ -113,9 +116,8 @@ void LruCache::IncrementScore() { // Overflow. if (next_score_ == 0) { - std::sort(entries_.begin(), entries_.end(), [](const Entry& a, const Entry& b) { - return a.score < b.score; - }); + std::sort(entries_.begin(), entries_.end(), + [](const Entry& a, const Entry& b) { return a.score < b.score; }); for (Entry& entry : entries_) entry.score = next_score_++; }