Re: String COW?

From: Kinkie <gkinkie_at_gmail.com>
Date: Wed, 21 Jan 2009 16:07:19 +0100

On Wed, Jan 21, 2009 at 1:07 PM, Henrik Nordstrom
<henrik_at_henriknordstrom.net> wrote:
> Still reading the IRC meeting notes regarding String/Buffer, and I
> stubled across COWs.. Had forgot we has such beasts flying around in the
> Sting/Buffer discussion.
>
> in what context do we need COW? We very very rarely modify anything. We
> copy lots of crap around just for the sake of copying, and making
> strings null terminated (either in-place or by copying, doesn't really
> matter).
>
> With String being backed by a refcounted store copying is eleminated.

COW may be triggered by the need to null-terminate a String or a
Buffer for exporting, or to invoke legacy libC calls which do not have
a variant with a length argument (sscanf..).. There is only one call
which does in-place modification right now, which is setAt, more as a
proof-of-concept than as an actual user.

> In the rare cases that the strings really need to be modified then a
> copy in a structured manner is needed. And is imho best done by a
> explicit interface.

Do you have anything specific in mind?

-- 
    /kinkie
Received on Wed Jan 21 2009 - 16:15:58 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 21 2009 - 12:00:26 MST