diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-08-01 18:58:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-01 20:53:28 +0200 |
commit | 75a862b887fb0b7ff633a396ee7f7f34c2c82964 (patch) | |
tree | 50361f282bfcd20ff04f97b59806b95029a9a405 /oox/source | |
parent | f8d764b138fddde719a04683f9bd3720c21e0656 (diff) |
use more string_view when dealing with attributes
which means we don't need to call strlen on them, since we already
know how long they are.
Change-Id: Iefc76f38a23250e87a65c27df3634d562464a760
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137679
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/helper/attributelist.cxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 043f0689fd40..0215588b2b97 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -227,15 +227,15 @@ std::optional< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nAttrToken ) std::optional< bool > AttributeList::getBool( sal_Int32 nAttrToken ) const { - const char *pAttr; + std::string_view pAttr; // catch the common cases as quickly as possible first - bool bHasAttr = getAttribList()->getAsChar( nAttrToken, pAttr ); + bool bHasAttr = getAttribList()->getAsView( nAttrToken, pAttr ); if( !bHasAttr ) return std::optional< bool >(); - if( !strcmp( pAttr, "false" ) ) + if( pAttr == "false" ) return std::optional< bool >( false ); - if( !strcmp( pAttr, "true" ) ) + if( pAttr == "true" ) return std::optional< bool >( true ); // now for all the crazy stuff @@ -299,13 +299,10 @@ OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefau return getXString( nAttrToken ).value_or( rDefault ); } -const char* AttributeList::getChar( sal_Int32 nAttrToken ) const +std::string_view AttributeList::getView( sal_Int32 nAttrToken ) const { - const char* p = nullptr; - bool bValid = getAttribList()->getAsChar(nAttrToken, p); - if (!bValid) - p = nullptr; - + std::string_view p; + getAttribList()->getAsView(nAttrToken, p); return p; } |