[Libreoffice] [PUSHED] Re: [PATCH] Easy Hacks : Use RTL_CONSTASCII_USTRINGPARAM macro bis
Caolán McNamara
caolanm at redhat.com
Sat Oct 30 14:08:21 PDT 2010
On Sat, 2010-10-30 at 22:23 +0200, Gert Faller wrote:
> Hi,
>
> here are some more of them.
Great, thanks.
Looking at this createFromAscii_4.patch reminds me of something else.
Nothing to do with you, the code was this way already, but
rtl::OUString foo = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("apple"));
is rather unnecessarily verbose
rtl::OUString foo(RTL_CONSTASCII_USTRINGPARAM("apple"));
is far easier on the eye and is equivalent.
Looking at createFromAscii_2.patch I see it affects a ternary operator
(i.e. ?:) so..
#define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) constAsciiStr,
((sal_Int32)(sizeof(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
old: OUString sFoo(OUString::createFromAscii(bBool ? "true" : "false));
new: OUString sFoo(RTL_CONSTASCII_USTRINGPARAM(bBool ? "true" :
"false));
would be expanded as...
OUString sFoo(bBool ? "true" : "false, ((sal_Int32)(sizeof(bBool ?
"true" : "false)-1));
I think this is fine, but I'm a little bit wary of making that change
while sleep-deprived given the occasional gotchas messing with ternary
operators can have, e.g.
http://blogs.linux.ie/caolan/2009/04/15/ternary-operator-blues/
so everything pushed except that I've omitted createFromAscii_2.patch
for now.
C.
More information about the LibreOffice
mailing list