compareToAscii( RTL_CONSTASCII_STRINGPARAM( "something" ) )
Stephan Bergmann
sbergman at redhat.com
Thu Sep 6 02:12:41 PDT 2012
On 09/06/2012 09:37 AM, Jan Holesovsky wrote:
> hunk. In this case, the use of RTL_CONSTASCII_STRINGPARAM() kind of
> simulates "startsWith" (that we do not have as a method); ie. for
> rQAttributeName == "xmlns:SOMETHING":
>
> rQAttributeName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("xmlns:") ) == 0
>
> but
>
> rQAttributeName.compareToAscii( "xmlns:" ) > 0
Good catch; and the different semantics of the compareTo... overloads is
a horrible gotcha indeed.
> I wonder if it makes sense to introduce some kind of CONSTASCII_STRLEN()
> macro that would make this more obvious, and convert the
> rQAttributeName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("xmlns:") )
Not sure what you mean here. (And there already is
RTL_CONSTASCII_LENGTH, btw.)
> cases to that? Or even better, introduce a startsWith() [or just
> startsWithAscii() for the optimized case] method, like we did with the
> isEmpty()...
Note that "startsWith" is already covered by the various existing
match... functions, with a default fromIndex = 0.
Stephan
More information about the LibreOffice
mailing list