summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-05-29 09:16:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-29 12:57:47 +0200
commit1094fedfac9d48262400e2a07581bfa36b2a422e (patch)
treed25b5741aa2d54825bb41f5473832d2bc8213b62
parent649228f932321c2c5784fbf7b0df84712fde55a0 (diff)
getUtf8TokenName can return by const ref
and avoid some reference-counting in a hot path Change-Id: I7f5fd7f8f5f9076eb5f8d60118afa8e3ac8a5e6c Reviewed-on: https://gerrit.libreoffice.org/38129 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/oox/token/tokenmap.hxx5
-rw-r--r--include/xmloff/fasttokenhandler.hxx6
-rw-r--r--oox/inc/drawingml/customshapeproperties.hxx2
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx2
-rw-r--r--oox/source/drawingml/shape.cxx2
-rw-r--r--oox/source/mathml/importutils.cxx2
-rw-r--r--oox/source/token/tokenmap.cxx2
-rw-r--r--xmloff/source/core/fasttokenhandler.cxx2
8 files changed, 15 insertions, 8 deletions
diff --git a/include/oox/token/tokenmap.hxx b/include/oox/token/tokenmap.hxx
index 2f499698c9a6..b5c14f20749b 100644
--- a/include/oox/token/tokenmap.hxx
+++ b/include/oox/token/tokenmap.hxx
@@ -42,13 +42,13 @@ public:
static sal_Int32 getTokenFromUnicode( const OUString& rUnicodeName );
/** Returns the UTF8 name of the passed token identifier as byte sequence. */
- css::uno::Sequence< sal_Int8 >
+ css::uno::Sequence< sal_Int8 > const &
getUtf8TokenName( sal_Int32 nToken ) const
{
SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "oox", "Wrong nToken parameter");
if (0 <= nToken && nToken < XML_TOKEN_COUNT)
return maTokenNames[ nToken ];
- return css::uno::Sequence< sal_Int8 >();
+ return EMPTY_BYTE_SEQ;
}
/** Returns the token identifier for the passed UTF8 token name. */
@@ -75,6 +75,7 @@ public:
private:
static sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 nLength );
+ static const css::uno::Sequence< sal_Int8 > EMPTY_BYTE_SEQ;
typedef ::std::vector< css::uno::Sequence< sal_Int8 > > TokenNameVector;
diff --git a/include/xmloff/fasttokenhandler.hxx b/include/xmloff/fasttokenhandler.hxx
index ca20d687ad7f..760360711535 100644
--- a/include/xmloff/fasttokenhandler.hxx
+++ b/include/xmloff/fasttokenhandler.hxx
@@ -27,12 +27,12 @@ public:
~TokenMap();
/** Returns the UTF-8 name of the passed token identifier as byte sequence. */
- css::uno::Sequence< sal_Int8 > getUtf8TokenName( sal_Int32 nToken ) const
+ css::uno::Sequence< sal_Int8 > const & getUtf8TokenName( sal_Int32 nToken ) const
{
SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "xmloff", "Wrong nToken parameter");
if( 0 <= nToken && nToken < XML_TOKEN_COUNT )
return maTokenNames[ nToken ];
- return css::uno::Sequence< sal_Int8 >();
+ return EMPTY_BYTE_SEQ;
}
/** Returns the token identifier for the passed UTF-8 token name. */
@@ -52,6 +52,8 @@ private:
static sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 nLength );
std::vector< css::uno::Sequence< sal_Int8 > > maTokenNames;
+
+ static const css::uno::Sequence< sal_Int8 > EMPTY_BYTE_SEQ;
};
struct StaticTokenMap : public rtl::Static< TokenMap, StaticTokenMap > {};
diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx
index 2e47b64bb013..ddd29199ff41 100644
--- a/oox/inc/drawingml/customshapeproperties.hxx
+++ b/oox/inc/drawingml/customshapeproperties.hxx
@@ -103,7 +103,7 @@ public:
const css::awt::Size &aSize );
sal_Int32 getShapePresetType() const { return mnShapePresetType; }
- css::uno::Sequence< sal_Int8 > getShapePresetTypeName() const;
+ css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const;
void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
bool getShapeTypeOverride(){ return mbShapeTypeOverride; };
void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 5cf9cd235b93..160879cc3e66 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -52,7 +52,7 @@ CustomShapeProperties::~CustomShapeProperties()
{
}
-uno::Sequence< sal_Int8 > CustomShapeProperties::getShapePresetTypeName() const
+uno::Sequence< sal_Int8 > const & CustomShapeProperties::getShapePresetTypeName() const
{
return StaticTokenMap::get().getUtf8TokenName( mnShapePresetType );
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 8805d7613754..774bcedc878a 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -752,7 +752,7 @@ Reference< XShape > const & Shape::createAndInsert(
sal_Int32 length = aGrabBag.getLength();
aGrabBag.realloc( length+1);
aGrabBag[length].Name = "mso-orig-shape-type";
- const uno::Sequence< sal_Int8 > aNameSeq =
+ uno::Sequence< sal_Int8 > const & aNameSeq =
mpCustomShapePropertiesPtr->getShapePresetTypeName();
OUString sShapePresetTypeName(reinterpret_cast< const char* >(
aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 7333f27dc352..77f5ec94b84f 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -58,7 +58,7 @@ AttributeListBuilder::AttributeListBuilder( const uno::Reference< xml::sax::XFas
OString tokenToString( int token )
{
- const uno::Sequence< sal_Int8 > aTokenNameSeq = StaticTokenMap::get().getUtf8TokenName( token & TOKEN_MASK );
+ uno::Sequence< sal_Int8 > const & aTokenNameSeq = StaticTokenMap::get().getUtf8TokenName( token & TOKEN_MASK );
OString tokenname( reinterpret_cast< const char* >( aTokenNameSeq.getConstArray() ), aTokenNameSeq.getLength() );
if( tokenname.isEmpty())
tokenname = "???";
diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx
index 549c40fec7b3..fc5e7ab48394 100644
--- a/oox/source/token/tokenmap.cxx
+++ b/oox/source/token/tokenmap.cxx
@@ -43,6 +43,8 @@ namespace {
#endif
} // namespace
+const css::uno::Sequence< sal_Int8 > TokenMap::EMPTY_BYTE_SEQ;
+
TokenMap::TokenMap() :
maTokenNames( static_cast< size_t >( XML_TOKEN_COUNT ) )
{
diff --git a/xmloff/source/core/fasttokenhandler.cxx b/xmloff/source/core/fasttokenhandler.cxx
index 22a1606b44b1..b5fa379c9de7 100644
--- a/xmloff/source/core/fasttokenhandler.cxx
+++ b/xmloff/source/core/fasttokenhandler.cxx
@@ -32,6 +32,8 @@ namespace token {
using namespace css;
+const css::uno::Sequence< sal_Int8 > TokenMap::EMPTY_BYTE_SEQ;
+
TokenMap::TokenMap() :
maTokenNames( static_cast< size_t >( XML_TOKEN_COUNT ) )
{