|
![](/i/fill.gif) |
Warp wrote:
> The problem is that it will make a copy of the string data every time
> it's modified, which is inefficient.
Yes. I understand that. I'm just saying that when you do this discussion,
don't discuss it using strings if Java is your target language. Java strings
are immutable. Discuss it using arrays of bytes, or something like that.
> If the string data is not shared, this is very efficient to do because
> it can be done in-place, without any kind of data copying. Imagine the
> string containing 10 megabytes of data, and you wanting to modify just
> the first character.
Yeah. You *can* do that sort of thing in Java. You just have to do it the
same way you do it in C: manually and error-prone. :-)
> Well, construction (including copy construction) and destruction are
> integral parts of CoW, because without them you wouldn't be able to
> perform reference counting (and this is exactly one of the aspects of
> RAII: resource acquisition and release).
OK. I just wasn't sure whether the assignment operator and such was
considered part of the support for RAII, but in retrospect, I guess it
wouldn't make sense for it not to be.
--
Darren New, San Diego CA, USA (PST)
Serving Suggestion:
"Don't serve this any more. It's awful."
Post a reply to this message
|
![](/i/fill.gif) |