[Scummvm-git-logs] scummvm master -> 36a5797bae505e2cb0bf4845d666a9eb188d577c
sev-
sev at scummvm.org
Fri May 14 20:35:28 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
45aa165b80 Modify getFileProperties to cache md5 results
bad9008a89 DETECTOR: Modify getFileProperties to cache md5 results
eba9fa8f30 DETECTOR: Use Common::String::format for performance
36a5797bae DETECTOR: Clear md5 cache before detection as well
Commit: 45aa165b80cf80aa30fb1fbced13b2937b0c002a
https://github.com/scummvm/scummvm/commit/45aa165b80cf80aa30fb1fbced13b2937b0c002a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-05-14T22:35:23+02:00
Commit Message:
Modify getFileProperties to cache md5 results
Changed paths:
engines/advancedDetector.cpp
engines/metaengine.h
gui/launcher.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index e129597823..c799607192 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -450,9 +450,31 @@ void AdvancedMetaEngineDetection::composeFileHashMap(FileMap &allFiles, const Co
}
}
+/* Singleton Cache Storage for MD5 */
+
+namespace Common {
+ DECLARE_SINGLETON(MD5CacheManager);
+}
+
bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const {
// FIXME/TODO: We don't handle the case that a file is listed as a regular
// file and as one with resource fork.
+ if (!allFiles.contains(fname))
+ return false;
+
+ fileProps.md5.clear();
+
+ const char *numbers = "0123456789";
+ Common::String hashname = allFiles[fname].getPath() + ":";
+ for (uint n = _md5Bytes; n > 0; n/=10) {
+ hashname += numbers[n % 10];
+ }
+
+ if (MD5Man.contains(hashname)) {
+ fileProps.md5 = MD5Man.getMD5(hashname);
+ fileProps.size = MD5Man.getSize(hashname);
+ return true;
+ }
if (game.flags & ADGF_MACRESFORK) {
FileMapArchive fileMapArchive(allFiles);
@@ -465,20 +487,23 @@ bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, con
fileProps.md5 = macResMan.computeResForkMD5AsString(_md5Bytes);
fileProps.size = macResMan.getResForkDataSize();
- if (fileProps.size != 0)
+ if (fileProps.size != 0) {
+ MD5Man.setMD5(hashname, fileProps.md5);
+ MD5Man.setSize(hashname, fileProps.size);
return true;
+ }
}
- if (!allFiles.contains(fname))
- return false;
-
Common::File testFile;
if (!testFile.open(allFiles[fname]))
return false;
- fileProps.size = (int32)testFile.size();
fileProps.md5 = Common::computeStreamMD5AsString(testFile, _md5Bytes);
+ fileProps.size = (int32)testFile.size();
+ MD5Man.setMD5(hashname, fileProps.md5);
+ MD5Man.setSize(hashname, fileProps.size);
+
return true;
}
diff --git a/engines/metaengine.h b/engines/metaengine.h
index b4075be976..eeff7cf7bc 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -567,5 +567,51 @@ private:
/** Convenience shortcut for accessing the engine manager. */
#define EngineMan EngineManager::instance()
+
+/**
+ * Singleton Cache Storage for Computed MD5s
+ */
+class MD5CacheManager : public Common::Singleton<MD5CacheManager> {
+public:
+ void setMD5(Common::String fname, Common::String md5) {
+ md5HashMap.setVal(fname, md5);
+ }
+
+ Common::String getMD5(Common::String fname) {
+ return md5HashMap.getVal(fname);
+ }
+
+ void setSize(Common::String fname, int32 size) {
+ sizeHashMap.setVal(fname, size);
+ }
+
+ int32 getSize(Common::String fname) {
+ return sizeHashMap.getVal(fname);
+ }
+
+ bool contains(Common::String fname) {
+ return (md5HashMap.contains(fname) && sizeHashMap.contains(fname));
+ }
+
+ MD5CacheManager() {
+ clear();
+ }
+
+ void clear() {
+ md5HashMap.clear(true);
+ sizeHashMap.clear(true);
+ }
+
+private:
+ friend class Common::Singleton<MD5CacheManager>;
+
+ typedef Common::HashMap<Common::String, Common::String, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileHashMap;
+ typedef Common::HashMap<Common::String, int32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> SizeHashMap;
+ FileHashMap md5HashMap;
+ SizeHashMap sizeHashMap;
+};
+
+/** Convenience shortcut for accessing the MD5CacheManager. */
+#define MD5Man MD5CacheManager::instance()
/** @} */
#endif
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 499f30b508..54c733c520 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -393,6 +393,7 @@ void LauncherDialog::massAddGame() {
MessageDialog alert(_("Do you really want to run the mass game detector? "
"This could potentially add a huge number of games."), _("Yes"), _("No"));
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
+ MD5Man.clear();
MassAddDialog massAddDlg(_browser->getResult());
massAddDlg.runModal();
Commit: bad9008a8959eda950a43b2fe335aaf41c439994
https://github.com/scummvm/scummvm/commit/bad9008a8959eda950a43b2fe335aaf41c439994
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-05-14T22:35:23+02:00
Commit Message:
DETECTOR: Modify getFileProperties to cache md5 results
Changed paths:
engines/advancedDetector.h
engines/metaengine.h
gui/launcher.cpp
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 31af9cd690..cb008b1b35 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -500,5 +500,51 @@ public:
*/
bool getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const;
};
+
+/**
+ * Singleton Cache Storage for Computed MD5s
+ */
+class MD5CacheManager : public Common::Singleton<MD5CacheManager> {
+public:
+ void setMD5(Common::String fname, Common::String md5) {
+ md5HashMap.setVal(fname, md5);
+ }
+
+ Common::String getMD5(Common::String fname) {
+ return md5HashMap.getVal(fname);
+ }
+
+ void setSize(Common::String fname, int32 size) {
+ sizeHashMap.setVal(fname, size);
+ }
+
+ int32 getSize(Common::String fname) {
+ return sizeHashMap.getVal(fname);
+ }
+
+ bool contains(Common::String fname) {
+ return (md5HashMap.contains(fname) && sizeHashMap.contains(fname));
+ }
+
+ MD5CacheManager() {
+ clear();
+ }
+
+ void clear() {
+ md5HashMap.clear(true);
+ sizeHashMap.clear(true);
+ }
+
+private:
+ friend class Common::Singleton<MD5CacheManager>;
+
+ typedef Common::HashMap<Common::String, Common::String, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileHashMap;
+ typedef Common::HashMap<Common::String, int32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> SizeHashMap;
+ FileHashMap md5HashMap;
+ SizeHashMap sizeHashMap;
+};
+
+/** Convenience shortcut for accessing the MD5CacheManager. */
+#define MD5Man MD5CacheManager::instance()
/** @} */
#endif
diff --git a/engines/metaengine.h b/engines/metaengine.h
index eeff7cf7bc..b4075be976 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -567,51 +567,5 @@ private:
/** Convenience shortcut for accessing the engine manager. */
#define EngineMan EngineManager::instance()
-
-/**
- * Singleton Cache Storage for Computed MD5s
- */
-class MD5CacheManager : public Common::Singleton<MD5CacheManager> {
-public:
- void setMD5(Common::String fname, Common::String md5) {
- md5HashMap.setVal(fname, md5);
- }
-
- Common::String getMD5(Common::String fname) {
- return md5HashMap.getVal(fname);
- }
-
- void setSize(Common::String fname, int32 size) {
- sizeHashMap.setVal(fname, size);
- }
-
- int32 getSize(Common::String fname) {
- return sizeHashMap.getVal(fname);
- }
-
- bool contains(Common::String fname) {
- return (md5HashMap.contains(fname) && sizeHashMap.contains(fname));
- }
-
- MD5CacheManager() {
- clear();
- }
-
- void clear() {
- md5HashMap.clear(true);
- sizeHashMap.clear(true);
- }
-
-private:
- friend class Common::Singleton<MD5CacheManager>;
-
- typedef Common::HashMap<Common::String, Common::String, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileHashMap;
- typedef Common::HashMap<Common::String, int32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> SizeHashMap;
- FileHashMap md5HashMap;
- SizeHashMap sizeHashMap;
-};
-
-/** Convenience shortcut for accessing the MD5CacheManager. */
-#define MD5Man MD5CacheManager::instance()
/** @} */
#endif
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 54c733c520..1d0011cbe0 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -51,6 +51,7 @@
#include "gui/widgets/tab.h"
#include "gui/widgets/popup.h"
#include "gui/ThemeEval.h"
+#include "engines/advancedDetector.h"
#include "graphics/cursorman.h"
#if defined(USE_CLOUD) && defined(USE_LIBCURL)
Commit: eba9fa8f30ebb893c9250649075a4a2158c375be
https://github.com/scummvm/scummvm/commit/eba9fa8f30ebb893c9250649075a4a2158c375be
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-05-14T22:35:23+02:00
Commit Message:
DETECTOR: Use Common::String::format for performance
Changed paths:
engines/advancedDetector.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index c799607192..aef274cf39 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -462,13 +462,7 @@ bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, con
if (!allFiles.contains(fname))
return false;
- fileProps.md5.clear();
-
- const char *numbers = "0123456789";
- Common::String hashname = allFiles[fname].getPath() + ":";
- for (uint n = _md5Bytes; n > 0; n/=10) {
- hashname += numbers[n % 10];
- }
+ Common::String hashname = Common::String::format("%s:%d", allFiles[fname].getPath().c_str(), _md5Bytes);
if (MD5Man.contains(hashname)) {
fileProps.md5 = MD5Man.getMD5(hashname);
Commit: 36a5797bae505e2cb0bf4845d666a9eb188d577c
https://github.com/scummvm/scummvm/commit/36a5797bae505e2cb0bf4845d666a9eb188d577c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-05-14T22:35:23+02:00
Commit Message:
DETECTOR: Clear md5 cache before detection as well
Changed paths:
base/plugins.cpp
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 3e47a53717..37daf1e766 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -32,6 +32,8 @@
#include "base/detection/detection.h"
+#include "engines/advancedDetector.h"
+
// Plugin versioning
int pluginTypeVersions[PLUGIN_TYPE_MAX] = {
@@ -722,6 +724,9 @@ DetectionResults EngineManager::detectGames(const Common::FSList &fslist) const
// run detection for all of them.
plugins = getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
+ // Clear md5 cache before each detection starts, just in case.
+ MD5Man.clear();
+
// Iterate over all known games and for each check if it might be
// the game in the presented directory.
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
More information about the Scummvm-git-logs
mailing list