@@ -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 }
@@ -1992,7 +1992,7 @@ namespace simplecpp {
19921992 throw invalidHashHash::unexpectedNewline (tok->location , name ());
19931993 if (variadic && tok->op == ' ,' && tok->next ->next ->next ->str () == args.back ()) {
19941994 Token *const comma = newMacroToken (tok->str (), loc, isReplaced (expandedmacros), tok);
1995- output.push_back (comma);
1995+ output.emplace_back (comma);
19961996 tok = expandToken (output, loc, tok->next ->next ->next , macros, expandedmacros, parametertokens2);
19971997 if (output.back () == comma)
19981998 output.deleteToken (comma);
@@ -3182,7 +3182,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31823182 {},
31833183 " Can not open include file '" + filename + " ' that is explicitly included."
31843184 };
3185- outputList->push_back (std::move (err));
3185+ outputList->emplace_back (std::move (err));
31863186 }
31873187 continue ;
31883188 }
@@ -3196,7 +3196,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31963196 if (dui.removeComments )
31973197 filedata->tokens .removeComments ();
31983198
3199- filelist.push_back (filedata->tokens .front ());
3199+ filelist.emplace_back (filedata->tokens .front ());
32003200 }
32013201
32023202 for (const Token *rawtok = rawtokens.cfront (); rawtok || !filelist.empty (); rawtok = rawtok ? rawtok->next : nullptr ) {
@@ -3235,7 +3235,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
32353235 if (dui.removeComments )
32363236 filedata->tokens .removeComments ();
32373237
3238- filelist.push_back (filedata->tokens .front ());
3238+ filelist.emplace_back (filedata->tokens .front ());
32393239 }
32403240
32413241 return cache;
@@ -3256,7 +3256,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32563256 err.location ,
32573257 " failed to expand \' " + tok->str () + " \' , " + err.what
32583258 };
3259- outputList->push_back (std::move (out));
3259+ outputList->emplace_back (std::move (out));
32603260 }
32613261 return false ;
32623262 }
@@ -3351,7 +3351,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33513351 {},
33523352 e.what ()
33533353 };
3354- outputList->push_back (std::move (err));
3354+ outputList->emplace_back (std::move (err));
33553355 }
33563356 output.clear ();
33573357 return ;
@@ -3385,7 +3385,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33853385 {},
33863386 " unknown standard specified: '" + dui.std + " '"
33873387 };
3388- outputList->push_back (std::move (err));
3388+ outputList->emplace_back (std::move (err));
33893389 }
33903390 output.clear ();
33913391 return ;
@@ -3442,7 +3442,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34423442 rawtok->location ,
34433443 " #" + rawtok->str () + " without #if"
34443444 };
3445- outputList->push_back (std::move (err));
3445+ outputList->emplace_back (std::move (err));
34463446 }
34473447 output.clear ();
34483448 return ;
@@ -3463,7 +3463,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34633463 std::move (msg)
34643464 };
34653465
3466- outputList->push_back (std::move (err));
3466+ outputList->emplace_back (std::move (err));
34673467 }
34683468 if (rawtok->str () == ERROR) {
34693469 output.clear ();
@@ -3490,7 +3490,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34903490 rawtok->location ,
34913491 " Failed to parse #define"
34923492 };
3493- outputList->push_back (std::move (err));
3493+ outputList->emplace_back (std::move (err));
34943494 }
34953495 output.clear ();
34963496 return ;
@@ -3501,7 +3501,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35013501 err.location ,
35023502 " Failed to parse #define, " + err.what
35033503 };
3504- outputList->push_back (std::move (out));
3504+ outputList->emplace_back (std::move (out));
35053505 }
35063506 output.clear ();
35073507 return ;
@@ -3542,7 +3542,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35423542 rawtok->location ,
35433543 " No header in #include"
35443544 };
3545- outputList->push_back (std::move (err));
3545+ outputList->emplace_back (std::move (err));
35463546 }
35473547 output.clear ();
35483548 return ;
@@ -3560,7 +3560,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35603560 rawtok->location ,
35613561 " Header not found: " + inctok->str ()
35623562 };
3563- outputList->push_back (std::move (out));
3563+ outputList->emplace_back (std::move (out));
35643564 }
35653565 } else if (includetokenstack.size () >= 400 ) {
35663566 if (outputList) {
@@ -3569,7 +3569,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35693569 rawtok->location ,
35703570 " #include nested too deeply"
35713571 };
3572- outputList->push_back (std::move (out));
3572+ outputList->emplace_back (std::move (out));
35733573 }
35743574 } else if (pragmaOnce.find (filedata->filename ) == pragmaOnce.end ()) {
35753575 includetokenstack.push (gotoNextLine (rawtok));
@@ -3584,7 +3584,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35843584 rawtok->location ,
35853585 " Syntax error in #" + rawtok->str ()
35863586 };
3587- outputList->push_back (std::move (out));
3587+ outputList->emplace_back (std::move (out));
35883588 }
35893589 output.clear ();
35903590 return ;
@@ -3595,10 +3595,10 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35953595 conditionIsTrue = false ;
35963596 else if (rawtok->str () == IFDEF) {
35973597 conditionIsTrue = (macros.find (rawtok->next ->str ()) != macros.end () || (hasInclude && rawtok->next ->str () == HAS_INCLUDE));
3598- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3598+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
35993599 } else if (rawtok->str () == IFNDEF) {
36003600 conditionIsTrue = (macros.find (rawtok->next ->str ()) == macros.end () && !(hasInclude && rawtok->next ->str () == HAS_INCLUDE));
3601- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3601+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36023602 } else { /* if (rawtok->str() == IF || rawtok->str() == ELIF)*/
36033603 TokenList expr (files);
36043604 for (const Token *tok = rawtok->next ; tok && tok->location .sameline (rawtok->location ); tok = tok->next ) {
@@ -3612,7 +3612,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36123612 const bool par = (tok && tok->op == ' (' );
36133613 if (par)
36143614 tok = tok->next ;
3615- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3615+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36163616 if (tok) {
36173617 if (macros.find (tok->str ()) != macros.end ())
36183618 expr.push_back (new Token (" 1" , tok->location ));
@@ -3630,7 +3630,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36303630 rawtok->location ,
36313631 " failed to evaluate " + std::string (rawtok->str () == IF ? " #if" : " #elif" ) + " condition"
36323632 };
3633- outputList->push_back (std::move (out));
3633+ outputList->emplace_back (std::move (out));
36343634 }
36353635 output.clear ();
36363636 return ;
@@ -3673,15 +3673,15 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36733673 rawtok->location ,
36743674 " failed to evaluate " + std::string (rawtok->str () == IF ? " #if" : " #elif" ) + " condition"
36753675 };
3676- outputList->push_back (std::move (out));
3676+ outputList->emplace_back (std::move (out));
36773677 }
36783678 output.clear ();
36793679 return ;
36803680 }
36813681 continue ;
36823682 }
36833683
3684- maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
3684+ maybeUsedMacros[rawtok->next ->str ()].emplace_back (rawtok->next ->location );
36853685
36863686 const Token *tmp = tok;
36873687 if (!preprocessToken (expr, tmp, macros, files, outputList)) {
@@ -3714,7 +3714,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37143714 rawtok->location ,
37153715 std::move (msg)
37163716 };
3717- outputList->push_back (std::move (out));
3717+ outputList->emplace_back (std::move (out));
37183718 }
37193719 output.clear ();
37203720 return ;
@@ -3813,7 +3813,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38133813 mu.macroName = macro.name ();
38143814 mu.macroLocation = macro.defineLocation ();
38153815 mu.useLocation = *usageIt;
3816- macroUsage->push_back (std::move (mu));
3816+ macroUsage->emplace_back (std::move (mu));
38173817 }
38183818 }
38193819 }
0 commit comments