From 75a862b887fb0b7ff633a396ee7f7f34c2c82964 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 1 Aug 2022 18:58:55 +0200 Subject: 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 --- sax/source/tools/fastattribs.cxx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sax/source') diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 3522f38f3ef5..d020e18de18c 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -242,7 +242,7 @@ bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble) const return false; } -bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos ) const +bool FastAttributeList::getAsView( sal_Int32 nToken, std::string_view& rPos ) const { for (size_t i = 0, n = maAttributeTokens.size(); i < n; ++i) { @@ -250,19 +250,14 @@ bool FastAttributeList::getAsChar( sal_Int32 nToken, const char*& rPos ) const continue; sal_Int32 nOffset = maAttributeValues[i]; - rPos = mpChunk + nOffset; + size_t nValueLen = maAttributeValues[i + 1] - maAttributeValues[i] - 1; + rPos = { mpChunk + nOffset, nValueLen }; return true; } return false; } -const char* FastAttributeList::getAsCharByIndex( sal_Int32 nTokenIndex ) const -{ - sal_Int32 nOffset = maAttributeValues[nTokenIndex]; - return mpChunk + nOffset; -} - std::string_view FastAttributeList::getAsViewByIndex( sal_Int32 nTokenIndex ) const { sal_Int32 nOffset = maAttributeValues[nTokenIndex]; -- cgit