diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-15 11:28:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-15 19:37:53 +0200 |
commit | 636a22ffd7769c5f31844e66579c78928434df81 (patch) | |
tree | 28c05f793691de482a820cadb053ddd5bff7af62 /i18npool | |
parent | 06c3bd93379053862e57221a550e4e07129bff49 (diff) |
use stack buffer in transliterateImpl
Change-Id: I7c3e24f3974dafeb9abb2af9e2a986003af7bfc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135873
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/transliteration/transliteration_body.cxx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx index 605a3bb64284..69ba0c236714 100644 --- a/i18npool/source/transliteration/transliteration_body.cxx +++ b/i18npool/source/transliteration/transliteration_body.cxx @@ -121,8 +121,17 @@ Transliteration_body::transliterateImpl( // Yes, on massive use even such small things do count. if ( pOffset ) { - std::vector<sal_Int32> aVec; - aVec.reserve(std::max<sal_Int32>(nLocalBuf, nCount) * NMAPPINGMAX); + sal_Int32* offsetData; + std::unique_ptr<sal_Int32[]> pOffsetHeapBuf; + sal_Int32 nOffsetCount = std::max<sal_Int32>(nLocalBuf, nCount); + if (nOffsetCount <= nLocalBuf) + offsetData = static_cast<sal_Int32*>(alloca(nOffsetCount * NMAPPINGMAX * sizeof(sal_Int32))); + else + { + pOffsetHeapBuf.reset(new sal_Int32[ nOffsetCount * NMAPPINGMAX ]); + offsetData = pOffsetHeapBuf.get(); + } + sal_Int32* offsetDataEnd = offsetData; for (sal_Int32 i = 0; i < nCount; i++) { @@ -130,12 +139,13 @@ Transliteration_body::transliterateImpl( MappingType nTmpMappingType = lcl_getMappingTypeForToggleCase( nMappingType, in[i] ); const i18nutil::Mapping &map = i18nutil::casefolding::getValue( in, i, nCount, aLocale, nTmpMappingType ); - std::fill_n(std::back_inserter(aVec), map.nmap, i + startPos); + std::fill_n(offsetDataEnd, map.nmap, i + startPos); + offsetDataEnd += map.nmap; std::copy_n(map.map, map.nmap, out + j); j += map.nmap; } - *pOffset = comphelper::containerToSequence(aVec); + *pOffset = css::uno::Sequence< sal_Int32 >(offsetData, offsetDataEnd - offsetData); } else { |