]> git.mxchange.org Git - simgear.git/commitdiff
Fix one more crash on Windows in HTTPRepository
authorTorsten Dreyer <torsten@t3r.de>
Fri, 6 May 2016 08:48:16 +0000 (10:48 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
inner scope it seems to overwrite out scope it on Win :-/

Anyway, the erase-remove-idiom is a better solution for that task
https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom

Also remove some useless debug messages

simgear/io/HTTPRepository.cxx

index 8ae8038e12ea7b57bd9002d8ca92188ad3cae56b..581f440abbf33ed53c9a7376f858983a6bab78a0 100644 (file)
@@ -254,18 +254,14 @@ public:
         string_list indexNames = indexChildren(),
             toBeUpdated, orphans;
         simgear::Dir d(absolutePath());
-        SG_LOG(SG_TERRASYNC, SG_DEBUG, "Dir created for: '" << absolutePath() );
         PathList fsChildren = d.children(0);
-        SG_LOG(SG_TERRASYNC, SG_DEBUG, "Dir has children: '" << fsChildren.size() );
         PathList::const_iterator it = fsChildren.begin();
 
 
         for (; it != fsChildren.end(); ++it) {
-            SG_LOG(SG_TERRASYNC, SG_DEBUG, "processing child: '" << it->str() << "', file=" << it->file() << ",isDir=" << it->isDir() );
             ChildInfo info(it->isDir() ? ChildInfo::DirectoryType : ChildInfo::FileType,
                            it->file(), "");
             std::string hash = hashForChild(info);
-            SG_LOG(SG_TERRASYNC, SG_DEBUG, "hash is: '" << hash << "'" );
 
             ChildInfoList::iterator c = findIndexChild(it->file());
             if (c == children.end()) {
@@ -285,7 +281,6 @@ public:
                 // perform a recursive check.
                 SG_LOG(SG_TERRASYNC, SG_DEBUG, "file exists hash is good:" << c->name);
                 if (c->type == ChildInfo::DirectoryType) {
-                    SG_LOG(SG_TERRASYNC, SG_DEBUG, "going recursive for:" << c->name);
                     SGPath p(relativePath());
                     p.append(c->name);
                     HTTPDirectory* childDir = _repository->getOrCreateDirectory(p.str());
@@ -295,12 +290,8 @@ public:
 
             // remove existing file system children from the index list,
             // so we can detect new children
-            SG_LOG(SG_TERRASYNC, SG_DEBUG, "looking for name in indexNames:" << c->name);
-            string_list::iterator it = std::find(indexNames.begin(), indexNames.end(), c->name);
-            if (it != indexNames.end()) {
-                SG_LOG(SG_TERRASYNC, SG_DEBUG, "found name in indexNames, erasing:" << c->name);
-                indexNames.erase(it);
-            }
+            // https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Erase-Remove
+            indexNames.erase(std::remove(indexNames.begin(), indexNames.end(), c->name), indexNames.end());
         } // of real children iteration
 
         // all remaining names in indexChilden are new children