Explorar o código

One map to rule them all

Mike Samsonov %!s(int64=6) %!d(string=hai) anos
pai
achega
0eec1c1d4a
Modificáronse 2 ficheiros con 5 adicións e 9 borrados
  1. 4 5
      code/FBXConverter.cpp
  2. 1 4
      code/FBXConverter.h

+ 4 - 5
code/FBXConverter.cpp

@@ -442,16 +442,15 @@ namespace Assimp {
         void FBXConverter::GetUniqueName(const std::string &name, std::string &uniqueName)
         {
             uniqueName = name;
-            auto it_pair = mNodeNameInstances.insert({ name, 0 }); // duplicate node name instance count
+            auto it_pair = mNodeNames.insert({ name, 0 }); // duplicate node name instance count
             unsigned int& i = it_pair.first->second;
-            auto uniqueIt_pair = mNodeNames.insert(uniqueName);
-            while (!uniqueIt_pair.second)
+            while (!it_pair.second)
             {
                 i++;
-                std::stringstream ext;
+                std::ostringstream ext;
                 ext << name << std::setfill('0') << std::setw(3) << i;
                 uniqueName = ext.str();
-                uniqueIt_pair = mNodeNames.insert(uniqueName);
+                it_pair = mNodeNames.insert({ uniqueName, 0 });
             }
         }
 

+ 1 - 4
code/FBXConverter.h

@@ -462,10 +462,7 @@ private:
     NodeAnimBitMap node_anim_chain_bits;
 
     // number of nodes with the same name
-    using NodeAnimNameMap = std::unordered_map<std::string, unsigned int>;
-    NodeAnimNameMap mNodeNameInstances;
-
-    using NodeNameCache = std::unordered_set<std::string>;
+    using NodeNameCache = std::unordered_map<std::string, unsigned int>;
     NodeNameCache mNodeNames;
 
     double anim_fps;