From d4cafd20506a60a148b55e716c690a74c943def7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 18 Feb 2019 15:05:28 +0200 Subject: use boost::optional in EditFieldInfo it is inefficient to allocate a tiny object like Color separately on the heap Change-Id: I2f03538f987ff032857f3316ed2d8c2c8d731549 Reviewed-on: https://gerrit.libreoffice.org/67968 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/editeng/outliner.hxx | 17 +++++++---------- sd/source/ui/app/sdmod2.cxx | 2 +- sw/source/core/doc/docdraw.cxx | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 1158f7195fea..67d2c47bb222 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -497,8 +498,8 @@ private: Outliner* pOutliner; const SvxFieldItem& rFldItem; - std::unique_ptr pTxtColor; - std::unique_ptr pFldColor; + boost::optional mxTxtColor; + boost::optional mxFldColor; OUString aRepresentation; @@ -522,15 +523,11 @@ public: const SvxFieldItem& GetField() const { return rFldItem; } - Color* GetTextColor() const { return pTxtColor.get(); } - void SetTextColor( const Color& rColor ) - { pTxtColor.reset( new Color( rColor ) ); } + boost::optional const & GetTextColor() const { return mxTxtColor; } + void SetTextColor( boost::optional xCol ) { mxTxtColor = xCol; } - Color* GetFieldColor() const { return pFldColor.get(); } - void SetFieldColor( const Color& rColor ) - { pFldColor.reset( new Color( rColor ) ); } - void ClearFieldColor() - { pFldColor.reset(); } + boost::optional const & GetFieldColor() const { return mxFldColor; } + void SetFieldColor( boost::optional xCol ) { mxFldColor = xCol; } sal_Int32 GetPara() const { return nPara; } sal_Int32 GetPos() const { return nPos; } diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx index 34584c4cd3e3..5fd4dc940116 100644 --- a/sd/source/ui/app/sdmod2.cxx +++ b/sd/source/ui/app/sdmod2.cxx @@ -343,7 +343,7 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void) } else if ( dynamic_cast< const SdrMeasureField* >(pField)) { - pInfo->ClearFieldColor(); + pInfo->SetFieldColor(boost::optional()); // clear the field color } else if ((pCustomPropertyField = dynamic_cast(pField)) != nullptr) { diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 9eb49b95a44b..2087fbbe58d8 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -541,8 +541,8 @@ IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo, void) } else if (dynamic_cast( pField)) { - // Measure field - pInfo->ClearFieldColor(); + // Clear measure field + pInfo->SetFieldColor(boost::optional()); } else if ( auto pTimeField = dynamic_cast( pField) ) { -- cgit