OUString is mutable?
Noel Grandin
noel at peralex.com
Fri Sep 28 06:52:07 PDT 2012
On 2012-09-28 15:37, Michael Meeks wrote:
> Hi Noel,
>
> On Fri, 2012-09-28 at 14:17 +0200, Noel Grandin wrote:
>> It just seems to me that we could easily enough steal a bit from the
>> length field to indicate that the buffer is immutable, and then we could
>> reduce our complexity by eliminating OUStringBuffer.
> We already steal bits from the ref-count for magic like this: static
> strings, and interned strings ;-)
>
> The question is - would it be more obvious if:
>
> void method(rtl::OUString &rFoo, rtl::OUString &rBaa)
> {
> rFoo += "foo"; // no exception it's mutable.
> rBaa += "baa"; // exception because it's immutable.
> }
>
> :-) i assume not. OTOH - I too am not a huge fan of the sal string
> classes for general usability - but I've not done a ton of work with
> them recently to be fair.
>
So that idea is workable - great.
In your example, it wouldn't throw an exception, it would simply notice
that it's internal buffer was immutable, allocate a new buffer, and
append the string to that.
I'm asking because I'm starting to do XubString/UniString -> OUString
cleanup work, and the work would be a lot simpler if we only had one
target - OUString.
Disclaimer: http://www.peralex.com/disclaimer.html
More information about the LibreOffice
mailing list