oox/IwyuFilter_oox.yaml | 3 --- oox/source/token/tokenmap.cxx | 28 +++++++++++++--------------- xmloff/CustomTarget_generated.mk | 1 - xmloff/IwyuFilter_xmloff.yaml | 3 --- xmloff/source/core/fasttokenhandler.cxx | 28 +++++++++++++--------------- 5 files changed, 26 insertions(+), 37 deletions(-)
New commits: commit 19861761f9d8551cd13219c97fb7b64e8f123ac2 Author: Caolán McNamara <[email protected]> AuthorDate: Wed Jul 9 09:42:06 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Jul 10 11:11:22 2025 +0200 reuse existing tokennames instead of including duplicate nm -S --size-sort --print-size instdir/program/libmergedlo.so| grep ' [Dd] ' | c++filt | tail -n 10 before: ... 0000000000002790 d STR_ARR_SVT_LANGUAGE_TABLE ... 00000000000027a8 d RID_STRLIST_FUNCTION_NAMES ... 00000000000027f0 d aFmFormShellSlots_Impl ... 0000000000002920 d pRGBTable ... 0000000000003b80 d vcl::pdf::BuildinFontFace::m_aBuildinFonts ... 0000000000004140 d C.16.0 ... 0000000000004d80 d (anonymous namespace)::aMethods ... 00000000000066a8 d aRTFTokenTab ... 000000000000cf60 d xmloff::token::getNames(int)::{lambda()#1}::operator()() const::sppcTokenNames ... 00000000000172c0 d oox::TokenMap::getUtf8TokenName(int)::{lambda()#1}::operator()() const::sppcTokenNames after: ... 0000000000002058 d abasctl_ShellSlots_Impl ... 0000000000002448 d oox::aPrstLightRigValuesArray ... 0000000000002790 d STR_ARR_SVT_LANGUAGE_TABLE ... 00000000000027a8 d RID_STRLIST_FUNCTION_NAMES ... 00000000000027f0 d aFmFormShellSlots_Impl ... 0000000000002920 d pRGBTable ... 0000000000003b80 d vcl::pdf::BuildinFontFace::m_aBuildinFonts ... 0000000000004140 d C.16.0 ... 0000000000004d80 d (anonymous namespace)::aMethods ... 00000000000066a8 d aRTFTokenTab Change-Id: Iaecc42395910794cb52a77f3d9feff04a6fc8bcd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187601 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/oox/IwyuFilter_oox.yaml b/oox/IwyuFilter_oox.yaml index 994678df7afa..4cacc799f78c 100644 --- a/oox/IwyuFilter_oox.yaml +++ b/oox/IwyuFilter_oox.yaml @@ -176,9 +176,6 @@ excludelist: # Auto-generated C array of transitional and strict namespace names - namespacenames.inc - namespaces-strictnames.inc - oox/source/token/tokenmap.cxx: - # Auto-generated C array of token names - - tokennames.inc oox/source/vml/vmlinputstream.cxx: # Needed for direct member access - com/sun/star/io/XTextInputStream2.hpp diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx index c6b21dfa89b6..3fd6dbf426a4 100644 --- a/oox/source/token/tokenmap.cxx +++ b/oox/source/token/tokenmap.cxx @@ -58,21 +58,19 @@ css::uno::Sequence<sal_Int8> const& TokenMap::getUtf8TokenName(sal_Int32 nToken) { static const auto saTokenNames = []() { - static constexpr std::string_view sppcTokenNames[] = { -// include auto-generated C array with token names as C strings -#include <tokennames.inc> - }; - static_assert(std::size(sppcTokenNames) == XML_TOKEN_COUNT); - - std::vector<css::uno::Sequence<sal_Int8>> aTokenNames; - aTokenNames.reserve(std::size(sppcTokenNames)); - std::transform( - std::begin(sppcTokenNames), std::end(sppcTokenNames), std::back_inserter(aTokenNames), - [](auto aUtf8Token) - { - return css::uno::Sequence<sal_Int8>( - reinterpret_cast<const sal_Int8*>(aUtf8Token.data()), aUtf8Token.size()); - }); + static_assert(std::size(wordlist) == XML_TOKEN_COUNT); + + std::vector<css::uno::Sequence<sal_Int8>> aTokenNames(std::size(wordlist)); + for (const auto& resword : wordlist) + { + const char *s = reinterpret_cast<const char*>(&stringpool_contents) + resword.name; + std::string_view aUtf8Token(s, strlen(s)); + + aTokenNames[resword.nToken] = + css::uno::Sequence<sal_Int8>( + reinterpret_cast<const sal_Int8*>(aUtf8Token.data()), aUtf8Token.size()); + } + return aTokenNames; }(); diff --git a/xmloff/CustomTarget_generated.mk b/xmloff/CustomTarget_generated.mk index e0949f80853b..d4460ec36985 100644 --- a/xmloff/CustomTarget_generated.mk +++ b/xmloff/CustomTarget_generated.mk @@ -20,7 +20,6 @@ $(eval $(call gb_CustomTarget_generate_tokens,xmloff/generated,xmloff,xmloff/sou $(call gb_CustomTarget_get_target,xmloff/generated) : \ $(xmloff_INC)/tokenhash.inc \ - $(xmloff_INC)/tokennames.inc \ $(xmloff_GENHEADERPATH)/tokens.hxx \ # vim: set noet sw=4 ts=4: diff --git a/xmloff/IwyuFilter_xmloff.yaml b/xmloff/IwyuFilter_xmloff.yaml index 95af3f97503e..356b76dac5bb 100644 --- a/xmloff/IwyuFilter_xmloff.yaml +++ b/xmloff/IwyuFilter_xmloff.yaml @@ -21,9 +21,6 @@ excludelist: xmloff/source/xforms/XFormsModelExport.hxx: # Needed for css shortcut - sal/types.h - xmloff/source/core/fasttokenhandler.cxx: - # Needed for special array initialization - - tokennames.inc xmloff/source/chart/SchXMLCalculationSettingsContext.cxx: # Complete type is needed - com/sun/star/frame/XModel.hpp diff --git a/xmloff/source/core/fasttokenhandler.cxx b/xmloff/source/core/fasttokenhandler.cxx index a830609c26d5..fb88f9878379 100644 --- a/xmloff/source/core/fasttokenhandler.cxx +++ b/xmloff/source/core/fasttokenhandler.cxx @@ -46,22 +46,20 @@ static const std::pair<css::uno::Sequence<sal_Int8>, OUString>& getNames(sal_Int { static const auto saTokenNames = []() { - static constexpr std::string_view sppcTokenNames[] = { -#include <tokennames.inc> + static_assert(std::size(wordlist) == XML_TOKEN_COUNT); + + std::vector<std::pair<css::uno::Sequence<sal_Int8>, OUString>> names(std::size(wordlist)); + + for (const auto& resword : wordlist) + { + const char *s = reinterpret_cast<const char*>(&stringpool_contents) + resword.name; + std::string_view token(s, strlen(s)); + + names[resword.nToken].first = + css::uno::Sequence<sal_Int8>( + reinterpret_cast<const sal_Int8*>(token.data()), token.size()); + names[resword.nToken].second = OStringToOUString(token, RTL_TEXTENCODING_UTF8); }; - static_assert(std::size(sppcTokenNames) == XML_TOKEN_COUNT); - - std::vector<std::pair<css::uno::Sequence<sal_Int8>, OUString>> names; - names.reserve(std::size(sppcTokenNames)); - std::transform(std::begin(sppcTokenNames), std::end(sppcTokenNames), - std::back_inserter(names), - [](auto token) - { - return std::make_pair( - css::uno::Sequence<sal_Int8>( - reinterpret_cast<const sal_Int8*>(token.data()), token.size()), - OStringToOUString(token, RTL_TEXTENCODING_UTF8)); - }); return names; }();
