Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 89065 invoked from network); 24 Sep 2007 21:17:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Sep 2007 21:17:22 -0000 Received: (qmail 14798 invoked by uid 500); 24 Sep 2007 21:17:12 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 14787 invoked by uid 500); 24 Sep 2007 21:17:12 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 14776 invoked by uid 99); 24 Sep 2007 21:17:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2007 14:17:12 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2007 21:19:25 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 268C771420F for ; Mon, 24 Sep 2007 14:16:51 -0700 (PDT) Message-ID: <8546881.1190668611154.JavaMail.jira@brutus> Date: Mon, 24 Sep 2007 14:16:51 -0700 (PDT) From: "Travis Vitek (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Updated: (STDCXX-492) std::string::operator+=() slow In-Reply-To: <30208173.1185137911359.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Travis Vitek updated STDCXX-492: -------------------------------- Attachment: string.patch Patch improves times of both basic_string<>::append() and basic_string<>::op+=(). I've looked at the gnu changelog format description, and it doesn't mention what to do when you are changing multiple overloads of the same functions. I'm guessing, here, but if that is wrong, please correct me. 2007-09-24 Travis Vitek STDCXX-492 * string (operator+=): replace call to append with push_back for performance. (append): avoid calling replace() from append if there is sufficient buffer space available for performance. (append): simplify append overload, move it to header and then inline it. (append): use _RWSTD_SIZE_T to avoid integer overflow problems that could lead to heap corruption. (push_back): call replace() instead of append when buffer reallocation required. cleanup. avoid integer overflow problem. * string.cc (append): moved append overload to header and make it inline. > std::string::operator+=() slow > ------------------------------ > > Key: STDCXX-492 > URL: https://issues.apache.org/jira/browse/STDCXX-492 > Project: C++ Standard Library > Issue Type: Bug > Components: 21. Strings > Affects Versions: 4.1.3 > Environment: gcc 4.1.2 on Linux/x86_64 > Reporter: Mark Brown > Assignee: Travis Vitek > Fix For: 4.2 > > Attachments: string.patch > > > Comparing overloads of string::operator+=() in stdcxx with the same functions in gcc 4.1.2, stdcxx is up to twice slower than gcc: > $ time ./op_plus_equal-stdcxx 100000000 0 > real 0m2.241s > user 0m1.932s > sys 0m0.204s > $ time ./op_plus_equal-stdcxx 100000000 1 > real 0m2.540s > user 0m2.344s > sys 0m0.196s > $ time ./op_plus_equal-stdcxx 100000000 2 > real 0m1.492s > user 0m1.308s > sys 0m0.184s > $ time ./op_plus_equal-gcc 100000000 0 > real 0m0.883s > user 0m0.728s > sys 0m0.156s > $ time ./op_plus_equal-gcc 100000000 1 > real 0m1.589s > user 0m1.424s > sys 0m0.168s > $ time ./op_plus_equal-gcc 100000000 2 > real 0m1.131s > user 0m0.976s > sys 0m0.156s > #include > #include > #include > int main (int argc, char *argv[]) > { > const int N = argc < 2 ? 1 : std::atoi (argv [1]); > const int op = argc < 3 ? 0 : std::atoi (argv [2]); > std::string str; > const std::string x ("x"); > if (op == 0) { > for (int i = 0; i < N; ++i) > str += 'x'; > } else if (op == 1) { > for (int i = 0; i < N; ++i) > str += "x"; > } else { > for (int i = 0; i < N; ++i) > str += x; > } > assert (str.size () == std::size_t (N)); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.