framework/source/uielement/uicommanddescription.cxx                     |   21 
+++--
 i18npool/source/characterclassification/characterclassificationImpl.cxx |    3 
 package/source/xstor/owriteablestream.cxx                               |    4 
-
 sfx2/source/doc/SfxDocumentMetaData.cxx                                 |   40 
+++++-----
 unotools/source/config/eventcfg.cxx                                     |    8 
+-
 5 files changed, 46 insertions(+), 30 deletions(-)

New commits:
commit 429a960e157f3375e795cdec8f265ace1c5bdc9e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun May 15 21:20:30 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue May 17 18:45:56 2022 +0200

    elide some OUString allocation
    
    Change-Id: Iadd73477bf3b0edaa0fb7db10f9ffca88fe737e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134476
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/framework/source/uielement/uicommanddescription.cxx 
b/framework/source/uielement/uicommanddescription.cxx
index 793bc9db8fe0..8054cf4bff8d 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -266,17 +266,24 @@ Any ConfigurationAccess_UICommand::getSequenceFromCache( 
const OUString& aComman
         if ( !pIter->second.bCommandNameCreated )
             fillInfoFromResult( pIter->second, pIter->second.aLabel );
 
+        static constexpr OUStringLiteral sLabel = u"Label";
+        static constexpr OUStringLiteral sName = u"Name";
+        static constexpr OUStringLiteral sPopup = u"Popup";
+        static constexpr OUStringLiteral sPopupLabel = u"PopupLabel";
+        static constexpr OUStringLiteral sTooltipLabel = u"TooltipLabel";
+        static constexpr OUStringLiteral sTargetURL = u"TargetURL";
+        static constexpr OUStringLiteral sIsExperimental = u"IsExperimental";
         Sequence< PropertyValue > aPropSeq{
-            comphelper::makePropertyValue("Label", 
!pIter->second.aContextLabel.isEmpty()
+            comphelper::makePropertyValue(sLabel, 
!pIter->second.aContextLabel.isEmpty()
                                                        ? 
Any(pIter->second.aContextLabel)
                                                        : 
Any(pIter->second.aLabel)),
-            comphelper::makePropertyValue("Name", pIter->second.aCommandName),
-            comphelper::makePropertyValue("Popup", pIter->second.bPopup),
+            comphelper::makePropertyValue(sName, pIter->second.aCommandName),
+            comphelper::makePropertyValue(sPopup, pIter->second.bPopup),
             comphelper::makePropertyValue(m_aPropProperties, 
pIter->second.nProperties),
-            comphelper::makePropertyValue("PopupLabel", 
pIter->second.aPopupLabel),
-            comphelper::makePropertyValue("TooltipLabel", 
pIter->second.aTooltipLabel),
-            comphelper::makePropertyValue("TargetURL", 
pIter->second.aTargetURL),
-            comphelper::makePropertyValue("IsExperimental", 
pIter->second.bIsExperimental)
+            comphelper::makePropertyValue(sPopupLabel, 
pIter->second.aPopupLabel),
+            comphelper::makePropertyValue(sTooltipLabel, 
pIter->second.aTooltipLabel),
+            comphelper::makePropertyValue(sTargetURL, 
pIter->second.aTargetURL),
+            comphelper::makePropertyValue(sIsExperimental, 
pIter->second.bIsExperimental)
         };
         return Any( aPropSeq );
     }
diff --git 
a/i18npool/source/characterclassification/characterclassificationImpl.cxx 
b/i18npool/source/characterclassification/characterclassificationImpl.cxx
index 8146612a87fc..aff424d8bef7 100644
--- a/i18npool/source/characterclassification/characterclassificationImpl.cxx
+++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx
@@ -32,7 +32,8 @@ namespace i18npool {
 CharacterClassificationImpl::CharacterClassificationImpl(
         const Reference < XComponentContext >& rxContext ) : m_xContext( 
rxContext )
 {
-    if (createLocaleSpecificCharacterClassification("Unicode", Locale()))
+    static constexpr OUStringLiteral sUnicode = u"Unicode";
+    if (createLocaleSpecificCharacterClassification(sUnicode, Locale()))
         xUCI = cachedItem->xCI;
 }
 
diff --git a/package/source/xstor/owriteablestream.cxx 
b/package/source/xstor/owriteablestream.cxx
index 2a4f1de3f9ef..8f9a93a2cc11 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -2771,8 +2771,8 @@ void SAL_CALL OWriteStream::setPropertyValue( const 
OUString& aPropertyName, con
     }
 
     m_pImpl->GetStreamProperties();
-    OUString aCompressedString( "Compressed" );
-    OUString aMediaTypeString( "MediaType" );
+    static constexpr OUStringLiteral aCompressedString( u"Compressed" );
+    static constexpr OUStringLiteral aMediaTypeString( u"MediaType" );
     if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && 
aPropertyName == aMediaTypeString )
     {
         // if the "Compressed" property is not set explicitly, the MediaType 
can change the default value
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx 
b/sfx2/source/doc/SfxDocumentMetaData.cxx
index e8937c096471..6392bd4aa2cc 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -414,10 +414,11 @@ const char* s_stdMeta[] = {
     nullptr
 };
 
-const char* s_stdMetaList[] = {
-    "meta:keyword",             // string*
-    "meta:user-defined",        // ...*
-    nullptr
+constexpr OUStringLiteral sMetaKeyword = u"meta:keyword";
+constexpr OUStringLiteral sMetaUserDefined = u"meta:user-defined";
+constexpr rtl::OUStringConstExpr s_stdMetaList[] {
+    sMetaKeyword,             // string*
+    sMetaUserDefined,        // ...*
 };
 
 constexpr OUStringLiteral s_nsXLink = u"http://www.w3.org/1999/xlink";;
@@ -1152,17 +1153,20 @@ void SfxDocumentMetaData::init(
                 }
             }
             if (!xRElem.is()) {
+                static constexpr OUStringLiteral sOfficeDocumentMeta = 
u"office:document-meta";
                 xRElem = i_xDoc->createElementNS(
-                    s_nsODF, "office:document-meta");
+                    s_nsODF, sOfficeDocumentMeta);
                 css::uno::Reference<css::xml::dom::XNode> xRNode(xRElem,
                     css::uno::UNO_QUERY_THROW);
                 i_xDoc->appendChild(xRNode);
             }
-            xRElem->setAttributeNS(s_nsODF, "office:version", "1.0");
+            static constexpr OUStringLiteral sOfficeVersion = 
u"office:version";
+            xRElem->setAttributeNS(s_nsODF, sOfficeVersion, "1.0");
             // does not exist, otherwise m_xParent would not be null
+            static constexpr OUStringLiteral sOfficeMeta = u"office:meta";
             css::uno::Reference<css::xml::dom::XNode> xParent (
-                i_xDoc->createElementNS(s_nsODF, "office:meta"),
-            css::uno::UNO_QUERY_THROW);
+                i_xDoc->createElementNS(s_nsODF, sOfficeMeta),
+                css::uno::UNO_QUERY_THROW);
             xRElem->appendChild(xParent);
             m_xParent = xParent;
         } catch (const css::xml::dom::DOMException &) {
@@ -1191,23 +1195,25 @@ void SfxDocumentMetaData::init(
     }
 
     // select nodes for elements of which we handle all occurrences
-    for (const char **pName = s_stdMetaList; *pName != nullptr; ++pName) {
-        OUString name = OUString::createFromAscii(*pName);
+    for (const auto & name : s_stdMetaList) {
         std::vector<css::uno::Reference<css::xml::dom::XNode> > nodes =
-            getChildNodeListByName(m_xParent, name);
+            getChildNodeListByName(m_xParent, OUString(name));
         m_metaList[name] = nodes;
     }
 
     // initialize members corresponding to attributes from DOM nodes
-    m_TemplateName  = getMetaAttr("meta:template", "xlink:title");
-    m_TemplateURL   = getMetaAttr("meta:template", "xlink:href");
+    static constexpr OUStringLiteral sMetaTemplate = u"meta:template";
+    static constexpr OUStringLiteral sMetaAutoReload = u"meta:auto-reload";
+    static constexpr OUStringLiteral sMetaHyperlinkBehaviour = 
u"meta:hyperlink-behaviour";
+    m_TemplateName  = getMetaAttr(sMetaTemplate, "xlink:title");
+    m_TemplateURL   = getMetaAttr(sMetaTemplate, "xlink:href");
     m_TemplateDate  =
-        textToDateTimeDefault(getMetaAttr("meta:template", "meta:date"));
-    m_AutoloadURL   = getMetaAttr("meta:auto-reload", "xlink:href");
+        textToDateTimeDefault(getMetaAttr(sMetaTemplate, "meta:date"));
+    m_AutoloadURL   = getMetaAttr(sMetaAutoReload, "xlink:href");
     m_AutoloadSecs  =
-        textToDuration(getMetaAttr("meta:auto-reload", "meta:delay"));
+        textToDuration(getMetaAttr(sMetaAutoReload, "meta:delay"));
     m_DefaultTarget =
-        getMetaAttr("meta:hyperlink-behaviour", "office:target-frame-name");
+        getMetaAttr(sMetaHyperlinkBehaviour, "office:target-frame-name");
 
 
     std::vector<css::uno::Reference<css::xml::dom::XNode> > & vec =
diff --git a/unotools/source/config/eventcfg.cxx 
b/unotools/source/config/eventcfg.cxx
index fb1eb948a47b..8cd883e0a0be 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -240,11 +240,13 @@ void GlobalEventConfig_Impl::replaceByName( const 
OUString& aName, const Any& aE
 
 css::uno::Sequence < css::beans::PropertyValue > 
GlobalEventConfig_Impl::getByName( const OUString& aName )
 {
+    static constexpr OUStringLiteral sEventType = u"EventType";
+    static constexpr OUStringLiteral sScript = u"Script";
     Sequence< beans::PropertyValue > props(2);
     auto pProps = props.getArray();
-    pProps[0].Name = "EventType";
-    pProps[0].Value <<= OUString("Script");
-    pProps[1].Name = "Script";
+    pProps[0].Name = sEventType;
+    pProps[0].Value <<= OUString(sScript);
+    pProps[1].Name = sScript;
     EventBindingHash::const_iterator it = m_eventBindingHash.find( aName );
     if( it != m_eventBindingHash.end() )
     {

Reply via email to