replace std::vector::push_back with emplace_back

This commit is contained in:
Bernd Amend 2021-05-22 13:16:44 +02:00
parent 964a36bdcd
commit 52a9fa47c1
2 changed files with 8 additions and 8 deletions

View File

@ -282,19 +282,19 @@ int main(int argc, char *argv[])
#endif #endif
std::vector<std::string> usepaths; std::vector<std::string> usepaths;
usepaths.push_back(""); usepaths.emplace_back("");
if (usepath != nullptr) if (usepath != nullptr)
{ {
usepaths.push_back(usepath); usepaths.emplace_back(usepath);
} }
std::vector<std::string> modulepaths; std::vector<std::string> modulepaths;
std::vector<std::string> searchpaths = default_search_paths(); std::vector<std::string> searchpaths = default_search_paths();
modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end()); modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end());
modulepaths.push_back(""); modulepaths.emplace_back("");
if (modulepath != nullptr) if (modulepath != nullptr)
{ {
modulepaths.push_back(modulepath); modulepaths.emplace_back(modulepath);
} }
chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser(),modulepaths,usepaths); chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser(),modulepaths,usepaths);

View File

@ -53,10 +53,10 @@ int main()
#endif #endif
std::vector<std::string> usepaths; std::vector<std::string> usepaths;
usepaths.push_back(""); usepaths.emplace_back("");
if (usepath) if (usepath)
{ {
usepaths.push_back(usepath); usepaths.emplace_back(usepath);
} }
std::vector<std::string> modulepaths; std::vector<std::string> modulepaths;
@ -64,10 +64,10 @@ int main()
#ifdef CHAISCRIPT_NO_DYNLOAD #ifdef CHAISCRIPT_NO_DYNLOAD
chaiscript::ChaiScript chai(/* unused */modulepaths, usepaths); chaiscript::ChaiScript chai(/* unused */modulepaths, usepaths);
#else #else
modulepaths.push_back(""); modulepaths.emplace_back("");
if (modulepath) if (modulepath)
{ {
modulepaths.push_back(modulepath); modulepaths.emplace_back(modulepath);
} }
// For this test we are going to load the dynamic stdlib // For this test we are going to load the dynamic stdlib