summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-29 11:06:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-01 08:30:18 +0200
commit5200a73627d13e2997f81b53f61e143e77e328ee (patch)
treef95c8346d061ecd0ad33d574895d18e169662785 /basic
parentb90d3d316dd9c720c83180b31f6bbd7003fead78 (diff)
use more string_view in various
found by examining uses of OUString::copy() for likely places Change-Id: I6ff20e7b273ad6005410b82719183c1122f8c018 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133617 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/codegen.cxx15
-rw-r--r--basic/source/comp/scanner.cxx5
-rw-r--r--basic/source/runtime/methods.cxx18
3 files changed, 20 insertions, 18 deletions
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index e2f675a369de..9f2f4960bf9a 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -31,6 +31,7 @@
#include <algorithm>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
#include <com/sun/star/script/ModuleType.hpp>
// nInc is the increment size of the buffers
@@ -200,24 +201,24 @@ void SbiCodeGen::Save()
if( nIfaceCount )
{
int nPropPrefixFound = aProcName.indexOf("Property ");
- OUString aPureProcName = aProcName;
- OUString aPropPrefix;
+ std::u16string_view aPureProcName = aProcName;
+ std::u16string_view aPropPrefix;
if( nPropPrefixFound == 0 )
{
- aPropPrefix = aProcName.copy( 0, 13 ); // 13 == Len( "Property ?et " )
- aPureProcName = aProcName.copy( 13 );
+ aPropPrefix = aProcName.subView( 0, 13 ); // 13 == Len( "Property ?et " )
+ aPureProcName = aProcName.subView( 13 );
}
for( int i = 0 ; i < nIfaceCount ; i++ )
{
const OUString& rIfaceName = pParser->aIfaceVector[i];
- int nFound = aPureProcName.indexOf( rIfaceName );
- if( nFound == 0 && aPureProcName[rIfaceName.getLength()] == '_' )
+ bool bFound = o3tl::starts_with(aPureProcName, rIfaceName );
+ if( bFound && aPureProcName[rIfaceName.getLength()] == '_' )
{
if( nPropPrefixFound == 0 )
{
aIfaceProcName.append(aPropPrefix);
}
- aIfaceProcName.append(aPureProcName.subView(rIfaceName.getLength() + 1) );
+ aIfaceProcName.append(aPureProcName.substr(rIfaceName.getLength() + 1) );
aIfaceName = rIfaceName;
nPassCount = 2;
break;
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index a0d9b9ab6c76..63d525939459 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -27,6 +27,7 @@
#include <svl/numformat.hxx>
#include <svl/zforlist.hxx>
#include <rtl/character.hxx>
+#include <o3tl/string_view.hxx>
SbiScanner::SbiScanner(const OUString& rBuf, StarBASIC* p)
: aBuf(rBuf)
@@ -160,8 +161,8 @@ void SbiScanner::scanGoto()
if(n + 1 < aLine.getLength())
{
- OUString aTemp = aLine.copy(n, 2);
- if(aTemp.equalsIgnoreAsciiCase("to"))
+ std::u16string_view aTemp = aLine.subView(n, 2);
+ if(o3tl::equalsIgnoreAsciiCase(aTemp, u"to"))
{
aSym = "goto";
nLineIdx += n + 2 - nCol;
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 972038744dae..8cc49c2a5024 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1911,7 +1911,7 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
break;
bool bUseTwoDigitYear = false;
- OUString aYearStr, aMonthStr, aDayStr;
+ std::u16string_view aYearStr, aMonthStr, aDayStr;
if (nLen == 6 || nLen == 8 || nLen == 9)
{
// ((Y)YY)YYMMDD
@@ -1921,9 +1921,9 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
const sal_Int32 nMonthPos = (nLen == 8 ? 4 : (nLen == 6 ? 2 : 5));
if (nMonthPos == 2)
bUseTwoDigitYear = true;
- aYearStr = aStr.copy( 0, nMonthPos );
- aMonthStr = aStr.copy( nMonthPos, 2 );
- aDayStr = aStr.copy( nMonthPos + 2, 2 );
+ aYearStr = aStr.subView( 0, nMonthPos );
+ aMonthStr = aStr.subView( nMonthPos, 2 );
+ aDayStr = aStr.subView( nMonthPos + 2, 2 );
}
else
{
@@ -1934,9 +1934,9 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
if (aStr.indexOf('-', nMonthSep + 1) != nMonthSep + 3)
break;
- aYearStr = aStr.copy( 0, nMonthSep );
- aMonthStr = aStr.copy( nMonthSep + 1, 2 );
- aDayStr = aStr.copy( nMonthSep + 4, 2 );
+ aYearStr = aStr.subView( 0, nMonthSep );
+ aMonthStr = aStr.subView( nMonthSep + 1, 2 );
+ aDayStr = aStr.subView( nMonthSep + 4, 2 );
if ( !comphelper::string::isdigitAsciiString(aYearStr) ||
!comphelper::string::isdigitAsciiString(aMonthStr) ||
!comphelper::string::isdigitAsciiString(aDayStr))
@@ -1944,8 +1944,8 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool)
}
double dDate;
- if (!implDateSerial( static_cast<sal_Int16>(nSign * aYearStr.toInt32()),
- static_cast<sal_Int16>(aMonthStr.toInt32()), static_cast<sal_Int16>(aDayStr.toInt32()),
+ if (!implDateSerial( static_cast<sal_Int16>(nSign * o3tl::toInt32(aYearStr)),
+ static_cast<sal_Int16>(o3tl::toInt32(aMonthStr)), static_cast<sal_Int16>(o3tl::toInt32(aDayStr)),
bUseTwoDigitYear, SbDateCorrection::None, dDate ))
break;