OUString is mutable?

Noel Grandin noel at peralex.com
Mon Oct 1 02:32:08 PDT 2012


On 2012-10-01 09:49, David Tardon wrote:
>   I find it perfectly reasonable that a variable of a value type (as
> opposed to polymorphic type) is assignable. In fact, I would be
> surprised if it were not. Value types are supposed to mimic the behavior
> of primitive types; that is why copy constructor and operator= are
> created by the compiler unless one disables them. You are not surprised
> that
>
>

David, I agree with you - what I'm really getting at here is that it 
seems perfectly reasonable to me to fold the functionality of 
OUStringBuffer into OUString, making our string classes that much simpler.
Otherwise we're going to end up constantly converting between the two 
for no good reason that I can see.

We'd have to make the following changes to struct rtl_uString:
- add (or steal from somewhere)  a single bit to indicate whether or not 
the buffer field contained a read-only array of chars
- a 'sal_uInt32 nCapacity' field.

And then we can make the OUString methods smart enough to do a 
copy-on-write if the OUString contains a read-only buffer.


Disclaimer: http://www.peralex.com/disclaimer.html




More information about the LibreOffice mailing list