@@ -59,7 +59,7 @@ static void addFilesToList(const std::string& fileList, std::vector<std::string>
5959 std::string fileName;
6060 while (std::getline (*files, fileName)) { // next line
6161 if (!fileName.empty ()) {
62- pathNames.push_back (fileName);
62+ pathNames.emplace_back (fileName);
6363 }
6464 }
6565 }
@@ -79,7 +79,7 @@ static bool addIncludePathsToList(const std::string& fileList, std::list<std::st
7979 if (!endsWith (pathName, ' /' ))
8080 pathName += ' /' ;
8181
82- pathNames->push_back (pathName);
82+ pathNames->emplace_back (pathName);
8383 }
8484 }
8585 return true ;
@@ -185,7 +185,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
185185 if (!endsWith (path,' /' ))
186186 path += ' /' ;
187187
188- mSettings ->includePaths .push_back (path);
188+ mSettings ->includePaths .emplace_back (path);
189189 }
190190
191191 // User undef
@@ -207,7 +207,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
207207 undef = 2 + argv[i];
208208 }
209209
210- mSettings ->userUndefs .insert (undef);
210+ mSettings ->userUndefs .emplace (undef);
211211 }
212212
213213 else if (std::strncmp (argv[i], " --addon=" , 8 ) == 0 )
@@ -231,9 +231,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
231231 mSettings ->clang = true ;
232232
233233 else if (std::strncmp (argv[i], " --config-exclude=" ,17 ) ==0 ) {
234- std::string path = argv[i] + 17 ;
235- path = Path::fromNativeSeparators (path);
236- mSettings ->configExcludePaths .insert (path);
234+ mSettings ->configExcludePaths .emplace (Path::fromNativeSeparators (argv[i] + 17 ));
237235 }
238236
239237 else if (std::strncmp (argv[i], " --config-excludes-file=" , 23 ) == 0 ) {
@@ -354,7 +352,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
354352
355353 // use a file filter
356354 else if (std::strncmp (argv[i], " --file-filter=" , 14 ) == 0 )
357- mSettings ->fileFilter = std::string ( argv[i] + 14 ) ;
355+ mSettings ->fileFilter = argv[i] + 14 ;
358356
359357 // file list specified
360358 else if (std::strncmp (argv[i], " --file-list=" , 12 ) == 0 )
@@ -402,14 +400,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
402400 if (!endsWith (path, ' /' ))
403401 path += ' /' ;
404402 }
405- mIgnoredPaths .push_back (path);
403+ mIgnoredPaths .emplace_back (path);
406404 }
407405 }
408406
409407 else if (std::strncmp (argv[i], " --include=" , 10 ) == 0 ) {
410- std::string path = argv[i] + 10 ;
411- path = Path::fromNativeSeparators (path);
412- mSettings ->userIncludes .push_back (path);
408+ mSettings ->userIncludes .emplace_back (Path::fromNativeSeparators (argv[i] + 10 ));
413409 }
414410
415411 else if (std::strncmp (argv[i], " --includes-file=" , 16 ) == 0 ) {
@@ -513,8 +509,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
513509
514510 // --library
515511 else if (std::strncmp (argv[i], " --library=" , 10 ) == 0 ) {
516- std::string lib (argv[i] + 10 );
517- mSettings ->libraries .push_back (lib);
512+ mSettings ->libraries .emplace_back (argv[i] + 10 );
518513 }
519514
520515 // Set maximum number of #ifdef configurations to check
@@ -588,7 +583,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
588583 if (projType == ImportProject::Type::CPPCHECK_GUI) {
589584 mPathNames = mSettings ->project .guiProject .pathNames ;
590585 for (const std::string &lib : mSettings ->project .guiProject .libraries )
591- mSettings ->libraries .push_back (lib);
586+ mSettings ->libraries .emplace_back (lib);
592587
593588 for (const std::string &ignorePath : mSettings ->project .guiProject .excludedPaths )
594589 mIgnoredPaths .emplace_back (ignorePath);
@@ -660,10 +655,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
660655 for (;;) {
661656 const std::string::size_type pos = paths.find (' ;' );
662657 if (pos == std::string::npos) {
663- mSettings ->basePaths .push_back (Path::fromNativeSeparators (paths));
658+ mSettings ->basePaths .emplace_back (Path::fromNativeSeparators (paths));
664659 break ;
665660 }
666- mSettings ->basePaths .push_back (Path::fromNativeSeparators (paths.substr (0 , pos)));
661+ mSettings ->basePaths .emplace_back (Path::fromNativeSeparators (paths.substr (0 , pos)));
667662 paths.erase (0 , pos + 1 );
668663 }
669664 } else {
@@ -682,7 +677,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
682677 else if (std::strncmp (argv[i], " --rule=" , 7 ) == 0 ) {
683678 Settings::Rule rule;
684679 rule.pattern = 7 + argv[i];
685- mSettings ->rules .push_back (rule);
680+ mSettings ->rules .emplace_back (rule);
686681 }
687682
688683 // Rule file
@@ -718,7 +713,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
718713 }
719714
720715 if (!rule.pattern .empty ())
721- mSettings ->rules .push_back (rule);
716+ mSettings ->rules .emplace_back (rule);
722717 }
723718 } else {
724719 printMessage (" cppcheck: error: unable to load rule-file: " + std::string (12 +argv[i]));
@@ -739,10 +734,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
739734 else if (showtimeMode.empty ())
740735 mSettings ->showtime = SHOWTIME_MODES::SHOWTIME_NONE;
741736 else {
742- std::string message (" cppcheck: error: unrecognized showtime mode: \" " );
743- message += showtimeMode;
744- message += " \" . Supported modes: file, summary, top5." ;
745- printMessage (message);
737+ printMessage (" cppcheck: error: unrecognized showtime mode: \" " + showtimeMode + " \" . Supported modes: file, summary, top5." );
746738 return false ;
747739 }
748740 }
@@ -899,9 +891,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
899891 }
900892
901893 else {
902- std::string path = Path::removeQuotationMarks (argv[i]);
903- path = Path::fromNativeSeparators (path);
904- mPathNames .push_back (path);
894+ mPathNames .emplace_back (Path::fromNativeSeparators (Path::removeQuotationMarks (argv[i])));
905895 }
906896 }
907897
0 commit comments