summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-10-17 20:33:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-23 08:55:00 +0200
commitc68be56c295c8dda3043c80d4641575ec2799e55 (patch)
tree40fc9a82e021498f7cebe76e59bec5bb85d6385c /i18npool
parent437dc68285dab0f08a1ded2193d86d64f560cd9b (diff)
size some stringbuffer to prevent re-alloc
Change-Id: I385587a922c555c320a45dcc6d644315b72510e9 Reviewed-on: https://gerrit.libreoffice.org/81278 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx16
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx10
-rw-r--r--i18npool/source/collator/gencoll_rule.cxx6
-rw-r--r--i18npool/source/indexentry/genindex_data.cxx3
4 files changed, 20 insertions, 15 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 7daf9e98e573..a1d423879109 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -792,10 +792,10 @@ void TestBreakIterator::testWeak()
for (sal_Int32 i = 0; i < aWeaks.getLength(); ++i)
{
sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i);
- OStringBuffer aMsg;
- aMsg.append("Char 0x");
- aMsg.append(static_cast<sal_Int32>(aWeaks[i]), 16);
- aMsg.append(" should have been weak");
+ OString aMsg =
+ "Char 0x" +
+ OString::number(static_cast<sal_Int32>(aWeaks[i]), 16) +
+ " should have been weak";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::WEAK, nScript);
}
@@ -831,10 +831,10 @@ void TestBreakIterator::testAsian()
for (sal_Int32 i = 0; i < aAsians.getLength(); ++i)
{
sal_Int16 nScript = m_xBreak->getScriptType(aAsians, i);
- OStringBuffer aMsg;
- aMsg.append("Char 0x");
- aMsg.append(static_cast<sal_Int32>(aAsians[i]), 16);
- aMsg.append(" should have been asian");
+ OString aMsg =
+ "Char 0x" +
+ OString::number(static_cast<sal_Int32>(aAsians[i]), 16) +
+ " should have been asian";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::ASIAN, nScript);
}
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index f21e377c68c0..b349066d06d7 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -165,13 +165,13 @@ void xdictionary::initDictionaryData(const sal_Char *pLang)
aEntry.maLang = OString( pLang, strlen( pLang ) );
#ifdef SAL_DLLPREFIX
- OUStringBuffer aBuf( sal::static_int_cast<int>(strlen(pLang) + 7 + 6) ); // mostly "lib*.so" (with * == dict_zh)
- aBuf.append( SAL_DLLPREFIX );
+ OString sModuleName = // mostly "lib*.so" (with * == dict_zh)
+ SAL_DLLPREFIX
#else
- OUStringBuffer aBuf( sal::static_int_cast<int>(strlen(pLang) + 7 + 4) ); // mostly "*.dll" (with * == dict_zh)
+ OString sModuleName = // mostly "*.dll" (with * == dict_zh)
#endif
- aBuf.append( "dict_" ).appendAscii( pLang ).append( SAL_DLLEXTENSION );
- aEntry.mhModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT );
+ "dict_" + rtl::OStringView(pLang) + SAL_DLLEXTENSION;
+ aEntry.mhModule = osl_loadModuleRelativeAscii( &thisModule, sModuleName.getStr(), SAL_LOADMODULE_DEFAULT );
if( aEntry.mhModule ) {
oslGenericFunction func;
func = osl_getAsciiFunctionSymbol( aEntry.mhModule, "getExistMark" );
diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx
index fb0349f19b84..33be2a5a2c56 100644
--- a/i18npool/source/collator/gencoll_rule.cxx
+++ b/i18npool/source/collator/gencoll_rule.cxx
@@ -88,8 +88,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
exit(1);
}
+ fseek(fp, 0L, SEEK_END);
+ int fileSize = ftell(fp);
+ rewind(fp);
+
sal_Char str[1024];
- OUStringBuffer Obuf;
+ OUStringBuffer Obuf(fileSize);
while (fgets(str, 1024, fp)) {
// don't convert last new line character to Ostr.
sal_Int32 len = strlen(str) - 1;
diff --git a/i18npool/source/indexentry/genindex_data.cxx b/i18npool/source/indexentry/genindex_data.cxx
index d5bad8b18def..128fad664bfb 100644
--- a/i18npool/source/indexentry/genindex_data.cxx
+++ b/i18npool/source/indexentry/genindex_data.cxx
@@ -49,7 +49,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
sal_Int32 address[MAX_ADDRESS];
for (i=0; i<MAX_ADDRESS; i++) address[i]=-1;
OUString sep('|');
- OUStringBuffer result=sep;
+ OUStringBuffer result(64*1024);
+ result.append(sep);
sal_Int32 max=0;
sal_Char str[1024];