summaryrefslogtreecommitdiff
path: root/reportdesign
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 /reportdesign
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 'reportdesign')
-rw-r--r--reportdesign/source/core/misc/conditionalexpression.cxx32
-rw-r--r--reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx6
2 files changed, 19 insertions, 19 deletions
diff --git a/reportdesign/source/core/misc/conditionalexpression.cxx b/reportdesign/source/core/misc/conditionalexpression.cxx
index 97284c8b0d64..d8f37efc9578 100644
--- a/reportdesign/source/core/misc/conditionalexpression.cxx
+++ b/reportdesign/source/core/misc/conditionalexpression.cxx
@@ -97,8 +97,8 @@ namespace rptui
// must be identical
if ( _rExpression.getLength() < nLHSIndex )
return false;
- const OUString sExprPart1( _rExpression.copy( 0, nLHSIndex ) );
- const OUString sMatchExprPart1( sMatchExpression.copy( 0, nLHSIndex ) );
+ const std::u16string_view sExprPart1( _rExpression.subView( 0, nLHSIndex ) );
+ const std::u16string_view sMatchExprPart1( sMatchExpression.subView( 0, nLHSIndex ) );
if ( sExprPart1 != sMatchExprPart1 )
// the left-most expression parts do not match
return false;
@@ -107,11 +107,11 @@ namespace rptui
// must be identical, too
bool bHaveRHS( nRHSIndex != -1 );
sal_Int32 nRightMostIndex( bHaveRHS ? nRHSIndex : nLHSIndex );
- const OUString sMatchExprPart3( sMatchExpression.copy( nRightMostIndex + 2 ) );
- if ( _rExpression.getLength() < sMatchExprPart3.getLength() )
+ const std::u16string_view sMatchExprPart3( sMatchExpression.subView( nRightMostIndex + 2 ) );
+ if ( _rExpression.getLength() < static_cast<sal_Int32>(sMatchExprPart3.size()) )
// the expression is not even long enough to hold the right-most part of the match expression
return false;
- const OUString sExprPart3( _rExpression.copy( _rExpression.getLength() - sMatchExprPart3.getLength() ) );
+ const std::u16string_view sExprPart3( _rExpression.subView( _rExpression.getLength() - sMatchExprPart3.size() ) );
if ( sExprPart3 != sMatchExprPart3 )
// the right-most expression parts do not match
return false;
@@ -119,28 +119,28 @@ namespace rptui
// if we don't have an RHS, we're done
if ( !bHaveRHS )
{
- _out_rLHS = _rExpression.copy( sExprPart1.getLength(), _rExpression.getLength() - sExprPart1.getLength() - sExprPart3.getLength() );
+ _out_rLHS = _rExpression.copy( sExprPart1.size(), _rExpression.getLength() - sExprPart1.size() - sExprPart3.size() );
return true;
}
// strip the match expression by its right-most and left-most part, and by the placeholders $1 and $2
sal_Int32 nMatchExprPart2Start( nLHSIndex + sLHSPattern.getLength() );
- OUString sMatchExprPart2 = sMatchExpression.copy(
+ std::u16string_view sMatchExprPart2 = sMatchExpression.subView(
nMatchExprPart2Start,
- sMatchExpression.getLength() - nMatchExprPart2Start - sMatchExprPart3.getLength() - 2
+ sMatchExpression.getLength() - nMatchExprPart2Start - sMatchExprPart3.size() - 2
);
// strip the expression by its left-most and right-most part
- const OUString sExpression( _rExpression.copy(
- sExprPart1.getLength(),
- _rExpression.getLength() - sExprPart1.getLength() - sExprPart3.getLength()
+ const std::u16string_view sExpression( _rExpression.subView(
+ sExprPart1.size(),
+ _rExpression.getLength() - sExprPart1.size() - sExprPart3.size()
) );
- sal_Int32 nPart2Index = sExpression.indexOf( sMatchExprPart2 );
- if ( nPart2Index == -1 )
+ size_t nPart2Index = sExpression.find( sMatchExprPart2 );
+ if ( nPart2Index == std::u16string_view::npos )
// the "middle" part of the match expression does not exist in the expression at all
return false;
- OSL_ENSURE( sExpression.indexOf( sMatchExprPart2, nPart2Index + 1 ) == -1,
+ OSL_ENSURE( sExpression.find( sMatchExprPart2, nPart2Index + 1 ) == std::u16string_view::npos,
"ConditionalExpression::matchExpression: ambiguous matching!" );
// if this fires, then we're lost: The middle part exists two times in the expression,
// so we cannot reliably determine what's the LHS and what's the RHS.
@@ -154,8 +154,8 @@ namespace rptui
// Here, at the latest, you can see that we need another mechanism, anyway, which does not
// rely on those strange expression building/matching
- _out_rLHS = sExpression.copy( 0, nPart2Index );
- _out_rRHS = sExpression.copy( nPart2Index + sMatchExprPart2.getLength() );
+ _out_rLHS = sExpression.substr( 0, nPart2Index );
+ _out_rRHS = sExpression.substr( nPart2Index + sMatchExprPart2.size() );
return true;
}
diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
index 4e7fd13b47c7..fa0f29037320 100644
--- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
@@ -247,14 +247,14 @@ void SAL_CALL ImportDocumentHandler::startElement(const OUString & _sName, const
const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
for(sal_Int16 i = 0; i < nLength; ++i)
{
- OUString sLocalName;
+ std::u16string_view sLocalName;
const OUString sAttrName = _xAttrList->getNameByIndex( i );
const sal_Int32 nColonPos = sAttrName.indexOf( ':' );
if( -1 == nColonPos )
sLocalName = sAttrName;
else
- sLocalName = sAttrName.copy( nColonPos + 1 );
- if ( sLocalName == "data-source-has-labels" )
+ sLocalName = sAttrName.subView( nColonPos + 1 );
+ if ( sLocalName == u"data-source-has-labels" )
{
const OUString sValue = _xAttrList->getValueByIndex( i );
bHasCategories = sValue == "both";