[Libreoffice] Replace (Byte|Uni|Xub_)String with O(U)String: Fill() method is missing

Stephan Bergmann sbergman at redhat.com
Mon Oct 31 01:15:31 PDT 2011


On 10/29/2011 10:18 PM, Chr. Rossmanith wrote:
> the deprecated string classes have a Fill(n,c) method which fills a
> string with a single character c repeated n times. I found ~50
> occurrences of Fill() using "git grep", so it might be worth to add a
> Fill() method to OUString. Maybe the name of the new method could be a
> bit more verbose e.g. fillWithChar().
>
> Probably I would have to add something similar to "OUString
> fillWithChar(sal_uInt32 nNumber,|sal_Unicode cChar=' '|)" to ustring.hxx
> and something like rtl_ustr_fillWithChar() to ustring.c|

This functionality IMO only makes sense as a constructor (esp. for 
immutable OUString), like

   rtl::OUString::OUString(sal_Unicode value, sal_Int32 count);

and probably some underlying C function like

   void rtl_uString_newFromValueAndCount(
     rtl_uString **, sal_Unicode value, sal_Int32 count);

However, I would also be sceptical that there are that many places that 
actually need to construct such an (immutable!) string---maybe at least 
some of the places are misguided attempts at preallocating some buffer 
of a given length?  Those should then be rewritten to use 
rtl::OUStringBuffer instead.

Stephan


More information about the LibreOffice mailing list