@@ -2988,18 +2988,18 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
29882988 return " " ;
29892989}
29902990
2991- std::pair<simplecpp::FileData *, bool > simplecpp::FileDataCache::tryload (const FileDataCache::name_map_type::iterator &name_it, const simplecpp::DUI &dui, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
2991+ std::pair<simplecpp::FileData *, bool > simplecpp::FileDataCache::tryload (FileDataCache::name_map_type::iterator &name_it, const simplecpp::DUI &dui, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
29922992{
29932993 const std::string &path = name_it->first ;
29942994 FileID fileId;
29952995
29962996 if (!getFileId (path, fileId))
2997- return std::make_pair ( nullptr , false ) ;
2997+ return { nullptr , false } ;
29982998
29992999 const auto id_it = mIdMap .find (fileId);
30003000 if (id_it != mIdMap .end ()) {
30013001 name_it->second = id_it->second ;
3002- return std::make_pair ( id_it->second , false ) ;
3002+ return { id_it->second , false } ;
30033003 }
30043004
30053005 std::ifstream f (path);
@@ -3009,53 +3009,56 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(const F
30093009 data->tokens .removeComments ();
30103010
30113011 name_it->second = data;
3012- mIdMap .insert ( std::make_pair ( fileId, data) );
3013- mData .push_back (std::unique_ptr<FileData>( data) );
3012+ mIdMap .emplace ( fileId, data);
3013+ mData .emplace_back ( data);
30143014
3015- return std::make_pair ( data, true ) ;
3015+ return { data, true } ;
30163016}
30173017
30183018std::pair<simplecpp::FileData *, bool > simplecpp::FileDataCache::get (const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
30193019{
30203020 if (isAbsolutePath (header)) {
3021- const auto ins = mNameMap .insert ( std::make_pair ( simplecpp::simplifyPath (header), nullptr ) );
3021+ auto ins = mNameMap .emplace ( simplecpp::simplifyPath (header), nullptr );
30223022
30233023 if (ins.second ) {
30243024 const auto ret = tryload (ins.first , dui, filenames, outputList);
3025- if (ret.first != nullptr )
3025+ if (ret.first != nullptr ) {
30263026 return ret;
3027+ }
30273028 } else {
3028- return std::make_pair ( ins.first ->second , false ) ;
3029+ return { ins.first ->second , false } ;
30293030 }
30303031
3031- return std::make_pair ( nullptr , false ) ;
3032+ return { nullptr , false } ;
30323033 }
30333034
30343035 if (!systemheader) {
3035- const auto ins = mNameMap .insert ( std::make_pair ( simplecpp::simplifyPath (dirPath (sourcefile) + header), nullptr ) );
3036+ auto ins = mNameMap .emplace ( simplecpp::simplifyPath (dirPath (sourcefile) + header), nullptr );
30363037
30373038 if (ins.second ) {
30383039 const auto ret = tryload (ins.first , dui, filenames, outputList);
3039- if (ret.first != nullptr )
3040+ if (ret.first != nullptr ) {
30403041 return ret;
3042+ }
30413043 } else if (ins.first ->second != nullptr ) {
3042- return std::make_pair ( ins.first ->second , false ) ;
3044+ return { ins.first ->second , false } ;
30433045 }
30443046 }
30453047
30463048 for (const auto &includePath : dui.includePaths ) {
3047- const auto ins = mNameMap .insert ( std::make_pair ( simplecpp::simplifyPath (includePath + " /" + header), nullptr ) );
3049+ auto ins = mNameMap .emplace ( simplecpp::simplifyPath (includePath + " /" + header), nullptr );
30483050
30493051 if (ins.second ) {
30503052 const auto ret = tryload (ins.first , dui, filenames, outputList);
3051- if (ret.first != nullptr )
3053+ if (ret.first != nullptr ) {
30523054 return ret;
3055+ }
30533056 } else if (ins.first ->second != nullptr ) {
3054- return std::make_pair ( ins.first ->second , false ) ;
3057+ return { ins.first ->second , false } ;
30553058 }
30563059 }
30573060
3058- return std::make_pair ( nullptr , false ) ;
3061+ return { nullptr , false } ;
30593062}
30603063
30613064bool simplecpp::FileDataCache::getFileId (const std::string &path, FileID &id)
0 commit comments