xmloff/source/core/xmltoken.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
New commits: commit 8031bedbc568bbbb6dc2968fc5ccca69543517d0 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Feb 28 16:02:56 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Feb 29 09:37:51 2020 +0100 reduce some pointer chasing can usd std::optional here Change-Id: I613131a00d64b7a226fe5b0d0f47a7db6ba41599 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89713 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 36739573e012..2005e929a684 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -22,6 +22,7 @@ #include <rtl/ustring.hxx> #include <rtl/string.hxx> #include <sal/log.hxx> +#include <optional> #include <set> @@ -34,7 +35,7 @@ namespace xmloff::token { { sal_Int32 const nLength; const char* pChar; - OUString* pOUString; + std::optional<OUString> xOUString; #if OSL_DEBUG_LEVEL > 0 XMLTokenEnum const eToken; #endif @@ -43,17 +44,17 @@ namespace xmloff::token { #if OSL_DEBUG_LEVEL > 0 - #define TOKEN( s, e ) { sizeof(s)-1, s, nullptr, e } + #define TOKEN( s, e ) { sizeof(s)-1, s, std::nullopt, e } #else - #define TOKEN( s, e ) { sizeof(s)-1, s, nullptr } + #define TOKEN( s, e ) { sizeof(s)-1, s, std::nullopt } #endif struct XMLTokenEntry aTokenList[] = { #if OSL_DEBUG_LEVEL > 0 - { 0, nullptr, nullptr, XML_TOKEN_START }, + { 0, nullptr, std::nullopt, XML_TOKEN_START }, #else - { 0, nullptr, nullptr }, // XML_TOKEN_START + { 0, nullptr, std::nullopt }, // XML_TOKEN_START #endif // common XML @@ -3343,9 +3344,9 @@ namespace xmloff::token { TOKEN( "resolved", XML_RESOLVED ), #if OSL_DEBUG_LEVEL > 0 - { 0, nullptr, nullptr, XML_TOKEN_END } + { 0, nullptr, std::nullopt, XML_TOKEN_END } #else - { 0, nullptr, nullptr /* XML_TOKEN_END */ } + { 0, nullptr, std::nullopt /* XML_TOKEN_END */ } #endif }; @@ -3399,10 +3400,10 @@ namespace xmloff::token { assert(sal_uInt16(eToken) < SAL_N_ELEMENTS(aTokenList)); XMLTokenEntry* pToken = &aTokenList[static_cast<sal_uInt16>(eToken)]; - if (!pToken->pOUString) - pToken->pOUString = new OUString( pToken->pChar, pToken->nLength, - RTL_TEXTENCODING_ASCII_US ); - return *pToken->pOUString; + if (!pToken->xOUString) + pToken->xOUString = OUString( pToken->pChar, pToken->nLength, + RTL_TEXTENCODING_ASCII_US ); + return *pToken->xOUString; } // does rString represent eToken? _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits