@@ -421,7 +421,7 @@ class FileStream : public simplecpp::TokenList::Stream {
421421 : file(fopen(filename.c_str(), "rb"))
422422 {
423423 if (!file) {
424- files.push_back (filename);
424+ files.emplace_back (filename);
425425 throw simplecpp::Output (simplecpp::Output::FILE_NOT_FOUND, {}, " File is missing: " + filename);
426426 }
427427 init ();
@@ -490,7 +490,7 @@ simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::st
490490 FileStream stream (filename, filenames);
491491 readfile (stream,filename,outputList);
492492 } catch (const simplecpp::Output & e) {
493- outputList->push_back (e);
493+ outputList->emplace_back (e);
494494 }
495495}
496496
@@ -625,7 +625,7 @@ static void portabilityBackslash(simplecpp::OutputList *outputList, const simple
625625 location,
626626 " Combination 'backslash space newline' is not portable."
627627 };
628- outputList->push_back (std::move (err));
628+ outputList->emplace_back (std::move (err));
629629}
630630
631631static bool isStringLiteralPrefix (const std::string &str)
@@ -674,7 +674,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
674674 location,
675675 " The code contains unhandled character(s) (character code=" + std::to_string (static_cast <int >(ch)) + " ). Neither unicode nor extended ascii is supported."
676676 };
677- outputList->push_back (std::move (err));
677+ outputList->emplace_back (std::move (err));
678678 }
679679 clear ();
680680 return ;
@@ -876,7 +876,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
876876 location,
877877 " Invalid newline in raw string delimiter."
878878 };
879- outputList->push_back (std::move (err));
879+ outputList->emplace_back (std::move (err));
880880 }
881881 return ;
882882 }
@@ -890,7 +890,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
890890 location,
891891 " Raw string missing terminating delimiter."
892892 };
893- outputList->push_back (std::move (err));
893+ outputList->emplace_back (std::move (err));
894894 }
895895 return ;
896896 }
@@ -1434,7 +1434,7 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca
14341434 location,
14351435 std::string (" No pair for character (" ) + start + " ). Can't process file. File is either invalid or unicode, which is currently not supported."
14361436 };
1437- outputList->push_back (std::move (err));
1437+ outputList->emplace_back (std::move (err));
14381438 }
14391439 return " " ;
14401440 }
@@ -1472,7 +1472,7 @@ unsigned int simplecpp::TokenList::fileIndex(const std::string &filename)
14721472 if (files[i] == filename)
14731473 return i;
14741474 }
1475- files.push_back (filename);
1475+ files.emplace_back (filename);
14761476 return files.size () - 1U ;
14771477}
14781478
@@ -1754,7 +1754,7 @@ namespace simplecpp {
17541754 break ;
17551755 }
17561756 if (argtok->op != ' ,' )
1757- args.push_back (argtok->str ());
1757+ args.emplace_back (argtok->str ());
17581758 argtok = argtok->next ;
17591759 }
17601760 if (!sameline (nametoken, argtok)) {
@@ -1832,19 +1832,19 @@ namespace simplecpp {
18321832 return {};
18331833
18341834 std::vector<const Token *> parametertokens;
1835- parametertokens.push_back (nameTokInst->next );
1835+ parametertokens.emplace_back (nameTokInst->next );
18361836 unsigned int par = 0U ;
18371837 for (const Token *tok = nameTokInst->next ->next ; calledInDefine ? sameline (tok, nameTokInst) : (tok != nullptr ); tok = tok->next ) {
18381838 if (tok->op == ' (' )
18391839 ++par;
18401840 else if (tok->op == ' )' ) {
18411841 if (par == 0U ) {
1842- parametertokens.push_back (tok);
1842+ parametertokens.emplace_back (tok);
18431843 break ;
18441844 }
18451845 --par;
18461846 } else if (par == 0U && tok->op == ' ,' && (!variadic || parametertokens.size () < args.size ()))
1847- parametertokens.push_back (tok);
1847+ parametertokens.emplace_back (tok);
18481848 }
18491849 return parametertokens;
18501850 }
@@ -1894,7 +1894,7 @@ namespace simplecpp {
18941894 std::cout << " expand " << name () << " " << locstring (defineLocation ()) << std::endl;
18951895#endif
18961896
1897- usageList.push_back (loc);
1897+ usageList.emplace_back (loc);
18981898
18991899 if (nameTokInst->str () == " __FILE__" ) {
19001900 output.push_back (new Token (' \" ' +output.file (loc)+' \" ' , loc));
@@ -1954,11 +1954,11 @@ namespace simplecpp {
19541954 for (const Token *tok = parametertokens1[0 ]; tok && par < parametertokens1.size (); tok = tok->next ) {
19551955 if (tok->str () == " __COUNTER__" ) {
19561956 tokensparams.push_back (new Token (toString (counterMacro.usageList .size ()), tok->location ));
1957- counterMacro.usageList .push_back (tok->location );
1957+ counterMacro.usageList .emplace_back (tok->location );
19581958 } else {
19591959 tokensparams.push_back (new Token (*tok));
19601960 if (tok == parametertokens1[par]) {
1961- parametertokens2.push_back (tokensparams.cback ());
1961+ parametertokens2.emplace_back (tokensparams.cback ());
19621962 par++;
19631963 }
19641964 }
@@ -3183,7 +3183,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31833183 {},
31843184 " Can not open include file '" + filename + " ' that is explicitly included."
31853185 };
3186- outputList->push_back (std::move (err));
3186+ outputList->emplace_back (std::move (err));
31873187 }
31883188 continue ;
31893189 }
@@ -3197,7 +3197,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31973197 if (dui.removeComments )
31983198 filedata->tokens .removeComments ();
31993199
3200- filelist.push_back (filedata->tokens .front ());
3200+ filelist.emplace_back (filedata->tokens .front ());
32013201 }
32023202
32033203 for (const Token *rawtok = rawtokens.cfront (); rawtok || !filelist.empty (); rawtok = rawtok ? rawtok->next : nullptr ) {
@@ -3236,7 +3236,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
32363236 if (dui.removeComments )
32373237 filedata->tokens .removeComments ();
32383238
3239- filelist.push_back (filedata->tokens .front ());
3239+ filelist.emplace_back (filedata->tokens .front ());
32403240 }
32413241
32423242 return cache;
@@ -3257,7 +3257,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32573257 err.location ,
32583258 " failed to expand \' " + tok->str () + " \' , " + err.what
32593259 };
3260- outputList->push_back (std::move (out));
3260+ outputList->emplace_back (std::move (out));
32613261 }
32623262 return false ;
32633263 }
@@ -3352,7 +3352,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33523352 {},
33533353 e.what ()
33543354 };
3355- outputList->push_back (std::move (err));
3355+ outputList->emplace_back (std::move (err));
33563356 }
33573357 output.clear ();
33583358 return ;
@@ -3386,7 +3386,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33863386 {},
33873387 " unknown standard specified: '" + dui.std + " '"
33883388 };
3389- outputList->push_back (std::move (err));
3389+ outputList->emplace_back (std::move (err));
33903390 }
33913391 output.clear ();
33923392 return ;
@@ -3443,7 +3443,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34433443 rawtok->location ,
34443444 " #" + rawtok->str () + " without #if"
34453445 };
3446- outputList->push_back (std::move (err));
3446+ outputList->emplace_back (std::move (err));
34473447 }
34483448 output.clear ();
34493449 return ;
@@ -3464,7 +3464,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34643464 std::move (msg)
34653465 };
34663466
3467- outputList->push_back (std::move (err));
3467+ outputList->emplace_back (std::move (err));
34683468 }
34693469 if (rawtok->str () == ERROR) {
34703470 output.clear ();
@@ -3491,7 +3491,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34913491 rawtok->location ,
34923492 " Failed to parse #define"
34933493 };
3494- outputList->push_back (std::move (err));
3494+ outputList->emplace_back (std::move (err));
34953495 }
34963496 output.clear ();
34973497 return ;
@@ -3502,7 +3502,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35023502 err.location ,
35033503 " Failed to parse #define, " + err.what
35043504 };
3505- outputList->push_back (std::move (out));
3505+ outputList->emplace_back (std::move (out));
35063506 }
35073507 output.clear ();
35083508 return ;
@@ -3543,7 +3543,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35433543 rawtok->location ,
35443544 " No header in #include"
35453545 };
3546- outputList->push_back (std::move (err));
3546+ outputList->emplace_back (std::move (err));
35473547 }
35483548 output.clear ();
35493549 return ;
@@ -3561,7 +3561,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35613561 rawtok->location ,
35623562 " Header not found: " + inctok->str ()
35633563 };
3564- outputList->push_back (std::move (out));
3564+ outputList->emplace_back (std::move (out));
35653565 }
35663566 } else if (includetokenstack.size () >= 400 ) {
35673567 if (outputList) {
@@ -3570,7 +3570,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35703570 rawtok->location ,
35713571 " #include nested too deeply"
35723572 };
3573- outputList->push_back (std::move (out));
3573+ outputList->emplace_back (std::move (out));
35743574 }
35753575 } else if (pragmaOnce.find (filedata->filename ) == pragmaOnce.end ()) {
35763576 includetokenstack.push (gotoNextLine (rawtok));
@@ -3585,7 +3585,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35853585 rawtok->location ,
35863586 " Syntax error in #" + rawtok->str ()
35873587 };
3588- outputList->push_back (std::move (out));
3588+ outputList->emplace_back (std::move (out));
35893589 }
35903590 output.clear ();
35913591 return ;
@@ -3596,10 +3596,10 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35963596 conditionIsTrue = false ;
35973597 else if (rawtok->str () == IFDEF) {
35983598 conditionIsTrue = (macros.find (rawtok->next ->str ()) != macros.end () || (hasInclude && rawtok->next ->str () == HAS_INCLUDE));
3599- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3599+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36003600 } else if (rawtok->str () == IFNDEF) {
36013601 conditionIsTrue = (macros.find (rawtok->next ->str ()) == macros.end () && !(hasInclude && rawtok->next ->str () == HAS_INCLUDE));
3602- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3602+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36033603 } else { /* if (rawtok->str() == IF || rawtok->str() == ELIF)*/
36043604 TokenList expr (files);
36053605 for (const Token *tok = rawtok->next ; tok && tok->location .sameline (rawtok->location ); tok = tok->next ) {
@@ -3613,7 +3613,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36133613 const bool par = (tok && tok->op == ' (' );
36143614 if (par)
36153615 tok = tok->next ;
3616- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3616+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36173617 if (tok) {
36183618 if (macros.find (tok->str ()) != macros.end ())
36193619 expr.push_back (new Token (" 1" , tok->location ));
@@ -3631,7 +3631,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36313631 rawtok->location ,
36323632 " failed to evaluate " + std::string (rawtok->str () == IF ? " #if" : " #elif" ) + " condition"
36333633 };
3634- outputList->push_back (std::move (out));
3634+ outputList->emplace_back (std::move (out));
36353635 }
36363636 output.clear ();
36373637 return ;
@@ -3674,15 +3674,15 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36743674 rawtok->location ,
36753675 " failed to evaluate " + std::string (rawtok->str () == IF ? " #if" : " #elif" ) + " condition"
36763676 };
3677- outputList->push_back (std::move (out));
3677+ outputList->emplace_back (std::move (out));
36783678 }
36793679 output.clear ();
36803680 return ;
36813681 }
36823682 continue ;
36833683 }
36843684
3685- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3685+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36863686
36873687 const Token *tmp = tok;
36883688 if (!preprocessToken (expr, tmp, macros, files, outputList)) {
@@ -3715,7 +3715,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37153715 rawtok->location ,
37163716 std::move (msg)
37173717 };
3718- outputList->push_back (std::move (out));
3718+ outputList->emplace_back (std::move (out));
37193719 }
37203720 output.clear ();
37213721 return ;
@@ -3814,7 +3814,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38143814 mu.macroName = macro.name ();
38153815 mu.macroLocation = macro.defineLocation ();
38163816 mu.useLocation = *usageIt;
3817- macroUsage->push_back (std::move (mu));
3817+ macroUsage->emplace_back (std::move (mu));
38183818 }
38193819 }
38203820 }
0 commit comments