Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 87112 invoked from network); 3 Aug 2007 22:06:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 22:06:42 -0000 Received: (qmail 18836 invoked by uid 500); 3 Aug 2007 22:06:42 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 18812 invoked by uid 500); 3 Aug 2007 22:06:42 -0000 Mailing-List: contact stdcxx-commits-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-commits@incubator.apache.org Received: (qmail 18801 invoked by uid 99); 3 Aug 2007 22:06:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 15:06:42 -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.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 22:06:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9BDAC1A981A; Fri, 3 Aug 2007 15:06:19 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r562601 - /incubator/stdcxx/trunk/include/string Date: Fri, 03 Aug 2007 22:06:19 -0000 To: stdcxx-commits@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070803220619.9BDAC1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebor Date: Fri Aug 3 15:06:18 2007 New Revision: 562601 URL: http://svn.apache.org/viewvc?view=rev&rev=562601 Log: 2007-08-03 Mark Brown Farid Zaripov STDCXX-491 * string (push_back): Moved definition outside the basic_string class template and optimized so as to call append() only when reallocation is necessary. Modified: incubator/stdcxx/trunk/include/string Modified: incubator/stdcxx/trunk/include/string URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/string?view=diff&rev=562601&r1=562600&r2=562601 ============================================================================== --- incubator/stdcxx/trunk/include/string (original) +++ incubator/stdcxx/trunk/include/string Fri Aug 3 15:06:18 2007 @@ -23,7 +23,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 1994-2006 Rogue Wave Software. + * Copyright 1994-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -340,9 +340,7 @@ } // lwg issue 7 - void push_back (value_type __c) { - append (size_type (1), __c); - } + void push_back (value_type); basic_string& assign (const basic_string &__str) { return *this = __str; @@ -1083,6 +1081,24 @@ erase (__n, size () - __n); else replace (size (), size_type (), __n - size (), __c); +} + + +template +inline void basic_string<_CharT, _Traits, _Allocator>:: +push_back (value_type __c) +{ + const size_type __size = size () + 1; + + if ( capacity () < __size + || size_type (1) < size_type (_C_pref ()->_C_get_ref ())) + append (1, __c); + else { + traits_type::assign (_C_data [size ()], __c); + // append the terminating NUL character + traits_type::assign (_C_data [__size], value_type ()); + _C_pref ()->_C_size._C_size = __size; + } }