From -2821950868412222359
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,25827c9ceb81badc
X-Google-Attributes: gidf78e5,public
From: jkanze@otelo.ibmmail.com
Subject: Re: string/cow/algorithm
Date: 1998/08/20
Message-ID: <6rhf1q$f35$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 383028528
X-NNTP-Posting-Host: 195.75.80.132
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <35D9AE1C.7553@pratique.fr>
X-UID: 0000000001
X-Status: $$$T
X-Http-User-Agent: Mozilla/4.03 [de] (WinNT; I)
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Thu Aug 20 15:23:38 1998 GMT
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <35D9AE1C.7553@pratique.fr>,
  bonnardv@pratique.fr wrote:
>
> Nathan Myers <ncm@nospam.cantrip.org> writes:
>
> > the reference-counted version is
> > *always* more efficient than the always-copying version.
>
> A text manipulation program written in pre-STL style
> using only operator[] would be significantly slower
> except if the optimiser is clever enough to understand
> that the string is always locked.

Independantly of this issue, Nathan's statement is remarkably
naive (as are almost all statements with both "always" and
"efficient" in them).  Rob Murray has some discussion about
this in his book (something with Strategies and Tactics in the
title, highly recommended); he actually ran some tests with
his implementation, rather than just speculating.

Reference counting has a definite cost, if only in setting up
the count in the constructor.  If you never copy any strings, you
pay for reference counting without using it.  In practice, of course,
it's almost impossible to write anything useful without copying a
string now and then; Rob Murray's benchmarks measured how much copying
was necessary (for his implementation) to break even.

> Both cow and non cow strings make sens.

Agreed.

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient�e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




