From 5368dcf2bae8f15e16cd14348bb7bd716bbc81cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Mon, 6 Apr 2015 15:45:37 -0400 Subject: [PATCH] Avoid a call to find by using the return value of insert. --- gold/ChangeLog | 5 +++++ gold/gc.cc | 11 ++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 9eadf3b7cc9..25d45889f73 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2015-04-06 Rafael Ávila de Espíndola + + * gc.cc (Garbage_collection::do_transitive_closure): Avoid a call + to find by using the return value of insert. + 2015-04-06 Rafael Ávila de Espíndola * gc.cc (Garbage_collection::do_transitive_closure): Avoid a copy diff --git a/gold/gc.cc b/gold/gc.cc index 95867c4bbb6..16bdb19931d 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()) -- 2.30.2