public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] Use insert's return value instead of find + insert
@ 2015-04-01 18:24 Rafael Espíndola
  2015-04-02 22:55 ` Cary Coutant
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Espíndola @ 2015-04-01 18:24 UTC (permalink / raw)
  To: Binutils; +Cc: Cary Coutant

[-- Attachment #1: Type: text/plain, Size: 181 bytes --]

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

[-- Attachment #2: t.patch --]
[-- Type: text/x-patch, Size: 738 bytes --]

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()) 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Use insert's return value instead of find + insert
  2015-04-01 18:24 [patch] Use insert's return value instead of find + insert Rafael Espíndola
@ 2015-04-02 22:55 ` Cary Coutant
  0 siblings, 0 replies; 2+ messages in thread
From: Cary Coutant @ 2015-04-02 22:55 UTC (permalink / raw)
  To: Rafael Espíndola; +Cc: Binutils, Cary Coutant

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

This is OK, with a ChangeLog entry. Thanks!

-cary

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-02 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 18:24 [patch] Use insert's return value instead of find + insert Rafael Espíndola
2015-04-02 22:55 ` Cary Coutant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).