This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Use insert's return value instead of find + insert
- From: Rafael EspÃndola <rafael dot espindola at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Cc: Cary Coutant <ccoutant at google dot com>
- Date: Wed, 1 Apr 2015 14:24:50 -0400
- Subject: [patch] Use insert's return value instead of find + insert
- Authentication-results: sourceware.org; auth=none
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())