summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-04-14 12:51:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-14 17:04:52 +0200
commit306f6934ac6f0b012eaecd05bb4abb7c9d341993 (patch)
tree9ab9b1d067b9ba3074fee1e32d065c4e407fd6f6 /oox
parent869acd8315af695ff79594fc6a498abb8371103a (diff)
reduce allocation in TextListStyle
Change-Id: Id1bad0bf39b03bc6d4004c50c0f35b60d6753aa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114084 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/textbody.hxx1
-rw-r--r--oox/inc/drawingml/textliststyle.hxx19
-rw-r--r--oox/inc/drawingml/textparagraph.hxx1
-rw-r--r--oox/source/drawingml/textliststyle.cxx37
-rw-r--r--oox/source/drawingml/textparagraph.cxx2
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx2
6 files changed, 26 insertions, 36 deletions
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 5e6d156e7ce4..093642f30d97 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -24,6 +24,7 @@
#include <drawingml/textbodyproperties.hxx>
#include <drawingml/textliststyle.hxx>
#include <drawingml/shape3dproperties.hxx>
+#include <oox/helper/refvector.hxx>
namespace com::sun::star::text {
class XText;
diff --git a/oox/inc/drawingml/textliststyle.hxx b/oox/inc/drawingml/textliststyle.hxx
index 52cb29330877..ac84cc9d903d 100644
--- a/oox/inc/drawingml/textliststyle.hxx
+++ b/oox/inc/drawingml/textliststyle.hxx
@@ -21,11 +21,14 @@
#define INCLUDED_OOX_DRAWINGML_TEXTLISTSTYLE_HXX
#include <drawingml/textparagraphproperties.hxx>
-#include <oox/helper/refvector.hxx>
+#include <array>
+#include <memory>
namespace oox::drawingml
{
-typedef RefVector<TextParagraphProperties> TextParagraphPropertiesVector;
+constexpr int NUM_TEXT_LIST_STYLE_ENTRIES = 9;
+typedef std::array<std::shared_ptr<TextParagraphProperties>, NUM_TEXT_LIST_STYLE_ENTRIES>
+ TextParagraphPropertiesArray;
class TextListStyle
{
@@ -38,22 +41,22 @@ public:
void apply(const TextListStyle& rTextListStyle);
- const TextParagraphPropertiesVector& getListStyle() const { return maListStyle; };
- TextParagraphPropertiesVector& getListStyle() { return maListStyle; };
+ const TextParagraphPropertiesArray& getListStyle() const { return maListStyle; };
+ TextParagraphPropertiesArray& getListStyle() { return maListStyle; };
- const TextParagraphPropertiesVector& getAggregationListStyle() const
+ const TextParagraphPropertiesArray& getAggregationListStyle() const
{
return maAggregationListStyle;
};
- TextParagraphPropertiesVector& getAggregationListStyle() { return maAggregationListStyle; };
+ TextParagraphPropertiesArray& getAggregationListStyle() { return maAggregationListStyle; };
#ifdef DBG_UTIL
void dump() const;
#endif
private:
- TextParagraphPropertiesVector maListStyle;
- TextParagraphPropertiesVector maAggregationListStyle;
+ TextParagraphPropertiesArray maListStyle;
+ TextParagraphPropertiesArray maAggregationListStyle;
};
}
diff --git a/oox/inc/drawingml/textparagraph.hxx b/oox/inc/drawingml/textparagraph.hxx
index 22465355142c..5139c51b9b26 100644
--- a/oox/inc/drawingml/textparagraph.hxx
+++ b/oox/inc/drawingml/textparagraph.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/text/XText.hpp>
#include <oox/core/xmlfilterbase.hxx>
+#include <oox/helper/refvector.hxx>
#include <drawingml/textrun.hxx>
#include <drawingml/textliststyle.hxx>
#include <drawingml/textparagraphproperties.hxx>
diff --git a/oox/source/drawingml/textliststyle.cxx b/oox/source/drawingml/textliststyle.cxx
index d900e3cef338..da170cae03eb 100644
--- a/oox/source/drawingml/textliststyle.cxx
+++ b/oox/source/drawingml/textliststyle.cxx
@@ -24,10 +24,10 @@ namespace oox::drawingml {
TextListStyle::TextListStyle()
{
- for ( int i = 0; i < 9; i++ )
+ for ( int i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
{
- maListStyle.push_back( std::make_shared<TextParagraphProperties>( ) );
- maAggregationListStyle.push_back( std::make_shared<TextParagraphProperties>( ) );
+ maListStyle[i] = std::make_shared<TextParagraphProperties>( );
+ maAggregationListStyle[i] = std::make_shared<TextParagraphProperties>( );
}
}
@@ -37,12 +37,10 @@ TextListStyle::~TextListStyle()
TextListStyle::TextListStyle(const TextListStyle& rStyle)
{
- assert(rStyle.maListStyle.size() == 9);
- assert(rStyle.maAggregationListStyle.size() == 9);
- for ( size_t i = 0; i < 9; i++ )
+ for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
{
- maListStyle.push_back( std::make_shared<TextParagraphProperties>( *rStyle.maListStyle[i] ) );
- maAggregationListStyle.push_back( std::make_shared<TextParagraphProperties>( *rStyle.maAggregationListStyle[i] ) );
+ maListStyle[i] = std::make_shared<TextParagraphProperties>( *rStyle.maListStyle[i] );
+ maAggregationListStyle[i] = std::make_shared<TextParagraphProperties>( *rStyle.maAggregationListStyle[i] );
}
}
@@ -50,11 +48,7 @@ TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
{
if(this != &rStyle)
{
- assert(rStyle.maListStyle.size() == 9);
- assert(rStyle.maAggregationListStyle.size() == 9);
- assert(maListStyle.size() == 9);
- assert(maAggregationListStyle.size() == 9);
- for ( size_t i = 0; i < 9; i++ )
+ for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
{
*maListStyle[i] = *rStyle.maListStyle[i];
*maAggregationListStyle[i] = *rStyle.maAggregationListStyle[i];
@@ -63,19 +57,10 @@ TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
return *this;
}
-static void applyStyleList( const TextParagraphPropertiesVector& rSourceListStyle, TextParagraphPropertiesVector& rDestListStyle )
+static void applyStyleList( const TextParagraphPropertiesArray& rSourceListStyle, TextParagraphPropertiesArray& rDestListStyle )
{
- TextParagraphPropertiesVector::iterator aDestListStyleIter( rDestListStyle.begin() );
- for (auto const& elemSource : rSourceListStyle)
- {
- if ( aDestListStyleIter != rDestListStyle.end() )
- {
- (*aDestListStyleIter)->apply(*elemSource);
- ++aDestListStyleIter;
- }
- else
- rDestListStyle.push_back( std::make_shared<TextParagraphProperties>(*elemSource) );
- }
+ for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
+ rDestListStyle[i]->apply(*rSourceListStyle[i]);
}
void TextListStyle::apply( const TextListStyle& rTextListStyle )
@@ -87,7 +72,7 @@ void TextListStyle::apply( const TextListStyle& rTextListStyle )
#ifdef DBG_UTIL
void TextListStyle::dump() const
{
- for ( int i = 0; i < 9; i++ )
+ for ( int i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
{
SAL_INFO("oox.drawingml", "text list style level: " << i);
maListStyle[i]->dump();
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index 8aa4d8895040..ca33caa9f767 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -66,7 +66,7 @@ TextParagraphPropertiesPtr TextParagraph::getParagraphStyle(
SAL_INFO("oox", "TextParagraph::getParagraphStyle - level " << nLevel);
- const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle();
+ const TextParagraphPropertiesArray& rListStyle = rTextListStyle.getListStyle();
if (nLevel >= static_cast< sal_Int16 >(rListStyle.size()))
nLevel = 0;
TextParagraphPropertiesPtr pTextParagraphStyle;
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index aced17a2523b..9e14a260b846 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -86,7 +86,7 @@ PresentationFragmentHandler::PresentationFragmentHandler(XmlFilterBase& rFilter,
, mpTextListStyle( std::make_shared<TextListStyle>() )
, mbCommentAuthorsRead(false)
{
- TextParagraphPropertiesVector& rParagraphDefaultsVector( mpTextListStyle->getListStyle() );
+ TextParagraphPropertiesArray& rParagraphDefaultsVector( mpTextListStyle->getListStyle() );
for (auto const& elem : rParagraphDefaultsVector)
{
// ppt is having zero bottom margin per default, whereas OOo is 0,5cm,