* merge.cc (Object_merge_map::initialize_input_to_output_map):
authorIan Lance Taylor <ian@airs.com>
Thu, 9 Jul 2009 23:29:55 +0000 (23:29 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 9 Jul 2009 23:29:55 +0000 (23:29 +0000)
Reserve space in the hash table.

gold/ChangeLog
gold/merge.cc

index 70349e0d1ddc5466be5e01715a888000a2e55b2d..974a49f1505c3d6fe7a9100645ee7d7a0272959b 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-09  Ian Lance Taylor  <iant@google.com>
+
+       * merge.cc (Object_merge_map::initialize_input_to_output_map):
+       Reserve space in the hash table.
+
 2009-07-06  Mikolaj Zalewski  <mikolajz@google.com>
 
        * fileread.cc (File_read::get_mtime): New method.
index 25ecc40c0e17c14b7ef6605a98ad6c3f7065912a..3d9692124a0cb3a90123b01ff51faa4e9107d8a9 100644 (file)
@@ -204,6 +204,12 @@ Object_merge_map::initialize_input_to_output_map(
   Input_merge_map* map = this->get_input_merge_map(shndx);
   gold_assert(map != NULL);
 
+  gold_assert(initialize_map->empty());
+  // We know how many entries we are going to add.
+  // reserve_unordered_map takes an expected count of buckets, not a
+  // count of elements, so double it to try to reduce collisions.
+  reserve_unordered_map(initialize_map, map->entries.size() * 2);
+
   for (Input_merge_map::Entries::const_iterator p = map->entries.begin();
        p != map->entries.end();
        ++p)