diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:39:47 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:40:08 +0900 |
| commit | b1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch) | |
| tree | 9ce465b42bf09372118335c7c619bb2b41869eaf /src/WrDiskCache.cc | |
| parent | 4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff) | |
make clang-format using clang-format-3.6
Diffstat (limited to 'src/WrDiskCache.cc')
| -rw-r--r-- | src/WrDiskCache.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/WrDiskCache.cc b/src/WrDiskCache.cc index 9db39fe2..5bc57273 100644 --- a/src/WrDiskCache.cc +++ b/src/WrDiskCache.cc @@ -42,15 +42,11 @@ namespace aria2 { -WrDiskCache::WrDiskCache(size_t limit) - : limit_(limit), - total_(0), - clock_(0) -{} +WrDiskCache::WrDiskCache(size_t limit) : limit_(limit), total_(0), clock_(0) {} WrDiskCache::~WrDiskCache() { - if(total_) { + if (total_) { A2_LOG_WARN(fmt("Write disk cache is not empty size=%lu", static_cast<unsigned long>(total_))); } @@ -61,11 +57,12 @@ bool WrDiskCache::add(WrDiskCacheEntry* ent) ent->setSizeKey(ent->getSize()); ent->setLastUpdate(++clock_); std::pair<EntrySet::iterator, bool> rv = set_.insert(ent); - if(rv.second) { + if (rv.second) { total_ += ent->getSize(); ensureLimit(); return true; - } else { + } + else { A2_LOG_WARN(fmt("Found duplicate cache entry a.{size=%lu,clock=%" PRId64 "} b{size=%lu,clock=%" PRId64 "}", static_cast<unsigned long>((*rv.first)->getSize()), @@ -78,32 +75,32 @@ bool WrDiskCache::add(WrDiskCacheEntry* ent) bool WrDiskCache::remove(WrDiskCacheEntry* ent) { - if(set_.erase(ent)) { + if (set_.erase(ent)) { A2_LOG_DEBUG(fmt("Removed cache entry size=%lu, clock=%" PRId64, static_cast<unsigned long>(ent->getSize()), ent->getLastUpdate())); total_ -= ent->getSize(); return true; - } else { + } + else { return false; } } bool WrDiskCache::update(WrDiskCacheEntry* ent, ssize_t delta) { - if(!set_.erase(ent)) { + if (!set_.erase(ent)) { return false; } A2_LOG_DEBUG(fmt("Update cache entry size=%lu, delta=%ld, clock=%" PRId64, static_cast<unsigned long>(ent->getSize()), - static_cast<long>(delta), - ent->getLastUpdate())); + static_cast<long>(delta), ent->getLastUpdate())); ent->setSizeKey(ent->getSize()); ent->setLastUpdate(++clock_); set_.insert(ent); - if(delta < 0) { + if (delta < 0) { assert(total_ >= static_cast<size_t>(-delta)); } total_ += delta; @@ -113,7 +110,7 @@ bool WrDiskCache::update(WrDiskCacheEntry* ent, ssize_t delta) void WrDiskCache::ensureLimit() { - while(total_ > limit_) { + while (total_ > limit_) { auto i = set_.begin(); WrDiskCacheEntry* ent = *i; A2_LOG_DEBUG(fmt("Force flush cache entry size=%lu, clock=%" PRId64, |
