X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fgc.cc;h=7ee4eff90b4c71b22c0065308e2e705e285d5e01;hb=348fe36b1d64f12c60e08f6313520b3191663063;hp=4759c008206941f493ac76bcca52930987861341;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/gc.cc b/gold/gc.cc index 4759c00820..7ee4eff90b 100644 --- a/gold/gc.cc +++ b/gold/gc.cc @@ -1,6 +1,6 @@ // gc.cc -- garbage collection of unused sections -// Copyright (C) 2009-2014 Free Software Foundation, Inc. +// Copyright (C) 2009-2020 Free Software Foundation, Inc. // Written by Sriraman Tallam . // This file is part of gold. @@ -38,24 +38,18 @@ Garbage_collection::do_transitive_closure() { // Add elements from the work list to the referenced list // 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; - } + Section_id entry = this->worklist().back(); + this->worklist().pop_back(); + 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()) continue; - Garbage_collection::Sections_reachable v = find_it->second; + const Garbage_collection::Sections_reachable &v = find_it->second; // Scan the vector of references for each work_list entry. - for (Garbage_collection::Sections_reachable::iterator it_v = v.begin(); + for (Garbage_collection::Sections_reachable::const_iterator it_v = + v.begin(); it_v != v.end(); ++it_v) { @@ -63,7 +57,7 @@ Garbage_collection::do_transitive_closure() if (this->referenced_list().find(*it_v) == this->referenced_list().end()) { - this->worklist().push(*it_v); + this->worklist().push_back(*it_v); } } }