[Libreoffice] [PATCH] Changed String to OUString in funcdesc.hxx

Soeren Moeller soerenmoeller2001 at gmail.com
Mon Jan 10 15:30:49 PST 2011


I have now added a function ResId::toString which returns an OUString
from a ResId to tools/inc/resid.hxx, and changed the old workaround to
use this function. I also have changed OUString to OUStringBuffer in
getSignature() and GetParamList(), and modified the operations in
these functions accordingly.

Attached two patches, one with the changes to the tools tree, the
other with the changes to the sc tree.

Please review and apply if ok
Regards
Sören Möller
(LGPLv3+ / MPL)

2011/1/10 Kohei Yoshida <kyoshida at novell.com>:
> On Sun, 2011-01-09 at 21:41 +0000, Caolán McNamara wrote:
>> On Sun, 2011-01-09 at 20:37 +0100, Soeren Moeller wrote:
>> > And here another patch for sc/inc/funcdesc.hxx and related source
>> > files,
>> ...
>> >(using casts when forced to use String originally because of ResId).
>>
>> Kohei will probably want to have a look at these, but as an aside, how
>> about adding something like
>>
>> static rtl::OUString toString(const ResId&)
>>
>> to the tools resid.hxx ResId class and hide the nasty convert cast
>> kludge in the impl of that, which could be tucked away in the old
>> tools/source/strucvt.cxx for now.
>
> Yeah, that would make the transition a bit smoother.  We get String
> instances from ResId in many places, and having a function like that
> would indeed hide the ugliness in one place.
>
> The alternative is to use String to create a temporary string instance
> from (Sc)ResId, then pass it on to the constructor of rtl::OUString.
> But that always adds the overhead of instantiating two string instances
> instead of one.  Even with that overhead; however, I prefer that over
> casting String to OUString as long as the code is not
> performance-critical.  But Caolan's suggestion would probably be the
> best approach given the current constraints surrounding (Sc)ResId,
> String, and OUString.
>
> BTW, a minor nitpick to Soeren's original patch.  In GetParamList() and
> getSignature(), you could consider using rtl::OUStringBuffer instead of
> rtl::OUString for better performance.  rtl::OUString is by design
> immutable, and it creates a new string instance every time you add a new
> string segment to it.  The String class OTOH is not immutable hence it
> is sometimes used as a string buffer.  Looking at the way it is used in
> GetParamList() and getSignature(), rtl::OUStringBuffer probably is a
> better replacement candidate.
>
> Kohei
>
> --
> Kohei Yoshida, LibreOffice hacker, Calc
> <kyoshida at novell.com>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-function-to-ResId-to-give-an-OUString-from-a-R.patch
Type: text/x-patch
Size: 1169 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110111/7f6d3bf5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-OUString-to-OUStringBuffer-and-fixed-ResId-to-OUStri.patch
Type: text/x-patch
Size: 6112 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110111/7f6d3bf5/attachment-0001.bin>


More information about the LibreOffice mailing list