connectivity/source/drivers/ado/AConnection.cxx |   15 +++++++++------
 connectivity/source/inc/ado/AConnection.hxx     |    3 ++-
 2 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit ed4627a868b94c05797ed30abe8d9f775ee3060f
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Wed Apr 20 08:09:00 2022 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Wed Apr 20 10:09:05 2022 +0200

    loplugin:stringviewparam
    
    Not sure if the given url is guaranteed to be of a form so that neither of 
the
    two url.find(':') could return npos, but lets mimic the original code 
faithfully
    for now.
    
    Change-Id: Ib525b42ccb5b19b4bc13729f973248cf1c8713de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133192
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/connectivity/source/drivers/ado/AConnection.cxx 
b/connectivity/source/drivers/ado/AConnection.cxx
index 0287ee9e050f..2756a4c5d0d9 100644
--- a/connectivity/source/drivers/ado/AConnection.cxx
+++ b/connectivity/source/drivers/ado/AConnection.cxx
@@ -19,6 +19,7 @@
 
 #include <sal/config.h>
 
+#include <cstddef>
 #include <string_view>
 
 #include <ado/AConnection.hxx>
@@ -34,6 +35,7 @@
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <comphelper/servicehelper.hxx>
 #include <connectivity/dbexception.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/file.hxx>
 #include <systools/win32/oleauto.hxx>
 #include <strings.hrc>
@@ -81,17 +83,18 @@ OConnection::~OConnection()
 {
 }
 
-void OConnection::construct(const OUString& url,const Sequence< PropertyValue 
>& info)
+void OConnection::construct(std::u16string_view url,const Sequence< 
PropertyValue >& info)
 {
     osl_atomic_increment( &m_refCount );
 
     setConnectionInfo(info);
 
-    sal_Int32 nLen = url.indexOf(':');
-    nLen = url.indexOf(':',nLen+1);
-    OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
-    if ( aDSN.startsWith("access:") )
-        aDSN = aDSN.copy(7);
+    std::size_t nLen = url.find(':');
+    nLen = url.find(':',nLen == std::u16string_view::npos ? 0 : nLen+1);
+    std::u16string_view aDSN(url.substr(nLen == std::u16string_view::npos ? 0 
: nLen+1));
+    OUString aUID,aPWD;
+    if ( o3tl::starts_with(aDSN, u"access:") )
+        aDSN.remove_prefix(7);
 
     sal_Int32 nTimeout = 20;
     const PropertyValue *pIter  = info.getConstArray();
diff --git a/connectivity/source/inc/ado/AConnection.hxx 
b/connectivity/source/inc/ado/AConnection.hxx
index 3e7581ec6d03..c2c82100363d 100644
--- a/connectivity/source/inc/ado/AConnection.hxx
+++ b/connectivity/source/inc/ado/AConnection.hxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <map>
+#include <string_view>
 #include <connectivity/CommonTools.hxx>
 #include <OTypeInfo.hxx>
 #include <TConnection.hxx>
@@ -71,7 +72,7 @@ namespace connectivity::ado
             OConnection(ODriver*        _pDriver);
             //  OConnection(const SQLHANDLE _pConnectionHandle);
             ~OConnection() override;
-            void construct(const OUString& url,const css::uno::Sequence< 
css::beans::PropertyValue >& info);
+            void construct(std::u16string_view url,const css::uno::Sequence< 
css::beans::PropertyValue >& info);
 
             //XUnoTunnel
             virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;

Reply via email to