public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/23425] New: vector::clear should be manually inlined
@ 2005-08-16 18:26 tkho at ucla dot edu
  2005-08-16 18:32 ` [Bug libstdc++/23425] " tkho at ucla dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: tkho at ucla dot edu @ 2005-08-16 18:26 UTC (permalink / raw)
  To: gcc-bugs

vector::clear calls erase(begin(), end()), which has an unnecessary call to
memmove, in addition to a function call overhead. The fix results in a
2-instruction clear for simple types.

Compiling the following (-O2 -save-temps) shows the difference:

#include <vector>

using std::vector;

int main() {
  vector<int> v;

  asm("#start1");
  v.clear();
  asm("#end1");

  asm("#start2");
  v.erase(v.begin(), v.end());
  asm("#end2");
}

This was a notable performance difference between libstdc++ stl and stlport I
found in profiling a large application.

-- 
           Summary: vector::clear should be manually inlined
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkho at ucla dot edu
                CC: dank at kegel dot com,gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23425


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-23425-11148@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2005-11-02 16:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-16 18:26 [Bug libstdc++/23425] New: vector::clear should be manually inlined tkho at ucla dot edu
2005-08-16 18:32 ` [Bug libstdc++/23425] " tkho at ucla dot edu
2005-08-16 18:44 ` [Bug libstdc++/23425] New: " Andrew Pinski
2005-08-16 18:46 ` [Bug libstdc++/23425] " pinskia at physics dot uc dot edu
2005-08-16 20:26 ` fang at csl dot cornell dot edu
2005-08-17  2:26 ` pinskia at gcc dot gnu dot org
2005-08-18  7:26 ` phython at gcc dot gnu dot org
     [not found] <bug-23425-11148@http.gcc.gnu.org/bugzilla/>
2005-11-02 10:29 ` pcarlini at suse dot de
2005-11-02 10:29 ` pcarlini at suse dot de
2005-11-02 16:24 ` paolo at gcc dot gnu dot org

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