elide some string copies
Change-Id: I3e0d9f7e5a446689e007b9d01fb1c6bf9bc068e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136880 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -406,13 +406,13 @@ CreateStream(uno::Reference<embed::XStorage> const& xStorage,
|
||||
|
||||
if (xStorage->hasByName(filename))
|
||||
{
|
||||
OUString basename;
|
||||
OUString suffix;
|
||||
std::u16string_view basename;
|
||||
std::u16string_view suffix;
|
||||
sal_Int32 const nIndex(rFilename.lastIndexOf('.'));
|
||||
if (0 < nIndex)
|
||||
{
|
||||
basename = rFilename.copy(0, nIndex);
|
||||
suffix = rFilename.copy(nIndex);
|
||||
basename = rFilename.subView(0, nIndex);
|
||||
suffix = rFilename.subView(nIndex);
|
||||
}
|
||||
sal_Int32 count(0); // sigh... try to generate non-existent name
|
||||
do
|
||||
|
||||
@@ -719,9 +719,9 @@ TextSelection EditorWindow::GetLastHighlightPortionTextSelection() const
|
||||
if( aPortions.empty() )
|
||||
return TextSelection();
|
||||
|
||||
OUString sStr = aLine.copy( r.nBegin, r.nEnd - r.nBegin );
|
||||
std::u16string_view sStr = aLine.subView( r.nBegin, r.nEnd - r.nBegin );
|
||||
TextPaM aStart( nLine, r.nBegin );
|
||||
TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
|
||||
TextPaM aEnd( nLine, r.nBegin + sStr.size() );
|
||||
return TextSelection( aStart, aEnd );
|
||||
}
|
||||
|
||||
|
||||
@@ -105,9 +105,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
|
||||
aOUSource = aOUSource.copy( 0, nSourceLen-1 );
|
||||
}
|
||||
|
||||
OUString aSubStr = "Sub " + aMacroName + "\n\nEnd Sub";
|
||||
|
||||
aOUSource += aSubStr;
|
||||
aOUSource += "Sub " + aMacroName + "\n\nEnd Sub";
|
||||
|
||||
// update module in library
|
||||
StarBASIC* pBasic = dynamic_cast<StarBASIC*>(pModule->GetParent());
|
||||
|
||||
@@ -584,9 +584,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
|
||||
else
|
||||
nEndPos++;
|
||||
|
||||
OUString aEndStr = rStr.copy( nEndPos );
|
||||
rStr = rStr.copy( 0, nStartPos );
|
||||
rStr += aEndStr;
|
||||
rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( nEndPos );
|
||||
|
||||
// erase trailing empty lines
|
||||
{
|
||||
@@ -600,9 +598,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
|
||||
|
||||
if ( n > nStartPos )
|
||||
{
|
||||
aEndStr = rStr.copy( n );
|
||||
rStr = rStr.copy( 0, nStartPos );
|
||||
rStr += aEndStr;
|
||||
rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( n );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ bool XMLFontFamilyNamePropHdl::exportXML( OUString& rStrExpValue, const uno::Any
|
||||
sValue.append( ' ' );
|
||||
}
|
||||
sal_Int32 nLen = nLast-nFirst+1;
|
||||
OUString sFamily( aStrFamilyName.copy( nFirst, nLen ) );
|
||||
std::u16string_view sFamily( aStrFamilyName.subView( nFirst, nLen ) );
|
||||
bool bQuote = false;
|
||||
for( sal_Int32 i=0; i < nLen; i++ )
|
||||
{
|
||||
|
||||
@@ -3323,13 +3323,12 @@ void XMLAnnotationImportContext::PrepareField(
|
||||
}
|
||||
aDateBuffer.setLength(0);
|
||||
|
||||
OUString sBuffer = aTextBuffer.makeStringAndClear();
|
||||
if ( sBuffer.getLength() )
|
||||
if ( aTextBuffer.getLength() )
|
||||
{
|
||||
// delete last paragraph mark (if necessary)
|
||||
if (char(0x0a) == sBuffer[sBuffer.getLength()-1])
|
||||
sBuffer = sBuffer.copy(0, sBuffer.getLength()-1);
|
||||
xPropertySet->setPropertyValue(sAPI_content, Any(sBuffer));
|
||||
if (char(0x0a) == aTextBuffer[aTextBuffer.getLength()-1])
|
||||
aTextBuffer.setLength(aTextBuffer.getLength()-1);
|
||||
xPropertySet->setPropertyValue(sAPI_content, Any(aTextBuffer.makeStringAndClear()));
|
||||
}
|
||||
|
||||
if (!aName.isEmpty())
|
||||
|
||||
@@ -64,20 +64,18 @@ void XMLDocumentTransformerContext::StartElement( const Reference< XAttributeLis
|
||||
IsXMLToken( aLocalName, XML_MIMETYPE ) )
|
||||
{
|
||||
const OUString& rValue = xAttrList->getValueByIndex( i );
|
||||
static const char * aTmp[] =
|
||||
static constexpr std::string_view aTmp[]
|
||||
{
|
||||
"application/vnd.oasis.openoffice.",
|
||||
"application/x-vnd.oasis.openoffice.",
|
||||
"application/vnd.oasis.opendocument.",
|
||||
"application/x-vnd.oasis.document.",
|
||||
nullptr
|
||||
"application/x-vnd.oasis.document."
|
||||
};
|
||||
for (int k=0; aTmp[k]; k++)
|
||||
for (const auto & rPrefix : aTmp)
|
||||
{
|
||||
OUString sTmpString = OUString::createFromAscii(aTmp[k]);
|
||||
if( rValue.matchAsciiL( aTmp[k], sTmpString.getLength() ) )
|
||||
if( rValue.matchAsciiL( rPrefix.data(), rPrefix.size() ) )
|
||||
{
|
||||
aClass = rValue.copy( sTmpString.getLength() );
|
||||
aClass = rValue.copy( rPrefix.size() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1332,11 +1332,9 @@ bool XMLTransformerBase::ConvertURIToOOo( OUString& rURI,
|
||||
|
||||
if( bPackage && bSupportPackage )
|
||||
{
|
||||
OUString sTmp( '#' );
|
||||
if( rURI.startsWith( "./" ) )
|
||||
rURI = rURI.copy( 2 );
|
||||
sTmp += rURI;
|
||||
rURI = sTmp;
|
||||
rURI = "#" + rURI;
|
||||
bRet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <osl/nlsupport.h>
|
||||
#include <osl/process.h>
|
||||
#include <o3tl/char16_t2wchar_t.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
@@ -77,9 +78,9 @@ findTypeInDN(const OUString& rRawString, std::u16string_view sTypeName)
|
||||
{
|
||||
if (! bInValue)
|
||||
{
|
||||
OUString sType = rRawString.copy(nTypeNameStart, i - nTypeNameStart);
|
||||
sType = sType.trim();
|
||||
if (sType.equalsIgnoreAsciiCase(sTypeName))
|
||||
std::u16string_view sType = rRawString.subView(nTypeNameStart, i - nTypeNameStart);
|
||||
sType = o3tl::trim(sType);
|
||||
if (o3tl::equalsIgnoreAsciiCase(sType, sTypeName))
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
|
||||
@@ -152,9 +152,9 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
|
||||
OString SanExtensionImpl::removeOIDFromString( const OString &oidString)
|
||||
{
|
||||
OString objID;
|
||||
OString oid("OID.");
|
||||
constexpr std::string_view oid("OID.");
|
||||
if (oidString.match(oid))
|
||||
objID = oidString.copy(oid.getLength());
|
||||
objID = oidString.copy(oid.size());
|
||||
else
|
||||
objID = oidString;
|
||||
return objID;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <certificateextension_xmlsecimpl.hxx>
|
||||
|
||||
#include "sanextension_nssimpl.hxx"
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <tools/time.hxx>
|
||||
#include <svl/sigstruct.hxx>
|
||||
|
||||
@@ -185,9 +186,9 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
|
||||
|
||||
// remove "OID." prefix if existing
|
||||
OString objID;
|
||||
OString oid("OID.");
|
||||
constexpr std::string_view oid("OID.");
|
||||
if (oidString.match(oid))
|
||||
objID = oidString.copy(oid.getLength());
|
||||
objID = oidString.copy(oid.size());
|
||||
else
|
||||
objID = oidString;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user