diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-11-20 12:11:44 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-11-20 12:12:50 +0000 |
commit | 9491ca3f64bd44a6a8e63f7d2eae02164f792258 (patch) | |
tree | 5ed4973014c2fe04d5e67dd792ee2229c51928fa /oox | |
parent | 55716b1ed969073f273c00baedb56d8f5de93761 (diff) |
fastparser: avoid excessive alloc/frees for int / bool / double parsing
Change-Id: I596bbc723558f04588d9e767d64732164524e57a
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/helper/attributelist.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 2c0eb23fc85f..7c41d8e967d2 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -19,8 +19,10 @@ #include "oox/helper/attributelist.hxx" +#include <cassert> #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> +#include <sax/fastattribs.hxx> #include "oox/token/tokenmap.hxx" namespace oox { @@ -117,11 +119,22 @@ sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue ) // ============================================================================ AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) : - mxAttribs( rxAttribs ) + mxAttribs( rxAttribs ), + mpAttribList( NULL ) { OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" ); } +sax_fastparser::FastAttributeList *AttributeList::getAttribList() const +{ + if( mpAttribList == NULL ) + { + assert( dynamic_cast< sax_fastparser::FastAttributeList *>( mxAttribs.get() ) != NULL ); + mpAttribList = static_cast< sax_fastparser::FastAttributeList *>( mxAttribs.get() ); + } + return mpAttribList; +} + bool AttributeList::hasAttribute( sal_Int32 nAttrToken ) const { return mxAttribs->hasAttribute( nAttrToken ); @@ -153,16 +166,16 @@ OptValue< OUString > AttributeList::getXString( sal_Int32 nAttrToken ) const OptValue< double > AttributeList::getDouble( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); - bool bValid = !aValue.isEmpty(); - return OptValue< double >( bValid, bValid ? AttributeConversion::decodeDouble( aValue ) : 0.0 ); + double nValue; + bool bValid = getAttribList()->getAsDouble( nAttrToken, nValue ); + return OptValue< double >( bValid, nValue ); } OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); - bool bValid = !aValue.isEmpty(); - return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeInteger( aValue ) : 0 ); + sal_Int32 nValue; + bool bValid = getAttribList()->getAsInteger( nAttrToken, nValue ); + return OptValue< sal_Int32 >( bValid, nValue ); } OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nAttrToken ) const |