diff options
author | Nico Weber <thakis@chromium.org> | 2014-06-15 04:38:44 (GMT) |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2014-06-15 21:13:21 (GMT) |
commit | f5f7c80897cbe2d7dca454283e4e9c5e484dfadb (patch) | |
tree | 2d0e16d7cccb2460160131383b8a9014fe9a8843 /src/disk_interface.cc | |
parent | 20e03b33a340bbc709b0ecd8c50a4b55e709322b (diff) | |
download | Ninja-f5f7c80897cbe2d7dca454283e4e9c5e484dfadb.zip Ninja-f5f7c80897cbe2d7dca454283e4e9c5e484dfadb.tar.gz Ninja-f5f7c80897cbe2d7dca454283e4e9c5e484dfadb.tar.bz2 |
more minor cleanups
Diffstat (limited to 'src/disk_interface.cc')
-rw-r--r-- | src/disk_interface.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc index f211698..784f5d5 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -150,17 +150,13 @@ TimeStamp RealDiskInterface::Stat(const string& path) { transform(base.begin(), base.end(), base.begin(), ::tolower); Cache::iterator ci = cache_.find(dir); - if (ci != cache_.end()) { - DirCache::iterator di = ci->second->find(base); - return di != ci->second->end() ? di->second : 0; + if (ci == cache_.end()) { + DirCache* dc = new DirCache; + StatAllFilesInDir(dir.empty() ? "." : dir, dc); + ci = cache_.insert(make_pair(dir, dc)).first; } - - DirCache* dc = new DirCache; - StatAllFilesInDir(dir.empty() ? "." : dir, dc); - cache_.insert(make_pair(dir, dc)); - - DirCache::iterator di = dc->find(base); - return di != dc->end() ? di->second : 0; + DirCache::iterator di = ci->second->find(base); + return di != ci->second->end() ? di->second : 0; #else struct stat st; if (stat(path.c_str(), &st) < 0) { |