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
parent 55cec53911
commit c4dd3ffaf6
3 changed files with 12 additions and 4 deletions

View File

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

View File

@ -134,6 +134,12 @@ static std::string prefPath(const char *org, const char *app)
return str; 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; typedef std::vector<std::string> StringVec;
namespace po = boost::program_options; namespace po = boost::program_options;
@ -226,7 +232,7 @@ void Config::read(int argc, char *argv[])
PO_DESC_ALL; 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>(); ); GUARD_ALL( rtps = vm["RTP"].as<StringVec>(); );

View File

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