aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-06-06 22:41:40 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2021-06-06 22:41:40 -0500
commit387233e9e3603eb7d346eb351f0c70c84a956a10 (patch)
tree518a71de24555f0e56a2d0610494ffd6617a6c4b
parent7a1c3f385e5fc7f0fdcde60543d32795ea64e0fc (diff)
Don't store key in asset lookup cache
-rw-r--r--include/aoapplication.h4
-rw-r--r--src/path_functions.cpp14
2 files changed, 8 insertions, 10 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h
index 24a09eca..e800bb5c 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -51,7 +51,7 @@ public:
}
};
-inline uint qHash(const VPath &key, uint seed)
+inline uint qHash(const VPath &key, uint seed = qGlobalQHashSeed())
{
return qHash(key.toQString(), seed);
}
@@ -541,7 +541,7 @@ private:
QVector<server_type> server_list;
QVector<server_type> favorite_list;
- QHash<VPath, QString> asset_lookup_cache;
+ QHash<uint, QString> asset_lookup_cache;
private slots:
void ms_connect_finished(bool connected, bool will_retry);
diff --git a/src/path_functions.cpp b/src/path_functions.cpp
index dd652044..66b0a5b1 100644
--- a/src/path_functions.cpp
+++ b/src/path_functions.cpp
@@ -204,9 +204,6 @@ QString AOApplication::get_case_sensitive_path(QString p_file)
return file_parent_dir + "/" + file_basename;
// last resort, dirlist parent dir and find case insensitive match
- QRegExp file_rx =
- QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString);
-
static QHash<uint, QString> listing_cache;
static QHash<uint, bool> listing_exist_cache;
@@ -217,7 +214,8 @@ QString AOApplication::get_case_sensitive_path(QString p_file)
}
listing_exist_cache.insert(qHash(file_parent_dir), true);
}
- QString found_file = listing_cache.value(qHash(file_parent_dir % QChar('/') % file_basename.toLower()));
+ QString found_file = listing_cache.value(
+ qHash(file_parent_dir % QChar('/') % file_basename.toLower()));
if (!found_file.isEmpty()) {
return file_parent_dir + "/" + found_file;
@@ -232,7 +230,7 @@ QString AOApplication::get_case_sensitive_path(QString p_file)
QString AOApplication::get_real_path(const VPath &vpath) {
// Try cache first
- QString phys_path = asset_lookup_cache.value(vpath);
+ QString phys_path = asset_lookup_cache.value(qHash(vpath));
if (!phys_path.isEmpty() && exists(phys_path)) {
return phys_path;
}
@@ -249,7 +247,7 @@ QString AOApplication::get_real_path(const VPath &vpath) {
break;
}
if (exists(get_case_sensitive_path(path))) {
- asset_lookup_cache.insert(vpath, path);
+ asset_lookup_cache.insert(qHash(vpath), path);
return path;
}
}
@@ -263,7 +261,7 @@ QString AOApplication::get_real_path(const VPath &vpath) {
QString AOApplication::get_real_suffixed_path(const VPath &vpath,
const QStringList &suffixes) {
// Try cache first
- QString phys_path = asset_lookup_cache.value(vpath);
+ QString phys_path = asset_lookup_cache.value(qHash(vpath));
if (!phys_path.isEmpty() && exists(phys_path)) {
return phys_path;
}
@@ -281,7 +279,7 @@ QString AOApplication::get_real_suffixed_path(const VPath &vpath,
break;
}
if (exists(get_case_sensitive_path(path))) {
- asset_lookup_cache.insert(vpath, path);
+ asset_lookup_cache.insert(qHash(vpath), path);
return path;
}
}