From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30964 invoked by alias); 16 Aug 2005 18:24:39 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30670 invoked by uid 48); 16 Aug 2005 18:24:23 -0000 Date: Tue, 16 Aug 2005 18:26:00 -0000 From: "tkho at ucla dot edu" To: gcc-bugs@gcc.gnu.org Message-ID: <20050816182420.23425.tkho@ucla.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/23425] New: vector::clear should be manually inlined X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg01819.txt.bz2 List-Id: 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 using std::vector; int main() { vector 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