[Libreoffice-commits] core.git: connectivity/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 23 06:52:27 UTC 2021


 connectivity/source/drivers/mysql_jdbc/YDriver.cxx             |   14 +++++++--
 connectivity/source/drivers/postgresql/pq_databasemetadata.cxx |   15 +++++-----
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx         |    9 ++++--
 3 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit bbcb3e68c75d9eb7da36788def8845a3e3e727f8
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 23 07:30:35 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 23 08:51:55 2021 +0200

    Extend loplugin:stringviewparam to starts/endsWith: connectivity
    
    Change-Id: I10a6f919034a83d134c92f3c510641c10c7c133d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122506
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
index ad8ce525feac..7ee501d42e81 100644
--- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
+++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
@@ -17,8 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <mysql/YDriver.hxx>
 #include <mysql/YCatalog.hxx>
+#include <o3tl/string_view.hxx>
 #include <comphelper/namedvaluecollection.hxx>
 #include <comphelper/servicehelper.hxx>
 #include <comphelper/types.hxx>
@@ -93,11 +98,14 @@ enum class T_DRIVERTYPE
     Native
 };
 
-bool isOdbcUrl(const OUString& _sUrl) { return _sUrl.startsWith("sdbc:mysql:odbc:"); }
+bool isOdbcUrl(std::u16string_view _sUrl) { return o3tl::starts_with(_sUrl, u"sdbc:mysql:odbc:"); }
 
-bool isNativeUrl(const OUString& _sUrl) { return _sUrl.startsWith("sdbc:mysql:mysqlc:"); }
+bool isNativeUrl(std::u16string_view _sUrl)
+{
+    return o3tl::starts_with(_sUrl, u"sdbc:mysql:mysqlc:");
+}
 
-T_DRIVERTYPE lcl_getDriverType(const OUString& _sUrl)
+T_DRIVERTYPE lcl_getDriverType(std::u16string_view _sUrl)
 {
     T_DRIVERTYPE eRet = T_DRIVERTYPE::Jdbc;
     if (isOdbcUrl(_sUrl))
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 8f2021608830..b6b7b44482bd 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -74,6 +74,7 @@
 #include "pq_statics.hxx"
 #include "pq_tools.hxx"
 
+#include <o3tl/string_view.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <sal/macros.h>
 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
@@ -1184,34 +1185,34 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getTables(
 namespace
 {
     // sort no schema first, then "public", then normal schemas, then internal schemas
-    int compare_schema(const OUString &nsA, const OUString &nsB)
+    int compare_schema(const OUString &nsA, std::u16string_view nsB)
     {
         if (nsA.isEmpty())
         {
-            return nsB.isEmpty() ? 0 : -1;
+            return nsB.empty() ? 0 : -1;
         }
-        else if (nsB.isEmpty())
+        else if (nsB.empty())
         {
             assert(!nsA.isEmpty());
             return 1;
         }
         else if(nsA == "public")
         {
-            return (nsB == "public") ? 0 : -1;
+            return (nsB == u"public") ? 0 : -1;
         }
-        else if(nsB == "public")
+        else if(nsB == u"public")
         {
             assert(nsA != "public");
             return 1;
         }
         else if(nsA.startsWith("pg_"))
         {
-            if(nsB.startsWith("pg_"))
+            if(o3tl::starts_with(nsB, u"pg_"))
                 return nsA.compareTo(nsB);
             else
                 return 1;
         }
-        else if(nsB.startsWith("pg_"))
+        else if(o3tl::starts_with(nsB, u"pg_"))
         {
             return -1;
         }
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 34d9ef38f36e..82d595628db3 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -34,6 +34,11 @@
  *
  ************************************************************************/
 
+#include <sal/config.h>
+
+#include <string_view>
+
+#include <o3tl/string_view.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
@@ -81,9 +86,9 @@ static Any isCurrency( const OUString & typeName )
 //         typeName.equalsIgnoreAsciiCase("bigserial");
 // }
 
-static Any isAutoIncrement( const OUString & defaultValue )
+static Any isAutoIncrement( std::u16string_view defaultValue )
 {
-    bool ret = defaultValue.startsWith( "nextval(" );
+    bool ret = o3tl::starts_with( defaultValue, u"nextval(" );
 //     printf( "%s %d\n",
 //             OUStringToOString(defaultValue, RTL_TEXTENCODING_ASCII_US).getStr(),
 //             ret );


More information about the Libreoffice-commits mailing list