[Libreoffice-commits] core.git: include/oox include/xmloff oox/inc oox/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Mon May 29 10:58:15 UTC 2017


 include/oox/token/tokenmap.hxx                 |    5 +++--
 include/xmloff/fasttokenhandler.hxx            |    6 ++++--
 oox/inc/drawingml/customshapeproperties.hxx    |    2 +-
 oox/source/drawingml/customshapeproperties.cxx |    2 +-
 oox/source/drawingml/shape.cxx                 |    2 +-
 oox/source/mathml/importutils.cxx              |    2 +-
 oox/source/token/tokenmap.cxx                  |    2 ++
 xmloff/source/core/fasttokenhandler.cxx        |    2 ++
 8 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 1094fedfac9d48262400e2a07581bfa36b2a422e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon May 29 09:16:50 2017 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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 ) )
 {


More information about the Libreoffice-commits mailing list