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 <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara
2025-07-10 11:11:22 +02:00
parent 0d27622790
commit 19861761f9
5 changed files with 25 additions and 36 deletions
-3
View File
@@ -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
+10 -12
View File
@@ -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);
static_assert(std::size(wordlist) == 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)
std::vector<css::uno::Sequence<sal_Int8>> aTokenNames(std::size(wordlist));
for (const auto& resword : wordlist)
{
return css::uno::Sequence<sal_Int8>(
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;
}();
-1
View File
@@ -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:
-3
View File
@@ -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
+11 -13
View File
@@ -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(sppcTokenNames) == XML_TOKEN_COUNT);
static_assert(std::size(wordlist) == 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)
std::vector<std::pair<css::uno::Sequence<sal_Int8>, OUString>> names(std::size(wordlist));
for (const auto& resword : wordlist)
{
return std::make_pair(
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()),
OStringToOUString(token, RTL_TEXTENCODING_UTF8));
});
reinterpret_cast<const sal_Int8*>(token.data()), token.size());
names[resword.nToken].second = OStringToOUString(token, RTL_TEXTENCODING_UTF8);
};
return names;
}();