Index: XIOS/trunk/src/client_client_dht_template_impl.hpp
===================================================================
--- XIOS/trunk/src/client_client_dht_template_impl.hpp	(revision 839)
+++ XIOS/trunk/src/client_client_dht_template_impl.hpp	(revision 843)
@@ -24,6 +24,7 @@
 CClientClientDHTTemplate<T,H>::CClientClientDHTTemplate(const boost::unordered_map<size_t,T>& indexInfoMap,
                                                         const MPI_Comm& clientIntraComm)
-  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_()
-{
+  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_(), nbClient_(0)
+{
+  MPI_Comm_size(clientIntraComm, &nbClient_);
   this->computeMPICommLevel();
   int nbLvl = this->getNbLevel();
@@ -88,5 +89,5 @@
   }
 
-  std::map<int, size_t* > client2ClientIndex;
+  boost::unordered_map<int, size_t* > client2ClientIndex;
   for (int idx = 0; idx < nbClient; ++idx)
   {
@@ -140,6 +141,6 @@
   }
 
-  std::map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,
-                                    iteIndex = client2ClientIndex.end();
+  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,
+                                                iteIndex = client2ClientIndex.end();
   for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex)
     sendIndexToClients(itIndex->first, (itIndex->second), sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request);
@@ -213,6 +214,6 @@
   }
 
-  std::map<int,unsigned char*> client2ClientInfoOnReturn;
-  std::map<int,size_t*> client2ClientIndexOnReturn;
+  boost::unordered_map<int,unsigned char*> client2ClientInfoOnReturn;
+  boost::unordered_map<int,size_t*> client2ClientIndexOnReturn;
   currentIndex = 0;
   for (int idx = 0; idx < nbRecvClient; ++idx)
@@ -249,4 +250,5 @@
 
   boost::unordered_map<size_t,InfoType> indexToInfoMapping;
+  indexToInfoMapping.rehash(std::ceil(recvNbIndexCountOnReturn/indexToInfoMapping.max_load_factor()));
   int infoIndex = 0;
   for (int idx = 0; idx < recvNbIndexCountOnReturn; ++idx)
@@ -255,8 +257,8 @@
   }
 
-  indexToInfoMappingLevel_ = (indexToInfoMapping);
+  indexToInfoMappingLevel_.swap(indexToInfoMapping); //indexToInfoMappingLevel_ = (indexToInfoMapping);
   if (0 != recvNbIndexCount) delete [] recvIndexBuff;
-  for (std::map<int,size_t*>::const_iterator it = client2ClientIndex.begin();
-                                            it != client2ClientIndex.end(); ++it)
+  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin();
+                                                        it != client2ClientIndex.end(); ++it)
       delete [] it->second;
   delete tmpGlobalIndex;
@@ -268,9 +270,9 @@
   }
 
-  for (std::map<int,unsigned char*>::const_iterator it = client2ClientInfoOnReturn.begin();
-                                                    it != client2ClientInfoOnReturn.end(); ++it)
+  for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfoOnReturn.begin();
+                                                               it != client2ClientInfoOnReturn.end(); ++it)
       delete [] it->second;
 
-  for (std::map<int,size_t*>::const_iterator it = client2ClientIndexOnReturn.begin();
+  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndexOnReturn.begin();
                                             it != client2ClientIndexOnReturn.end(); ++it)
       delete [] it->second;
@@ -342,6 +344,6 @@
   }
 
-  std::map<int, size_t*> client2ClientIndex;
-  std::map<int, unsigned char*> client2ClientInfo;
+  boost::unordered_map<int, size_t*> client2ClientIndex;
+  boost::unordered_map<int, unsigned char*> client2ClientInfo;
   for (int idx = 0; idx < nbClient; ++idx)
   {
@@ -407,10 +409,10 @@
   }
 
-  std::map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,
-                                    iteIndex = client2ClientIndex.end();
+  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,
+                                                iteIndex = client2ClientIndex.end();
   for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex)
     sendIndexToClients(itIndex->first, itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request);
-  std::map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo,
-                                          iteInfo = client2ClientInfo.end();
+  boost::unordered_map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo,
+                                                      iteInfo = client2ClientInfo.end();
   for (itInfo = itbInfo; itInfo != iteInfo; ++itInfo)
     sendInfoToClients(itInfo->first, itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], commLevel, request);
@@ -420,4 +422,5 @@
 
   boost::unordered_map<size_t,InfoType> indexToInfoMapping;
+  indexToInfoMapping.rehash(std::ceil(currentIndex/indexToInfoMapping.max_load_factor()));
   currentIndex = 0;
   InfoType infoValue;
@@ -440,10 +443,10 @@
     delete [] recvInfoBuff;
   }
-  for (std::map<int,unsigned char*>::const_iterator it = client2ClientInfo.begin();
-                                                    it != client2ClientInfo.end(); ++it)
+  for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfo.begin();
+                                                               it != client2ClientInfo.end(); ++it)
       delete [] it->second;
 
-  for (std::map<int,size_t*>::const_iterator it = client2ClientIndex.begin();
-                                            it != client2ClientIndex.end(); ++it)
+  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin();
+                                                        it != client2ClientIndex.end(); ++it)
       delete [] it->second;
 
@@ -455,5 +458,5 @@
   }
   else
-    index2InfoMapping_ = (indexToInfoMapping);
+    index2InfoMapping_.swap(indexToInfoMapping); //index2InfoMapping_ = (indexToInfoMapping);
 }
 
