From 387233e9e3603eb7d346eb351f0c70c84a956a10 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sun, 6 Jun 2021 22:41:40 -0500 Subject: [PATCH] Don't store key in asset lookup cache --- include/aoapplication.h | 4 ++-- src/path_functions.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 24a09ec..e800bb5 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_list; QVector favorite_list; - QHash asset_lookup_cache; + QHash 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 dd65204..66b0a5b 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 listing_cache; static QHash 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; } }