diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-04 14:26:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-05 08:39:23 +0200 |
commit | d15a6560bd445cd1931e9fded6ad8ecfdd54211b (patch) | |
tree | dc23fce7925c88620abe8cc032b27f25b0a888e0 /connectivity | |
parent | c895edf3f67f19d8d2012674c084456a7851436e (diff) |
use more string_view
found by examining the call sites of OString::getToken
which means I needed to add a new o3tl::equalsAscii function
Change-Id: I7dc0ea1cf5ce8090a708d44f2cf7c938fa200c5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133826
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/hsqldb/HDriver.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 33 |
2 files changed, 19 insertions, 16 deletions
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index e108406b7d04..39475e715e5d 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -259,7 +259,7 @@ namespace connectivity if ( sLine.isEmpty() ) continue; sal_Int32 nIdx {0}; - const OString sIniKey = sLine.getToken(0, '=', nIdx); + const std::string_view sIniKey = o3tl::getToken(sLine, 0, '=', nIdx); const OString sValue = sLine.getToken(0, '=', nIdx); if( sIniKey == "hsqldb.compatible_version" ) { diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index 2feb2d2688d1..7410ad38e6fc 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -30,6 +30,7 @@ #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/typeprovider.hxx> #include <comphelper/seqstream.hxx> +#include <o3tl/safeint.hxx> #include <o3tl/string_view.hxx> using namespace rtl; @@ -292,24 +293,23 @@ Date SAL_CALL OResultSet::getDate(sal_Int32 column) if (checkNull(column)) return d; - OString dateStr = m_aRows[m_nRowPosition][column - 1]; + const OString& dateStr = m_aRows[m_nRowPosition][column - 1]; - OString dateString(dateStr); - OString token; + std::string_view dateString(dateStr); sal_Int32 nIndex = 0, i = 0; do { - token = dateString.getToken(0, '-', nIndex); + std::string_view token = o3tl::getToken(dateString, 0, '-', nIndex); switch (i) { case 0: - d.Year = static_cast<sal_uInt16>(token.toUInt32()); + d.Year = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; case 1: - d.Month = static_cast<sal_uInt16>(token.toUInt32()); + d.Month = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; case 2: - d.Day = static_cast<sal_uInt16>(token.toUInt32()); + d.Day = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; default:; } @@ -467,25 +467,28 @@ Time SAL_CALL OResultSet::getTime(sal_Int32 column) if (checkNull(column)) return t; - OString sVal = m_aRows[m_nRowPosition][column - 1]; - OString timeString{ sVal.getStr(), getDataLength(column) }; - OString token; + const OString& sVal = m_aRows[m_nRowPosition][column - 1]; + std::string_view timeString{ sVal.getStr(), o3tl::make_unsigned(getDataLength(column)) }; sal_Int32 nIndex, i = 0; - nIndex = timeString.indexOf(' ') + 1; + size_t idx = timeString.find(' '); + if (idx == std::string_view::npos) + nIndex = 0; + else + nIndex = idx + 1; do { - token = timeString.getToken(0, ':', nIndex); + std::string_view token = o3tl::getToken(timeString, 0, ':', nIndex); switch (i) { case 0: - t.Hours = static_cast<sal_uInt16>(token.toUInt32()); + t.Hours = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; case 1: - t.Minutes = static_cast<sal_uInt16>(token.toUInt32()); + t.Minutes = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; case 2: - t.Seconds = static_cast<sal_uInt16>(token.toUInt32()); + t.Seconds = static_cast<sal_uInt16>(o3tl::toUInt32(token)); break; } i++; |