aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/archive.cpp17
-rw-r--r--common/archive.h2
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;