Config: Use set for preloadScripts

Would probably make sense for all other string vectors too.
This commit is contained in:
Jonas Kulla 2017-03-03 19:37:19 +01:00 committed by Marty Plummer
parent 55cec53911
commit a819cb54a6
3 changed files with 12 additions and 4 deletions

View File

@ -452,8 +452,9 @@ static void runRMXPScripts(BacktraceData &btData)
}
/* Execute preloaded scripts */
for (size_t i = 0; i < conf.preloadScripts.size(); ++i)
runCustomScript(conf.preloadScripts[i]);
for (std::set<std::string>::iterator i = conf.preloadScripts.begin();
i != conf.preloadScripts.end(); ++i)
runCustomScript(*i);
VALUE exc = rb_gv_get("$!");
if (exc != Qnil)

View File

@ -134,6 +134,12 @@ static std::string prefPath(const char *org, const char *app)
return str;
}
template<typename T>
std::set<T> setFromVec(const std::vector<T> &vec)
{
return std::set<T>(vec.begin(), vec.end());
}
typedef std::vector<std::string> StringVec;
namespace po = boost::program_options;
@ -226,7 +232,7 @@ void Config::read(int argc, char *argv[])
PO_DESC_ALL;
GUARD_ALL( preloadScripts = vm["preloadScript"].as<StringVec>(); );
GUARD_ALL( preloadScripts = setFromVec(vm["preloadScript"].as<StringVec>()); );
GUARD_ALL( rtps = vm["RTP"].as<StringVec>(); );

View File

@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <set>
struct Config
{
@ -77,7 +78,7 @@ struct Config
bool useScriptNames;
std::string customScript;
std::vector<std::string> preloadScripts;
std::set<std::string> preloadScripts;
std::vector<std::string> rtps;
std::vector<std::string> fontSubs;