This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Use insert's return value instead of find + insert


The attached patch just avoids a find+insert pair. It is simpler and a
bit faster.

Chromium link times go from 6.373936381( +- 0.30% )
to 6.325477054 ( +- 0.33% ).

Cheers,
Rafael
diff --git a/gold/gc.cc b/gold/gc.cc
index 843b2b8..1e32c18 100644
--- a/gold/gc.cc
+++ b/gold/gc.cc
@@ -40,15 +40,8 @@ Garbage_collection::do_transitive_closure()
       // one by one.
       Section_id entry = this->worklist().front();
       this->worklist().pop();
-      if (this->referenced_list().find(entry)
-          == this->referenced_list().end()) 
-        {
-          this->referenced_list().insert(entry);
-        }
-      else
-        {
-          continue;
-        }
+      if (!this->referenced_list().insert(entry).second)
+        continue;
       Garbage_collection::Section_ref::iterator find_it = 
                 this->section_reloc_map().find(entry);
       if (find_it == this->section_reloc_map().end()) 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]