About Strings

Lubos Lunak l.lunak at suse.cz
Mon Mar 19 05:55:46 PDT 2012

On Monday 19 of March 2012, Noel Grandin wrote:
> On 2012-03-19 08:27, Lubos Lunak wrote:
> > That said, I myself dislike the buffer class. I doubt its
> > preallocation is a significant requirement for good performance
> > (especially given it's only 16 characters). I
> Even in Java, it's a code smell to allocate a StringBuffer object
> without specifying a pre-allocation size.
> Might make a good EasyHack to go through the code and change the places
> that allocate OUStringBuffer to give them a reasonable initial size?

 It might make a good EasyHack, but otherwise it seems like a waste of effort 
to me. Especially given that in some places finding out the reasonable 
initial size would not be worth the cost. It would be much simpler if we 
could raise the preallocation size to something more sensible, except that we 
can't, since surprise surprise that overhead remains there when 
OUStringBuffer::makeStringAndClear() converts it to OUString (one more reason 
why the buffer classes just do not make much sense).

 But let me ponder a bit more the idea of trying to get rid of the buffer 
class. Next thing on my todo for string classes is the efficient operator+, 
based on the proof of concept already posted to this list, which should make 
a lot of usage of the buffer classes obsolete, and it would throw away some 
work done for the suggested EasyHack. So I think it'd be better to evaluate 
this when that work is done, seeing how much usage of the buffer class would 
be there that would be actually justified. And even then, by that time, it 
might be simpler to just go with OUString::reserve().

 Lubos Lunak
 l.lunak at suse.cz

More information about the LibreOffice mailing list