diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-12-17 22:02:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-19 17:53:06 +0100 |
commit | 46c5de832868d2812448b2caace3eeaa9237b9f6 (patch) | |
tree | 6f25538cfb7a0def54ff7ac5b6b17eb22a76178a /xmloff | |
parent | 6dd1d2268487920e8bda44dfd169a5bda4d62f13 (diff) |
make *String(string_view) constructors explicit
to make it more obvious when we are constructing heap OUStrings
code and potentially inadvertently throwing away performance.
And fix a handful of places so revealed.
Change-Id: I0cf390f78026f8a670aaab53424cd31510633051
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107923
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmluconv.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/draw/animimp.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/draw/shapeimport.cxx | 18 | ||||
-rw-r--r-- | xmloff/source/draw/ximpcustomshape.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 2 |
5 files changed, 34 insertions, 25 deletions
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 48c94ed3a3fb..8c137e131427 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -504,34 +504,34 @@ bool SvXMLTokenEnumerator::getNextToken( OUString& rToken ) return true; } -static bool lcl_getPositions(const OUString& _sValue,OUString& _rContentX,OUString& _rContentY,OUString& _rContentZ) +static bool lcl_getPositions(std::u16string_view _sValue, OUString& _rContentX, OUString& _rContentY, OUString& _rContentZ) { - if(_sValue.isEmpty() || _sValue[0] != '(') + if(_sValue.empty() || _sValue[0] != '(') return false; - sal_Int32 nPos(1); - sal_Int32 nFound = _sValue.indexOf(' ', nPos); + size_t nPos(1); + size_t nFound = _sValue.find(' ', nPos); - if(nFound == -1 || nFound <= nPos) + if(nFound == std::u16string_view::npos || nFound <= nPos) return false; - _rContentX = _sValue.copy(nPos, nFound - nPos); + _rContentX = _sValue.substr(nPos, nFound - nPos); nPos = nFound + 1; - nFound = _sValue.indexOf(' ', nPos); + nFound = _sValue.find(' ', nPos); - if(nFound == -1 || nFound <= nPos) + if(nFound == std::u16string_view::npos || nFound <= nPos) return false; - _rContentY = _sValue.copy(nPos, nFound - nPos); + _rContentY = _sValue.substr(nPos, nFound - nPos); nPos = nFound + 1; - nFound = _sValue.indexOf(')', nPos); + nFound = _sValue.find(')', nPos); - if(nFound == -1 || nFound <= nPos) + if(nFound == std::u16string_view::npos || nFound <= nPos) return false; - _rContentZ = _sValue.copy(nPos, nFound - nPos); + _rContentZ = _sValue.substr(nPos, nFound - nPos); return true; } diff --git a/xmloff/source/draw/animimp.cxx b/xmloff/source/draw/animimp.cxx index 3ae369745f43..de189cab7d22 100644 --- a/xmloff/source/draw/animimp.cxx +++ b/xmloff/source/draw/animimp.cxx @@ -325,12 +325,12 @@ namespace constexpr OUStringLiteral gsDimColor = u"DimColor"; constexpr OUStringLiteral gsDimHide = u"DimHide"; constexpr OUStringLiteral gsDimPrev = u"DimPrevious"; - constexpr std::u16string_view gsEffect = u"Effect"; + constexpr OUStringLiteral gsEffect = u"Effect"; constexpr OUStringLiteral gsPlayFull = u"PlayFull"; constexpr OUStringLiteral gsSound = u"Sound"; constexpr OUStringLiteral gsSoundOn = u"SoundOn"; constexpr OUStringLiteral gsSpeed = u"Speed"; - constexpr std::u16string_view gsTextEffect = u"TextEffect"; + constexpr OUStringLiteral gsTextEffect = u"TextEffect"; constexpr OUStringLiteral gsPresShapeService = u"com.sun.star.presentation.Shape"; constexpr OUStringLiteral gsAnimPath = u"AnimationPath"; constexpr OUStringLiteral gsIsAnimation = u"IsAnimation"; @@ -546,8 +546,10 @@ void XMLAnimationsEffectContext::endFastElement(sal_Int32 ) { const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW ); - auto const s = mbTextEffect ? gsTextEffect : gsEffect; - xSet->setPropertyValue( s, makeAny( eEffect ) ); + if (mbTextEffect) + xSet->setPropertyValue( gsTextEffect, makeAny( eEffect ) ); + else + xSet->setPropertyValue( gsEffect, makeAny( eEffect ) ); xSet->setPropertyValue( gsSpeed, makeAny( meSpeed ) ); if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() ) diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index bf0b1d7a951b..2ac15ae78ed5 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -112,10 +112,10 @@ struct XMLShapeImportHelperImpl bool mbIsPresentationShapesSupported; }; -const std::u16string_view gsStartShape(u"StartShape"); -const std::u16string_view gsEndShape(u"EndShape"); -const std::u16string_view gsStartGluePointIndex(u"StartGluePointIndex"); -const std::u16string_view gsEndGluePointIndex(u"EndGluePointIndex"); +const OUStringLiteral gsStartShape(u"StartShape"); +const OUStringLiteral gsEndShape(u"EndShape"); +const OUStringLiteral gsStartGluePointIndex(u"StartGluePointIndex"); +const OUStringLiteral gsEndGluePointIndex(u"EndGluePointIndex"); XMLShapeImportHelper::XMLShapeImportHelper( SvXMLImport& rImporter, @@ -819,10 +819,16 @@ void XMLShapeImportHelper::restoreConnections() mrImporter.getInterfaceToIdentifierMapper().getReference( rHint.aDestShapeId ), uno::UNO_QUERY ); if( xShape.is() ) { - xConnector->setPropertyValue( rHint.bStart ? gsStartShape : gsEndShape, uno::Any(xShape) ); + if (rHint.bStart) + xConnector->setPropertyValue( gsStartShape, uno::Any(xShape) ); + else + xConnector->setPropertyValue( gsEndShape, uno::Any(xShape) ); sal_Int32 nGlueId = rHint.nDestGlueId < 4 ? rHint.nDestGlueId : getGluePointId( xShape, rHint.nDestGlueId ); - xConnector->setPropertyValue( rHint.bStart ? gsStartGluePointIndex : gsEndGluePointIndex, uno::Any(nGlueId) ); + if(rHint.bStart) + xConnector->setPropertyValue( gsStartGluePointIndex, uno::Any(nGlueId) ); + else + xConnector->setPropertyValue( gsEndGluePointIndex, uno::Any(nGlueId) ); } // #86637# restore line deltas diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index 897f8dcc375c..ebaf15651950 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -143,8 +143,9 @@ static void GetDoublePercentage( std::vector< css::beans::PropertyValue >& rDest return; rtl_math_ConversionStatus eStatus; - double fAttrDouble = ::rtl::math::stringToDouble( rValue, - '.', ',', &eStatus ); + double fAttrDouble = rtl_math_stringToDouble(rValue.data(), + rValue.data() + rValue.size(), + '.', ',', &eStatus, nullptr); if ( eStatus == rtl_math_ConversionStatus_Ok ) { beans::PropertyValue aProp; diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 4fdad0a36ee2..02632fa08c8b 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -1140,7 +1140,7 @@ namespace xmloff exportStringPropertyAttribute( OAttributeMetaData::getSpecialAttributeNamespace( nStringPropertyAttributeIds[i] ), OAttributeMetaData::getSpecialAttributeName( nStringPropertyAttributeIds[i] ), - pStringPropertyNames[i] + OUString(pStringPropertyNames[i]) ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking |