comphelper/source/misc/mimeconfighelper.cxx        |   12 +++++---
 embeddedobj/source/commonembedding/persistence.cxx |    9 ++++--
 package/source/xstor/owriteablestream.cxx          |    3 +-
 package/source/xstor/xstorage.cxx                  |    3 +-
 sfx2/source/doc/docfile.cxx                        |    6 ++--
 sfx2/source/doc/sfxbasemodel.cxx                   |   27 +++++++++++++------
 svx/source/customshapes/EnhancedCustomShape2d.cxx  |   29 +++++++++++++--------
 7 files changed, 59 insertions(+), 30 deletions(-)

New commits:
commit 3322e500f48794d3569c27f73cc5f3bafb5f2397
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue May 10 14:09:04 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed May 11 09:24:42 2022 +0200

    avoid some OUString construction on some hot paths
    
    Change-Id: I098b017d22b7a4502998a0901ddcfca08a57ee43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134115
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/comphelper/source/misc/mimeconfighelper.cxx 
b/comphelper/source/misc/mimeconfighelper.cxx
index 0046c7f11d4f..8f24aa175592 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -267,10 +267,14 @@ bool MimeConfigurationHelper::GetVerbByShortcut( const 
OUString& aVerbShortcut,
         if ( xVerbsConfig.is() && ( xVerbsConfig->getByName( aVerbShortcut ) 
>>= xVerbsProps ) && xVerbsProps.is() )
         {
             embed::VerbDescriptor aTempDescr;
-            if ( ( xVerbsProps->getByName("VerbID") >>= aTempDescr.VerbID )
-              && ( xVerbsProps->getByName("VerbUIName") >>= 
aTempDescr.VerbName )
-              && ( xVerbsProps->getByName("VerbFlags") >>= 
aTempDescr.VerbFlags )
-              && ( xVerbsProps->getByName("VerbAttributes") >>= 
aTempDescr.VerbAttributes ) )
+            static constexpr OUStringLiteral sVerbID = u"VerbID";
+            static constexpr OUStringLiteral sVerbUIName = u"VerbUIName";
+            static constexpr OUStringLiteral sVerbFlags = u"VerbFlags";
+            static constexpr OUStringLiteral sVerbAttributes = 
u"VerbAttributes";
+            if ( ( xVerbsProps->getByName(sVerbID) >>= aTempDescr.VerbID )
+              && ( xVerbsProps->getByName(sVerbUIName) >>= aTempDescr.VerbName 
)
+              && ( xVerbsProps->getByName(sVerbFlags) >>= aTempDescr.VerbFlags 
)
+              && ( xVerbsProps->getByName(sVerbAttributes) >>= 
aTempDescr.VerbAttributes ) )
             {
                 aDescriptor = aTempDescr;
                 bResult = true;
diff --git a/embeddedobj/source/commonembedding/persistence.cxx 
b/embeddedobj/source/commonembedding/persistence.cxx
index b32d07f1c59c..e49e5169cc79 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -190,10 +190,13 @@ static void TransferMediaType( const uno::Reference< 
embed::XStorage >& i_rSourc
 static uno::Reference< util::XCloseable > CreateDocument( const 
uno::Reference< uno::XComponentContext >& _rxContext,
     const OUString& _rDocumentServiceName, bool _bEmbeddedScriptSupport, const 
bool i_bDocumentRecoverySupport )
 {
+    static constexpr OUStringLiteral sEmbeddedObject = u"EmbeddedObject";
+    static constexpr OUStringLiteral sEmbeddedScriptSupport = 
u"EmbeddedScriptSupport";
+    static constexpr OUStringLiteral sDocumentRecoverySupport = 
u"DocumentRecoverySupport";
     ::comphelper::NamedValueCollection aArguments;
-    aArguments.put( "EmbeddedObject", true );
-    aArguments.put( "EmbeddedScriptSupport", _bEmbeddedScriptSupport );
-    aArguments.put( "DocumentRecoverySupport", i_bDocumentRecoverySupport );
+    aArguments.put( sEmbeddedObject, true );
+    aArguments.put( sEmbeddedScriptSupport, _bEmbeddedScriptSupport );
+    aArguments.put( sDocumentRecoverySupport, i_bDocumentRecoverySupport );
 
     uno::Reference< uno::XInterface > xDocument;
     try
diff --git a/package/source/xstor/owriteablestream.cxx 
b/package/source/xstor/owriteablestream.cxx
index 9e454e016d5e..c2f979b61f9d 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -242,8 +242,9 @@ OUString GetNewTempFileURL( const uno::Reference< 
uno::XComponentContext >& rCon
 
 uno::Reference< io::XStream > CreateMemoryStream( const uno::Reference< 
uno::XComponentContext >& rContext )
 {
+    static constexpr OUStringLiteral sName(u"com.sun.star.comp.MemoryStream");
     return uno::Reference< io::XStream >(
-        
rContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.MemoryStream",
 rContext),
+        rContext->getServiceManager()->createInstanceWithContext(sName, 
rContext),
         uno::UNO_QUERY_THROW);
 }
 
diff --git a/package/source/xstor/xstorage.cxx 
b/package/source/xstor/xstorage.cxx
index a5777deb771e..bdcd699a7eb7 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -473,7 +473,8 @@ void OStorage_Impl::GetStorageProperties()
         uno::Reference< beans::XPropertySet > xPackageProps( m_xPackage, 
uno::UNO_QUERY_THROW );
         xPackageProps->getPropertyValue( MEDIATYPE_FALLBACK_USED_PROPERTY ) 
>>= m_bMTFallbackUsed;
 
-        xProps->getPropertyValue( "MediaType" ) >>= m_aMediaType;
+        static constexpr OUStringLiteral sMediaType(u"MediaType");
+        xProps->getPropertyValue( sMediaType ) >>= m_aMediaType;
         m_bControlMediaType = true;
     }
 
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 131fbf30a4c4..aae5a8710bb8 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3447,9 +3447,11 @@ SfxMedium::SfxMedium( const 
uno::Sequence<beans::PropertyValue>& aArgs ) :
 
 void SfxMedium::SetArgs(const uno::Sequence<beans::PropertyValue>& rArgs)
 {
+    static constexpr OUStringLiteral sStream(u"Stream");
+    static constexpr OUStringLiteral sInputStream(u"InputStream");
     comphelper::SequenceAsHashMap aArgsMap(rArgs);
-    aArgsMap.erase("Stream");
-    aArgsMap.erase("InputStream");
+    aArgsMap.erase(sStream);
+    aArgsMap.erase(sInputStream);
     pImpl->m_aArgs = aArgsMap.getAsConstPropertyValueList();
 }
 
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 062329033264..c0f677ad5da6 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -879,15 +879,24 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const   
OUString&
             pObjectShell->SetMacroCallsSeenWhileLoading();
         }
 
-        aArgs.remove( "WinExtent" );
-        aArgs.remove( "BreakMacroSignature" );
-        aArgs.remove( "MacroEventRead" );
-        aArgs.remove( "Stream" );
-        aArgs.remove( "InputStream" );
-        aArgs.remove( "URL" );
-        aArgs.remove( "Frame" );
-        aArgs.remove( "Password" );
-        aArgs.remove( "EncryptionData" );
+        static constexpr OUStringLiteral sWinExtent = u"WinExtent";
+        static constexpr OUStringLiteral sBreakMacroSignature = 
u"BreakMacroSignature";
+        static constexpr OUStringLiteral sMacroEventRead = u"MacroEventRead";
+        static constexpr OUStringLiteral sStream = u"Stream";
+        static constexpr OUStringLiteral sInputStream = u"InputStream";
+        static constexpr OUStringLiteral sURL = u"URL";
+        static constexpr OUStringLiteral sFrame = u"Frame";
+        static constexpr OUStringLiteral sPassword = u"Password";
+        static constexpr OUStringLiteral sEncryptionData = u"EncryptionData";
+        aArgs.remove( sWinExtent );
+        aArgs.remove( sBreakMacroSignature );
+        aArgs.remove( sMacroEventRead );
+        aArgs.remove( sStream );
+        aArgs.remove( sInputStream );
+        aArgs.remove( sURL );
+        aArgs.remove( sFrame );
+        aArgs.remove( sPassword );
+        aArgs.remove( sEncryptionData );
 
         // TODO/LATER: all the parameters that are accepted by ItemSet of the 
DocShell must be removed here
 
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx 
b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index a521b6eb3120..41cec42df4a1 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -556,35 +556,44 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const 
SdrCustomShapeGeometryIt
         nCoordWidthG  = std::abs( aViewBox.Width );
         nCoordHeightG = std::abs( aViewBox.Height);
     }
-    static const OUStringLiteral sPath( u"Path" );
+    static constexpr OUStringLiteral sPath( u"Path" );
+    static constexpr OUStringLiteral sCoordinates( u"Coordinates" );
+    static constexpr OUStringLiteral sGluePoints( u"GluePoints" );
+    static constexpr OUStringLiteral sSegments( u"Segments" );
+    static constexpr OUStringLiteral sSubViewSize( u"SubViewSize" );
+    static constexpr OUStringLiteral sStretchX( u"StretchX" );
+    static constexpr OUStringLiteral sStretchY( u"StretchY" );
+    static constexpr OUStringLiteral sTextFrames( u"TextFrames" );
+    static constexpr OUStringLiteral sEquations( u"Equations" );
+    static constexpr OUStringLiteral sHandles( u"Handles" );
 
 
     // Path/Coordinates
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "Coordinates" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sCoordinates );
     if ( pAny )
         *pAny >>= seqCoordinates;
 
 
     // Path/GluePoints
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "GluePoints" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sGluePoints );
     if ( pAny )
         *pAny >>= seqGluePoints;
 
 
     // Path/Segments
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "Segments" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sSegments );
     if ( pAny )
         *pAny >>= seqSegments;
 
 
     // Path/SubViewSize
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "SubViewSize" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sSubViewSize );
     if ( pAny )
         *pAny >>= seqSubViewSize;
 
 
     // Path/StretchX
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "StretchX" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sStretchX );
     if ( pAny )
     {
         sal_Int32 nStretchX = 0;
@@ -594,7 +603,7 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const 
SdrCustomShapeGeometryIt
 
 
     // Path/StretchY
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "StretchY" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sStretchY );
     if ( pAny )
     {
         sal_Int32 nStretchY = 0;
@@ -604,19 +613,19 @@ void EnhancedCustomShape2d::ApplyShapeAttributes( const 
SdrCustomShapeGeometryIt
 
 
     // Path/TextFrames
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, "TextFrames" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sPath, sTextFrames );
     if ( pAny )
         *pAny >>= seqTextFrames;
 
 
     // Equations
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
"Equations" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sEquations );
     if ( pAny )
         *pAny >>= seqEquations;
 
 
     // Handles
-    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
"Handles" );
+    pAny = 
const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( 
sHandles );
     if ( pAny )
         *pAny >>= seqHandles;
 }

Reply via email to