Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On Tue, Mar 19, 2013 at 03:13:02PM +0100, Stephan Bergmann wrote:

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,

Thanks for checking.

The string passed in argument is always of length 1, so in practise
the two will have the same behaviour. In the abstract, operator== is
"more correct" (and possibly future-proof against changes in
PostgreSQL internals) than startsWith.

The same holds for string2keytype.

-- 
Lionel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.