OUString is mutable?
Stephan Bergmann
sbergman at redhat.com
Mon Oct 1 01:15:56 PDT 2012
On 09/28/2012 01:46 PM, Noel Grandin wrote:
> I don't really understand the point of not being able to mutate OUString
> in-place, but being able to overwrite it via the assignment operator?
>
> It seems to me it should be one or the other.
> Either OUString is immutable, and it cannot be assigned to, except via a
> constructor, or it is mutable, and we can pretty much throw away
> OUStringBuffer.
Note that the rtl string functionality had originally been designed,
arguably somewhat naively, after java.lang.String. On the Java
platform, immutability of String is an important security measure.
While that argument is irrelevant in a C/C++ context, immutability is
also an important concept when reasoning about multi-threaded code.
Therefore, the distinction between OUString and OUStringBuffer IMO does
make sense after all.
(The confusion about apparent mutability that arises from OUString's
split into a smart-pointer and the actual payload has already been
covered in this thread.)
Stephan
More information about the LibreOffice
mailing list