diff options
author | Willem Jan Palenstijn | 2008-11-21 13:29:53 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2008-11-21 13:29:53 +0000 |
commit | 196e2cc92c894ea9449c96a10f2373fd605cc2dc (patch) | |
tree | 040c4e2d182fbbc8e3ace96b02b9a1d4328160be /common | |
parent | a28b531ed0a984aa89a6cbc55c0314ad52f304fb (diff) | |
download | scummvm-rg350-196e2cc92c894ea9449c96a10f2373fd605cc2dc.tar.gz scummvm-rg350-196e2cc92c894ea9449c96a10f2373fd605cc2dc.tar.bz2 scummvm-rg350-196e2cc92c894ea9449c96a10f2373fd605cc2dc.zip |
refactor inconsistent calls to cacheDirectoryRecursive
svn-id: r35140
Diffstat (limited to 'common')
-rw-r--r-- | common/archive.cpp | 17 | ||||
-rw-r--r-- | common/archive.h | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/common/archive.cpp b/common/archive.cpp index 85586c2820..ce640557e7 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -127,10 +127,7 @@ FSNode FSDirectory::getFSNode() const { FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) { // make caching as lazy as possible if (!name.empty()) { - if (!_cached) { - cacheDirectoryRecursive(_node, _depth, _prefix); - _cached = true; - } + ensureCached(); if (cache.contains(name)) return cache[name]; @@ -237,15 +234,19 @@ void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& } +void FSDirectory::ensureCached() +{ + if (_cached) return; + cacheDirectoryRecursive(_node, _depth, _prefix); + _cached = true; +} + int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) { if (!_node.isDirectory()) return 0; // Cache dir data - if (!_cached) { - cacheDirectoryRecursive(_node, _depth, ""); - _cached = true; - } + ensureCached(); String lowercasePattern(pattern); lowercasePattern.toLowercase(); diff --git a/common/archive.h b/common/archive.h index a11d02e5af..90983ba9c7 100644 --- a/common/archive.h +++ b/common/archive.h @@ -165,6 +165,8 @@ class FSDirectory : public Archive { // cache management void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix); + // fill cache if not already cached + void ensureCached(); bool _cached; int _depth; |