diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-27 14:04:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-28 08:39:35 +0200 |
commit | e32c56855b04ef825b720b20220245365eec51fd (patch) | |
tree | d497c6fad6e3e7ac39a8bc80fa8e81fc7192f199 /svgio | |
parent | b2e8bbeafa35c15d168961de711e4970eb0985cb (diff) |
use boost::optional in sc and svgio
instead of using std:unique_ptr to allocate small objects on the heap
Change-Id: Ifd309a9bf331910354406b827b89a0363f3b7eda
Reviewed-on: https://gerrit.libreoffice.org/51945
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgnode.hxx | 13 | ||||
-rw-r--r-- | svgio/source/svgreader/svgnode.cxx | 24 |
2 files changed, 15 insertions, 22 deletions
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx index 7fd8129a48b8..45d9730be909 100644 --- a/svgio/inc/svgnode.hxx +++ b/svgio/inc/svgnode.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <memory> #include <vector> +#include <boost/optional.hpp> // predefines namespace svgio @@ -94,10 +95,10 @@ namespace svgio std::vector< std::unique_ptr<SvgNode> > maChildren; /// Id svan value - std::unique_ptr<OUString> mpId; + boost::optional<OUString> mpId; /// Class svan value - std::unique_ptr<OUString> mpClass; + boost::optional<OUString> mpClass; /// XmlSpace value XmlSpace maXmlSpace; @@ -163,12 +164,12 @@ namespace svgio double getCurrentXHeight() const; /// Id access - const OUString* getId() const { return mpId.get(); } - void setId(const OUString* pfId); + boost::optional<OUString> const & getId() const { return mpId; } + void setId(OUString const &); /// Class access - const OUString* getClass() const { return mpClass.get(); } - void setClass(const OUString* pfClass); + boost::optional<OUString> const & getClass() const { return mpClass; } + void setClass(OUString const &); /// XmlSpace access XmlSpace getXmlSpace() const; diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index 9f3687e67a25..f6395a24527d 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -263,8 +263,6 @@ namespace svgio mpParent(pParent), mpAlternativeParent(nullptr), maChildren(), - mpId(nullptr), - mpClass(nullptr), maXmlSpace(XmlSpace_notset), maDisplay(Display_inline), maCssStyleVector(), @@ -422,7 +420,7 @@ namespace svgio { if(!aContent.isEmpty()) { - setId(&aContent); + setId(aContent); } break; } @@ -430,7 +428,7 @@ namespace svgio { if(!aContent.isEmpty()) { - setClass(&aContent); + setClass(aContent); } break; } @@ -629,7 +627,7 @@ namespace svgio return getCurrentXHeightInherited(); } - void SvgNode::setId(const OUString* pfId) + void SvgNode::setId(OUString const & rId) { if(mpId) { @@ -637,14 +635,11 @@ namespace svgio mpId.reset(); } - if(pfId) - { - mpId.reset( new OUString(*pfId) ); - mrDocument.addSvgNodeToMapper(*mpId, *this); - } + mpId = rId; + mrDocument.addSvgNodeToMapper(*mpId, *this); } - void SvgNode::setClass(const OUString* pfClass) + void SvgNode::setClass(OUString const & rClass) { if(mpClass) { @@ -652,11 +647,8 @@ namespace svgio mpClass.reset(); } - if(pfClass) - { - mpClass.reset( new OUString(*pfClass) ); - mrDocument.addSvgNodeToMapper(*mpClass, *this); - } + mpClass = rClass; + mrDocument.addSvgNodeToMapper(*mpClass, *this); } XmlSpace SvgNode::getXmlSpace() const |