[Libreoffice-commits] core.git: dbaccess/source sd/source sfx2/source sw/source vcl/source writerfilter/source

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 5 10:52:17 UTC 2021


 dbaccess/source/ui/control/opendoccontrols.cxx  |    2 
 sd/source/ui/app/sdmod2.cxx                     |   18 +++----
 sfx2/source/view/classificationhelper.cxx       |    2 
 sw/source/core/attr/calbck.cxx                  |    2 
 sw/source/filter/ww8/rtfstringbuffer.cxx        |    4 -
 sw/source/uibase/app/swmodule.cxx               |   58 ++++++++++++------------
 sw/source/uibase/uiview/uivwimp.cxx             |    2 
 vcl/source/app/stdtext.cxx                      |    8 +--
 vcl/source/window/scrwnd.cxx                    |   12 ++--
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |    5 --
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |    9 +--
 11 files changed, 60 insertions(+), 62 deletions(-)

New commits:
commit aecdb5425538130ff4b82d56fa910bffcd9c3b81
Author:     Thorsten Behrens <thorsten.behrens at allotropia.de>
AuthorDate: Thu Mar 4 23:29:50 2021 +0100
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Fri Mar 5 11:51:32 2021 +0100

    emplace_back: use perfect forwarding if possible
    
    When using that new-ish method, try giving the compiler a chance to
    construct in-place. Left out harder cases using initializer lists,
    and might have missed slightly less obvious places.
    
    Change-Id: Ifcc3a6d4599474457e37dd17a35c41fc73e7a17e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111980
    Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins

diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
index 52c3bb6fb816..99be8a42763d 100644
--- a/dbaccess/source/ui/control/opendoccontrols.cxx
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -170,7 +170,7 @@ namespace dbaui
                     OUString sDecodedURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
 
                     m_xControl->append_text(sTitle);
-                    m_aURLs.emplace_back(StringPair(sDecodedURL, sFilter));
+                    m_aURLs.emplace_back(sDecodedURL, sFilter);
                 }
             }
             catch( Exception& ) {}
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index d749d2c73644..2ea60b588ef9 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -800,15 +800,15 @@ std::unique_ptr<SfxStyleFamilies> SdModule::CreateStyleFamilies()
 {
     std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
 
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
-                                                    SdResId(STR_GRAPHICS_STYLE_FAMILY),
-                                                    BMP_STYLES_FAMILY_GRAPHICS,
-                                                    RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
-                                                    SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
-                                                    BMP_STYLES_FAMILY_PRESENTATIONS,
-                                                    RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale()));
+    pStyleFamilies->emplace_back(SfxStyleFamily::Para,
+                                 SdResId(STR_GRAPHICS_STYLE_FAMILY),
+                                 BMP_STYLES_FAMILY_GRAPHICS,
+                                 RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Pseudo,
+                                 SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
+                                 BMP_STYLES_FAMILY_PRESENTATIONS,
+                                 RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale());
 
     return pStyleFamilies;
 }
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index d0bed6f97a67..ef864760381e 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -183,7 +183,7 @@ void SAL_CALL SfxClassificationParser::startElement(const OUString& rName, const
             OUString aIdentifier = xAttribs->getValueByName("Identifier");
 
             // Create a new category and initialize it with the data that's true for all categories.
-            m_aCategories.emplace_back(SfxClassificationCategory());
+            m_aCategories.emplace_back();
             SfxClassificationCategory& rCategory = m_aCategories.back();
 
             rCategory.m_aName = aName;
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index ae840edff48e..a37ee5bef376 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -268,7 +268,7 @@ sw::WriterMultiListener::~WriterMultiListener()
 void sw::WriterMultiListener::StartListening(SwModify* pDepend)
 {
     EndListening(nullptr);
-    m_vDepends.emplace_back(ListenerEntry(&m_rToTell, pDepend));
+    m_vDepends.emplace_back(&m_rToTell, pDepend);
 }
 
 
diff --git a/sw/source/filter/ww8/rtfstringbuffer.cxx b/sw/source/filter/ww8/rtfstringbuffer.cxx
index 055ace53a429..f5d21d0b2bd4 100644
--- a/sw/source/filter/ww8/rtfstringbuffer.cxx
+++ b/sw/source/filter/ww8/rtfstringbuffer.cxx
@@ -63,7 +63,7 @@ OString RtfStringBuffer::makeStringAndClear()
 OStringBuffer& RtfStringBuffer::getLastBuffer()
 {
     if (m_aValues.empty() || m_aValues.back().isGraphic())
-        m_aValues.emplace_back(RtfStringBufferValue());
+        m_aValues.emplace_back();
     return m_aValues.back().getBuffer();
 }
 
@@ -73,7 +73,7 @@ void RtfStringBuffer::clear() { m_aValues.clear(); }
 
 void RtfStringBuffer::append(const SwFlyFrameFormat* pFlyFrameFormat, const SwGrfNode* pGrfNode)
 {
-    m_aValues.emplace_back(RtfStringBufferValue(pFlyFrameFormat, pGrfNode));
+    m_aValues.emplace_back(pFlyFrameFormat, pGrfNode);
 }
 
 void RtfStringBuffer::appendAndClear(RtfStringBuffer& rBuf)
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 9d5748ede637..d07ca6aa59aa 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -345,35 +345,35 @@ std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
 {
     std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
 
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
-                                                    SwResId(STR_PARAGRAPHSTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_PARA,
-                                                    RID_PARAGRAPHSTYLEFAMILY, GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Char,
-                                                    SwResId(STR_CHARACTERSTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_CHAR,
-                                                    RID_CHARACTERSTYLEFAMILY, GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
-                                                    SwResId(STR_FRAMESTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_FRAME,
-                                                    RID_FRAMESTYLEFAMILY, GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
-                                                    SwResId(STR_PAGESTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_PAGE,
-                                                    RID_PAGESTYLEFAMILY, GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
-                                                    SwResId(STR_LISTSTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_LIST,
-                                                    RID_LISTSTYLEFAMILY, GetResLocale()));
-
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Table,
-                                                    SwResId(STR_TABLESTYLEFAMILY),
-                                                    BMP_STYLES_FAMILY_TABLE,
-                                                    RID_TABLESTYLEFAMILY, GetResLocale()));
+    pStyleFamilies->emplace_back(SfxStyleFamily::Para,
+                                 SwResId(STR_PARAGRAPHSTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_PARA,
+                                 RID_PARAGRAPHSTYLEFAMILY, GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Char,
+                                 SwResId(STR_CHARACTERSTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_CHAR,
+                                 RID_CHARACTERSTYLEFAMILY, GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Frame,
+                                 SwResId(STR_FRAMESTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_FRAME,
+                                 RID_FRAMESTYLEFAMILY, GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Page,
+                                 SwResId(STR_PAGESTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_PAGE,
+                                 RID_PAGESTYLEFAMILY, GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Pseudo,
+                                 SwResId(STR_LISTSTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_LIST,
+                                 RID_LISTSTYLEFAMILY, GetResLocale());
+
+    pStyleFamilies->emplace_back(SfxStyleFamily::Table,
+                                 SwResId(STR_TABLESTYLEFAMILY),
+                                 BMP_STYLES_FAMILY_TABLE,
+                                 RID_TABLESTYLEFAMILY, GetResLocale());
 
     return pStyleFamilies;
 }
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index b607ccf9b256..336ce8de1975 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -230,7 +230,7 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
                 return !xTunnel.is();
             }), mxTransferables.end());
 
-        mxTransferables.emplace_back(uno::Reference<lang::XUnoTunnel>(&rTransferable));
+        mxTransferables.emplace_back(&rTransferable);
     }
     osl_atomic_decrement(&rTransferable.m_refCount);
 }
diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx
index 0d5e8411bc60..f5b603e009bd 100644
--- a/vcl/source/app/stdtext.cxx
+++ b/vcl/source/app/stdtext.cxx
@@ -39,10 +39,10 @@ static void ImplInitMsgBoxImageList()
     std::vector<Image> &rImages = pSVData->mpWinData->maMsgBoxImgList;
     if (rImages.empty())
     {
-        rImages.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_ERRORBOX));
-        rImages.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_QUERYBOX));
-        rImages.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_WARNINGBOX));
-        rImages.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_INFOBOX));
+        rImages.emplace_back(StockImage::Yes, SV_RESID_BITMAP_ERRORBOX);
+        rImages.emplace_back(StockImage::Yes, SV_RESID_BITMAP_QUERYBOX);
+        rImages.emplace_back(StockImage::Yes, SV_RESID_BITMAP_WARNINGBOX);
+        rImages.emplace_back(StockImage::Yes, SV_RESID_BITMAP_INFOBOX);
     }
 }
 
diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx
index 3fd68cf09351..efb29c4f52f5 100644
--- a/vcl/source/window/scrwnd.cxx
+++ b/vcl/source/window/scrwnd.cxx
@@ -118,12 +118,12 @@ void ImplWheelWindow::ImplSetRegion( const Bitmap& rRegionBmp )
 
 void ImplWheelWindow::ImplCreateImageList()
 {
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_SCROLLVH));
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_SCROLLV));
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_SCROLLH));
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_WHEELVH));
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_WHEELV));
-    maImgList.emplace_back(Image(StockImage::Yes, SV_RESID_BITMAP_WHEELH));
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_SCROLLVH);
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_SCROLLV);
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_SCROLLH);
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_WHEELVH);
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_WHEELV);
+    maImgList.emplace_back(StockImage::Yes, SV_RESID_BITMAP_WHEELH);
 }
 
 void ImplWheelWindow::ImplSetWheelMode( WheelMode nWheelMode )
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index cca01ebf4323..f398326a7344 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -273,7 +273,7 @@ bool RTFDocumentImpl::dispatchParagraphSprmValue(RTFKeyword nKeyword, int nParam
         {
             while (m_aTableBufferStack.size() < sal::static_int_cast<std::size_t>(nParam))
             {
-                m_aTableBufferStack.emplace_back(RTFBuffer_t());
+                m_aTableBufferStack.emplace_back();
             }
             // Invalid tables may omit INTBL after ITAP
             dispatchFlag(RTF_INTBL); // sets newly pushed buffer as current
@@ -1637,8 +1637,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             if (rDrawingObject.getPolyLinePoints().empty())
                 dispatchValue(RTF_DPPOLYCOUNT, 2);
 
-            rDrawingObject.getPolyLinePoints().emplace_back(
-                awt::Point(convertTwipToMm100(nParam), 0));
+            rDrawingObject.getPolyLinePoints().emplace_back(convertTwipToMm100(nParam), 0);
         }
         break;
         case RTF_DPPTY:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2eb09c13d4ec..8745ba050afb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1483,8 +1483,7 @@ void RTFDocumentImpl::text(OUString& rString)
     if (m_aStates.top().getTableCellSprms().find(NS_ooxml::LN_CT_TcPrBase_vAlign)
         && m_nTopLevelCells == 0)
     {
-        m_aTableBufferStack.back().emplace_back(
-            Buf_t(BUFFER_UTEXT, new RTFValue(rString), nullptr));
+        m_aTableBufferStack.back().emplace_back(BUFFER_UTEXT, new RTFValue(rString), nullptr);
         return;
     }
 
@@ -3673,9 +3672,9 @@ void RTFDocumentImpl::resetFrame() { m_aStates.top().getFrame() = RTFFrame(&m_aS
 void RTFDocumentImpl::bufferProperties(RTFBuffer_t& rBuffer, const RTFValue::Pointer_t& pValue,
                                        const tools::SvRef<TableRowBuffer>& pTableProperties)
 {
-    rBuffer.emplace_back(
-        Buf_t(BUFFER_SETSTYLE, new RTFValue(m_aStates.top().getCurrentStyleIndex()), nullptr));
-    rBuffer.emplace_back(Buf_t(BUFFER_PROPS, pValue, pTableProperties));
+    rBuffer.emplace_back(BUFFER_SETSTYLE, new RTFValue(m_aStates.top().getCurrentStyleIndex()),
+                         nullptr);
+    rBuffer.emplace_back(BUFFER_PROPS, pValue, pTableProperties);
 }
 
 RTFShape::RTFShape() = default;


More information about the Libreoffice-commits mailing list