PLUGINS: In uncached mode, try plugin which matches engine name first

Trying all engine plugins in alphabetical order is a time consuming
process, so start by trying the plugin which has the same name as the
engine id first, if it exists, as it will usually be the right one.

In the rare case that it would be the wrong one there is no problem;
the code will simply fall through to the old scanning and then record
the correct plugin in the engine_plugin_files domain where it will be
found the next time the plugin is needed.
This commit is contained in:
Marcus Comstedt 2021-09-20 23:12:49 +02:00
parent da5e8c667d
commit e8ed75d884

View file

@ -409,6 +409,20 @@ bool PluginManagerUncached::loadPluginFromEngineId(const Common::String &engineI
}
}
}
// Check for a plugin with the same name as the engine before starting
// to scan all plugins
Common::String tentativeEnginePluginFilename = engineId;
#ifdef PLUGIN_SUFFIX
tentativeEnginePluginFilename += PLUGIN_SUFFIX;
#endif
for (PluginList::iterator p = _allEnginePlugins.begin(); p != _allEnginePlugins.end(); ++p) {
Common::String filename = (*p)->getFileName();
if (filename.hasSuffixIgnoreCase(tentativeEnginePluginFilename)) {
if (loadPluginByFileName(filename)) {
return true;
}
}
}
return false;
}