connectivity/source/drivers/postgresql/pq_xkeys.cxx: compareToAscii -> operator== sound?

Stephan Bergmann sbergman at redhat.com
Tue Mar 19 07:13:02 PDT 2013


> commit c69436f7b76237f2b99a29737dc897fb0a86bfd7
> Author: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
> Date:   Sat Jan 19 10:08:21 2013 -0200
>
>     fdo#57950: Remove some chained appends in connectivity and..
>
>     ... remove some RTL* macros.
>
>     Change-Id: I919d17e14334c9220b47775355512df8dfa00bca
>     Reviewed-on: https://gerrit.libreoffice.org/1768
>     Reviewed-by: Olivier Hallot <olivier.hallot at alta.org.br>
>     Tested-by: Olivier Hallot <olivier.hallot at alta.org.br>
>
> diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
> index 314924d..2a8d521 100644
> --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
> +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
> @@ -127,58 +126,17 @@ static sal_Int32 string2keytype( const rtl::OUString &type )
>  static sal_Int32 string2keyrule( const rtl::OUString & rule )
>  {
>      sal_Int32 ret = com::sun::star::sdbc::KeyRule::NO_ACTION;
> -    if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "r" ) ) == 0 )
> +    if( rule == "r" )
>          ret = com::sun::star::sdbc::KeyRule::RESTRICT;
> -    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "c" ) ) == 0 )
> +    else if( rule == "c" )
>          ret = com::sun::star::sdbc::KeyRule::CASCADE;
> -    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "n" ) ) == 0 )
> +    else if( rule == "n" )
>          ret = com::sun::star::sdbc::KeyRule::SET_NULL;
> -    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "d" ) ) == 0 )
> +    else if( rule == "d" )
>          ret = com::sun::star::sdbc::KeyRule::SET_DEFAULT;
>      return ret;
>  }

smells like an incorrect conversion from 
rtl::OUString::compareToAscii(asciiStr,maxLength) to operator== rather 
than rtl::OUString::startsWith, but then again, given the preceeding

> static sal_Int32 string2keytype( const rtl::OUString &type )
> {
>     sal_Int32 ret = com::sun::star::sdbcx::KeyType::UNIQUE;
>     if ( type == "p" )
>         ret = com::sun::star::sdbcx::KeyType::PRIMARY;
>     else if ( type == "f" )
>         ret =  com::sun::star::sdbcx::KeyType::FOREIGN;
>     return ret;
> }

I'm not really sure.

Stephan


More information about the LibreOffice mailing list