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>
This commit is contained in:
Noel Grandin 2019-10-17 20:33:50 +02:00 committed by Noel Grandin
parent 437dc68285
commit c68be56c29
21 changed files with 123 additions and 65 deletions

View File

@ -39,7 +39,7 @@ namespace codemaker { namespace java {
OString translateUnoToJavaType( OString translateUnoToJavaType(
codemaker::UnoType::Sort sort, OString const & nucleus, bool referenceType) codemaker::UnoType::Sort sort, OString const & nucleus, bool referenceType)
{ {
OStringBuffer buf; OStringBuffer buf(128);
if (sort <= codemaker::UnoType::Sort::Any) { if (sort <= codemaker::UnoType::Sort::Any) {
OString const javaTypes[static_cast<int>(codemaker::UnoType::Sort::Any) + 1][2] = { OString const javaTypes[static_cast<int>(codemaker::UnoType::Sort::Any) + 1][2] = {
{ "void", "java/lang/Void" }, { "void", "java/lang/Void" },

View File

@ -2400,6 +2400,28 @@ void PolyStructType::dumpLightGetCppuType(FileStream & out)
<< "static ::typelib_TypeDescriptionReference * the_type = 0;\n" << "static ::typelib_TypeDescriptionReference * the_type = 0;\n"
<< indent() << "if (the_type == 0) {\n"; << indent() << "if (the_type == 0) {\n";
inc(); inc();
out << "#ifdef LIBO_INTERNAL_ONLY\n";
out << indent() << "::rtl::OString the_buffer = \"" << name_
<< "<\" +\n";
for (std::vector< OUString >::const_iterator i(
entity_->getTypeParameters().begin());
i != entity_->getTypeParameters().end();) {
out << indent()
<< ("::rtl::OUStringToOString("
"::cppu::getTypeFavourChar(static_cast< ");
dumpTypeParameterName(out, *i);
out << " * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8) +\n";
++i;
if (i != entity_->getTypeParameters().end()) {
out << indent() << "\",\" +\n";
}
}
out << indent() << "\">\";\n";
out << "#else\n";
out << indent() << "::rtl::OStringBuffer the_buffer(\"" << name_ out << indent() << "::rtl::OStringBuffer the_buffer(\"" << name_
<< "<\");\n"; << "<\");\n";
for (std::vector< OUString >::const_iterator i( for (std::vector< OUString >::const_iterator i(
@ -2415,9 +2437,14 @@ void PolyStructType::dumpLightGetCppuType(FileStream & out)
out << indent() << "the_buffer.append(',');\n"; out << indent() << "the_buffer.append(',');\n";
} }
} }
out << indent() << "the_buffer.append('>');\n" << indent() out << indent() << "the_buffer.append('>');\n";
out << "#endif\n";
out << indent()
<< "::typelib_static_type_init(&the_type, " << getTypeClass(name_, true) << "::typelib_static_type_init(&the_type, " << getTypeClass(name_, true)
<< ", the_buffer.getStr());\n"; << ", the_buffer.getStr());\n";
dec(); dec();
out << indent() << "}\n" << indent() out << indent() << "}\n" << indent()
<< "return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n"; << "return *reinterpret_cast< ::css::uno::Type * >(&the_type);\n";
@ -2506,6 +2533,27 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out)
out << indent() << "::css::uno::Type * operator()() const\n" out << indent() << "::css::uno::Type * operator()() const\n"
<< indent() << "{\n"; << indent() << "{\n";
inc(); inc();
out << "#ifdef LIBO_INTERNAL_ONLY\n";
out << indent()
<< "::rtl::OUString the_name =\n";
out << indent() << "\"" << name_ << "<\" +\n";
for (std::vector< OUString >::const_iterator i(
entity_->getTypeParameters().begin());
i != entity_->getTypeParameters().end();) {
out << indent()
<< "::cppu::getTypeFavourChar(static_cast< ";
dumpTypeParameterName(out, *i);
out << " * >(0)).getTypeName() +\n";
++i;
if (i != entity_->getTypeParameters().end()) {
out << indent()
<< "\",\" +\n";
}
}
out << indent()
<< "\">\";\n";
out << "#else\n";
out << indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent() out << indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent()
<< "the_buffer.append(\"" << name_ << "<\");\n"; << "the_buffer.append(\"" << name_ << "<\");\n";
for (std::vector< OUString >::const_iterator i( for (std::vector< OUString >::const_iterator i(
@ -2522,9 +2570,10 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out)
"static_cast< ::sal_Unicode >(','));\n"); "static_cast< ::sal_Unicode >(','));\n");
} }
} }
out << indent() << "the_buffer.append(static_cast< ::sal_Unicode >('>'));\n" out << indent() << "the_buffer.append(static_cast< ::sal_Unicode >('>'));\n";
<< indent() out << indent()
<< "::rtl::OUString the_name(the_buffer.makeStringAndClear());\n"; << "::rtl::OUString the_name(the_buffer.makeStringAndClear());\n";
out << "#endif\n";
std::map< OUString, sal_uInt32 > parameters; std::map< OUString, sal_uInt32 > parameters;
std::map< OUString, sal_uInt32 > types; std::map< OUString, sal_uInt32 > types;
std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >:: std::vector< unoidl::PolymorphicStructTypeTemplateEntity::Member >::

View File

@ -89,7 +89,7 @@ OUString createUnoName(
rtl::Reference< TypeManager > const & manager, OUString const & nucleus, rtl::Reference< TypeManager > const & manager, OUString const & nucleus,
sal_Int32 rank, std::vector< OUString > const & arguments) sal_Int32 rank, std::vector< OUString > const & arguments)
{ {
OUStringBuffer buf; OUStringBuffer buf(256);
appendUnoName(manager, nucleus, rank, arguments, &buf); appendUnoName(manager, nucleus, rank, arguments, &buf);
return buf.makeStringAndClear(); return buf.makeStringAndClear();
} }
@ -293,8 +293,8 @@ SpecialType getFieldDescriptor(
PolymorphicUnoType * polymorphicUnoType) PolymorphicUnoType * polymorphicUnoType)
{ {
assert(descriptor != nullptr); assert(descriptor != nullptr);
OStringBuffer desc; OStringBuffer desc(64);
OStringBuffer sig; OStringBuffer sig(64);
bool needsSig = false; bool needsSig = false;
SpecialType specialType = translateUnoTypeToDescriptor( SpecialType specialType = translateUnoTypeToDescriptor(
manager, type, false, false, dependencies, &desc, &sig, &needsSig, manager, type, false, false, dependencies, &desc, &sig, &needsSig,
@ -331,9 +331,9 @@ public:
private: private:
rtl::Reference< TypeManager > m_manager; rtl::Reference< TypeManager > m_manager;
std::set<OUString> * m_dependencies; std::set<OUString> * m_dependencies;
OStringBuffer m_descriptorStart; OStringBuffer m_descriptorStart{16*1024};
OString m_descriptorEnd; OString m_descriptorEnd;
OStringBuffer m_signatureStart; OStringBuffer m_signatureStart{16*1024};
OString m_signatureEnd; OString m_signatureEnd;
bool m_needsSignature; bool m_needsSignature;
}; };
@ -347,9 +347,9 @@ MethodDescriptor::MethodDescriptor(
assert(dependencies != nullptr); assert(dependencies != nullptr);
m_descriptorStart.append('('); m_descriptorStart.append('(');
m_signatureStart.append('('); m_signatureStart.append('(');
OStringBuffer descEnd; OStringBuffer descEnd(128);
descEnd.append(')'); descEnd.append(')');
OStringBuffer sigEnd; OStringBuffer sigEnd(128);
sigEnd.append(')'); sigEnd.append(')');
SpecialType special = translateUnoTypeToDescriptor( SpecialType special = translateUnoTypeToDescriptor(
m_manager, returnType, false, false, m_dependencies, &descEnd, &sigEnd, m_manager, returnType, false, false, m_dependencies, &descEnd, &sigEnd,
@ -896,7 +896,7 @@ sal_uInt16 addFieldInit(
dynamic_cast< unoidl::EnumTypeEntity * >(ent.get())); dynamic_cast< unoidl::EnumTypeEntity * >(ent.get()));
assert(ent2.is()); assert(ent2.is());
code->loadLocalReference(0); code->loadLocalReference(0);
OStringBuffer descBuf; OStringBuffer descBuf(128);
translateUnoTypeToDescriptor( translateUnoTypeToDescriptor(
manager, sort, nucleus, 0, std::vector< OUString >(), false, manager, sort, nucleus, 0, std::vector< OUString >(), false,
false, dependencies, &descBuf, nullptr, nullptr, nullptr); false, dependencies, &descBuf, nullptr, nullptr, nullptr);
@ -917,7 +917,7 @@ sal_uInt16 addFieldInit(
code->instrInvokespecial( code->instrInvokespecial(
codemaker::convertString(nucleus).replace('.', '/'), codemaker::convertString(nucleus).replace('.', '/'),
"<init>", "()V"); "<init>", "()V");
OStringBuffer desc; OStringBuffer desc(128);
translateUnoTypeToDescriptor( translateUnoTypeToDescriptor(
manager, sort, nucleus, 0, args, false, false, dependencies, manager, sort, nucleus, 0, args, false, false, dependencies,
&desc, nullptr, nullptr, nullptr); &desc, nullptr, nullptr, nullptr);
@ -947,13 +947,13 @@ sal_uInt16 addFieldInit(
false)); false));
} }
} else { } else {
OStringBuffer desc; OStringBuffer desc(128);
translateUnoTypeToDescriptor( translateUnoTypeToDescriptor(
manager, sort, nucleus, rank - 1, std::vector< OUString >(), false, manager, sort, nucleus, rank - 1, std::vector< OUString >(), false,
false, dependencies, &desc, nullptr, nullptr, nullptr); false, dependencies, &desc, nullptr, nullptr, nullptr);
code->instrAnewarray(desc.makeStringAndClear()); code->instrAnewarray(desc.makeStringAndClear());
} }
OStringBuffer desc; OStringBuffer desc(128);
translateUnoTypeToDescriptor( translateUnoTypeToDescriptor(
manager, sort, nucleus, rank, std::vector< OUString >(), false, false, manager, sort, nucleus, rank, std::vector< OUString >(), false, false,
dependencies, &desc, nullptr, nullptr, nullptr); dependencies, &desc, nullptr, nullptr, nullptr);
@ -1440,7 +1440,8 @@ void handlePolyStructType(
assert(entity.is()); assert(entity.is());
OString className(codemaker::convertString(name).replace('.', '/')); OString className(codemaker::convertString(name).replace('.', '/'));
std::map< OUString, sal_Int32 > typeParameters; std::map< OUString, sal_Int32 > typeParameters;
OStringBuffer sig("<"); OStringBuffer sig(128);
sig.append("<");
sal_Int32 index = 0; sal_Int32 index = 0;
for (const OUString& param : entity->getTypeParameters()) for (const OUString& param : entity->getTypeParameters())
{ {

View File

@ -49,16 +49,18 @@ public:
void Base64Test::testBase64Encode() void Base64Test::testBase64Encode()
{ {
OUStringBuffer aBuffer; OUStringBuffer aBuffer(32);
uno::Sequence<sal_Int8> inputSequence; uno::Sequence<sal_Int8> inputSequence;
inputSequence = { 0, 0, 0, 0, 0, 1, 2, 3 }; inputSequence = { 0, 0, 0, 0, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);
CPPUNIT_ASSERT_EQUAL(OUString("AAAAAAABAgM="), aBuffer.makeStringAndClear()); CPPUNIT_ASSERT_EQUAL(OUString("AAAAAAABAgM="), aBuffer.toString());
aBuffer.setLength(0);
inputSequence = { 5, 2, 3, 0, 0, 1, 2, 3 }; inputSequence = { 5, 2, 3, 0, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);
CPPUNIT_ASSERT_EQUAL(OUString("BQIDAAABAgM="), aBuffer.makeStringAndClear()); CPPUNIT_ASSERT_EQUAL(OUString("BQIDAAABAgM="), aBuffer.toString());
aBuffer.setLength(0);
inputSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 }; inputSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);
@ -84,16 +86,18 @@ void Base64Test::testBase64Decode()
void Base64Test::testBase64EncodeForOStringBuffer() void Base64Test::testBase64EncodeForOStringBuffer()
{ {
OStringBuffer aBuffer; OStringBuffer aBuffer(32);
uno::Sequence<sal_Int8> inputSequence; uno::Sequence<sal_Int8> inputSequence;
inputSequence = { 0, 0, 0, 0, 0, 1, 2, 3 }; inputSequence = { 0, 0, 0, 0, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);
CPPUNIT_ASSERT_EQUAL(OString("AAAAAAABAgM="), aBuffer.makeStringAndClear()); CPPUNIT_ASSERT_EQUAL(OString("AAAAAAABAgM="), aBuffer.toString());
aBuffer.setLength(0);
inputSequence = { 5, 2, 3, 0, 0, 1, 2, 3 }; inputSequence = { 5, 2, 3, 0, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);
CPPUNIT_ASSERT_EQUAL(OString("BQIDAAABAgM="), aBuffer.makeStringAndClear()); CPPUNIT_ASSERT_EQUAL(OString("BQIDAAABAgM="), aBuffer.toString());
aBuffer.setLength(0);
inputSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 }; inputSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 };
comphelper::Base64::encode(aBuffer, inputSequence); comphelper::Base64::encode(aBuffer, inputSequence);

View File

@ -308,7 +308,7 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
css::uno::Sequence<sal_Int8> aSeq( GetOoxHashAsSequence( rPassword, rSaltValue, nSpinCount, css::uno::Sequence<sal_Int8> aSeq( GetOoxHashAsSequence( rPassword, rSaltValue, nSpinCount,
eIterCount, rAlgorithmName)); eIterCount, rAlgorithmName));
OUStringBuffer aBuf; OUStringBuffer aBuf((aSeq.getLength()+2)/3*4);
comphelper::Base64::encode( aBuf, aSeq); comphelper::Base64::encode( aBuf, aSeq);
return aBuf.makeStringAndClear(); return aBuf.makeStringAndClear();
} }

View File

@ -1629,7 +1629,7 @@ OUString ContentNode::GetExpandedText(sal_Int32 nStartPos, sal_Int32 nEndPos) co
DBG_ASSERT( nStartPos <= nEndPos, "Start and End reversed?" ); DBG_ASSERT( nStartPos <= nEndPos, "Start and End reversed?" );
sal_Int32 nIndex = nStartPos; sal_Int32 nIndex = nStartPos;
OUStringBuffer aStr; OUStringBuffer aStr(256);
const EditCharAttrib* pNextFeature = GetCharAttribs().FindFeature( nIndex ); const EditCharAttrib* pNextFeature = GetCharAttribs().FindFeature( nIndex );
while ( nIndex < nEndPos ) while ( nIndex < nEndPos )
{ {

View File

@ -287,7 +287,7 @@ OUString ImpEditEngine::GetSelected( const EditSelection& rSel ) const
OSL_ENSURE( nStartNode <= nEndNode, "Selection not sorted ?" ); OSL_ENSURE( nStartNode <= nEndNode, "Selection not sorted ?" );
OUStringBuffer aText; OUStringBuffer aText(256);
const OUString aSep = EditDoc::GetSepStr( LINEEND_LF ); const OUString aSep = EditDoc::GetSepStr( LINEEND_LF );
// iterate over the paragraphs ... // iterate over the paragraphs ...

View File

@ -792,10 +792,10 @@ void TestBreakIterator::testWeak()
for (sal_Int32 i = 0; i < aWeaks.getLength(); ++i) for (sal_Int32 i = 0; i < aWeaks.getLength(); ++i)
{ {
sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i); sal_Int16 nScript = m_xBreak->getScriptType(aWeaks, i);
OStringBuffer aMsg; OString aMsg =
aMsg.append("Char 0x"); "Char 0x" +
aMsg.append(static_cast<sal_Int32>(aWeaks[i]), 16); OString::number(static_cast<sal_Int32>(aWeaks[i]), 16) +
aMsg.append(" should have been weak"); " should have been weak";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::WEAK, nScript); i18n::ScriptType::WEAK, nScript);
} }
@ -831,10 +831,10 @@ void TestBreakIterator::testAsian()
for (sal_Int32 i = 0; i < aAsians.getLength(); ++i) for (sal_Int32 i = 0; i < aAsians.getLength(); ++i)
{ {
sal_Int16 nScript = m_xBreak->getScriptType(aAsians, i); sal_Int16 nScript = m_xBreak->getScriptType(aAsians, i);
OStringBuffer aMsg; OString aMsg =
aMsg.append("Char 0x"); "Char 0x" +
aMsg.append(static_cast<sal_Int32>(aAsians[i]), 16); OString::number(static_cast<sal_Int32>(aAsians[i]), 16) +
aMsg.append(" should have been asian"); " should have been asian";
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(),
i18n::ScriptType::ASIAN, nScript); i18n::ScriptType::ASIAN, nScript);
} }

View File

@ -165,13 +165,13 @@ void xdictionary::initDictionaryData(const sal_Char *pLang)
aEntry.maLang = OString( pLang, strlen( pLang ) ); aEntry.maLang = OString( pLang, strlen( pLang ) );
#ifdef SAL_DLLPREFIX #ifdef SAL_DLLPREFIX
OUStringBuffer aBuf( sal::static_int_cast<int>(strlen(pLang) + 7 + 6) ); // mostly "lib*.so" (with * == dict_zh) OString sModuleName = // mostly "lib*.so" (with * == dict_zh)
aBuf.append( SAL_DLLPREFIX ); SAL_DLLPREFIX
#else #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 #endif
aBuf.append( "dict_" ).appendAscii( pLang ).append( SAL_DLLEXTENSION ); "dict_" + rtl::OStringView(pLang) + SAL_DLLEXTENSION;
aEntry.mhModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT ); aEntry.mhModule = osl_loadModuleRelativeAscii( &thisModule, sModuleName.getStr(), SAL_LOADMODULE_DEFAULT );
if( aEntry.mhModule ) { if( aEntry.mhModule ) {
oslGenericFunction func; oslGenericFunction func;
func = osl_getAsciiFunctionSymbol( aEntry.mhModule, "getExistMark" ); func = osl_getAsciiFunctionSymbol( aEntry.mhModule, "getExistMark" );

View File

@ -88,8 +88,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
exit(1); exit(1);
} }
fseek(fp, 0L, SEEK_END);
int fileSize = ftell(fp);
rewind(fp);
sal_Char str[1024]; sal_Char str[1024];
OUStringBuffer Obuf; OUStringBuffer Obuf(fileSize);
while (fgets(str, 1024, fp)) { while (fgets(str, 1024, fp)) {
// don't convert last new line character to Ostr. // don't convert last new line character to Ostr.
sal_Int32 len = strlen(str) - 1; sal_Int32 len = strlen(str) - 1;

View File

@ -49,7 +49,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
sal_Int32 address[MAX_ADDRESS]; sal_Int32 address[MAX_ADDRESS];
for (i=0; i<MAX_ADDRESS; i++) address[i]=-1; for (i=0; i<MAX_ADDRESS; i++) address[i]=-1;
OUString sep('|'); OUString sep('|');
OUStringBuffer result=sep; OUStringBuffer result(64*1024);
result.append(sep);
sal_Int32 max=0; sal_Int32 max=0;
sal_Char str[1024]; sal_Char str[1024];

View File

@ -31,7 +31,8 @@ namespace {
OString createName( OString createName(
AstType const * typeTemplate, DeclList const * typeArguments) AstType const * typeTemplate, DeclList const * typeArguments)
{ {
OStringBuffer buf(typeTemplate->getScopedName()); OStringBuffer buf(64);
buf.append(typeTemplate->getScopedName());
if (typeArguments != nullptr) { if (typeArguments != nullptr) {
buf.append('<'); buf.append('<');
for (DeclList::const_iterator i(typeArguments->begin()); for (DeclList::const_iterator i(typeArguments->begin());

View File

@ -238,7 +238,6 @@ sal_Int32 compileFile(const OString * pathname)
lCppArgs.emplace_back("-C"); lCppArgs.emplace_back("-C");
lCppArgs.emplace_back("-zI"); lCppArgs.emplace_back("-zI");
OStringBuffer cppArgs(256);
Options* pOptions = idlc()->getOptions(); Options* pOptions = idlc()->getOptions();
OString filePath; OString filePath;
@ -250,10 +249,9 @@ sal_Int32 compileFile(const OString * pathname)
if ( !filePath.isEmpty() ) if ( !filePath.isEmpty() )
{ {
cppArgs.append("-I"); OString cppArgs = "-I" + filePath;
cppArgs.append(filePath);
lCppArgs.push_back(OStringToOUString( lCppArgs.push_back(OStringToOUString(
cppArgs.makeStringAndClear().replace('\\', '/'), cppArgs.replace('\\', '/'),
RTL_TEXTENCODING_UTF8)); RTL_TEXTENCODING_UTF8));
} }
} }
@ -284,11 +282,9 @@ sal_Int32 compileFile(const OString * pathname)
lCppArgs.emplace_back("-o"); lCppArgs.emplace_back("-o");
cppArgs.append(preprocFile); lCppArgs.push_back(OStringToOUString(preprocFile, RTL_TEXTENCODING_UTF8));
lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
cppArgs.append(tmpFile); lCppArgs.push_back(OStringToOUString(tmpFile, RTL_TEXTENCODING_UTF8));
lCppArgs.push_back(OStringToOUString(cppArgs.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
OUString cpp; OUString cpp;
OUString startDir; OUString startDir;

View File

@ -44,7 +44,7 @@ static std::list< OString >* pCreatedDirectories = nullptr;
static bool checkOutputPath(const OString& completeName) static bool checkOutputPath(const OString& completeName)
{ {
OString sysPathName = convertToAbsoluteSystemPath(completeName); OString sysPathName = convertToAbsoluteSystemPath(completeName);
OStringBuffer buffer(sysPathName.getLength()); OStringBuffer buffer(sysPathName.getLength()+16);
if ( sysPathName.indexOf( SEPARATOR ) == -1 ) if ( sysPathName.indexOf( SEPARATOR ) == -1 )
return true; return true;

View File

@ -79,13 +79,13 @@ namespace detail {
} }
if( !fromAny( seq[nArg], &v ) ) if( !fromAny( seq[nArg], &v ) )
{ {
OUStringBuffer buf; OUString msg =
buf.append( "Cannot extract ANY { " ); "Cannot extract ANY { " +
buf.append( seq[nArg].getValueType().getTypeName() ); seq[nArg].getValueType().getTypeName() +
buf.append( " } to " ); " } to " +
buf.append( ::cppu::UnoType<T>::get().getTypeName() ); ::cppu::UnoType<T>::get().getTypeName() +
buf.append( u'!' ); "!";
return unwrapArgsError( buf.makeStringAndClear(), nArg, args... ); return unwrapArgsError( msg, nArg, args... );
} }
return unwrapArgs( seq, ++nArg, args... ); return unwrapArgs( seq, ++nArg, args... );
} }

View File

@ -970,7 +970,8 @@ OStoreDirectory ORegKey::getStoreDir() const
OUString ORegKey::getFullPath(OUString const & path) const { OUString ORegKey::getFullPath(OUString const & path) const {
OSL_ASSERT(!m_name.isEmpty() && !path.isEmpty()); OSL_ASSERT(!m_name.isEmpty() && !path.isEmpty());
OUStringBuffer b(m_name); OUStringBuffer b(32);
b.append(m_name);
if (!b.isEmpty() && b[b.getLength() - 1] == '/') { if (!b.isEmpty() && b[b.getLength() - 1] == '/') {
if (path[0] == '/') { if (path[0] == '/') {
b.append(std::u16string_view(path).substr(1)); b.append(std::u16string_view(path).substr(1));

View File

@ -629,7 +629,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
} }
OStoreDirectory rStoreDir; OStoreDirectory rStoreDir;
OUStringBuffer sFullPath(sFullKeyName.getLength()); OUStringBuffer sFullPath(sFullKeyName.getLength()+16);
OUString token; OUString token;
sFullPath.append('/'); sFullPath.append('/');

View File

@ -90,7 +90,7 @@ void doTest(util::Duration const & rid, char const*const pis,
CPPUNIT_ASSERT_EQUAL(rid.Seconds, od.Seconds); CPPUNIT_ASSERT_EQUAL(rid.Seconds, od.Seconds);
CPPUNIT_ASSERT_EQUAL(rid.NanoSeconds, od.NanoSeconds); CPPUNIT_ASSERT_EQUAL(rid.NanoSeconds, od.NanoSeconds);
CPPUNIT_ASSERT_EQUAL(rid.Negative, od.Negative); CPPUNIT_ASSERT_EQUAL(rid.Negative, od.Negative);
OUStringBuffer buf; OUStringBuffer buf(64);
Converter::convertDuration(buf, od); Converter::convertDuration(buf, od);
SAL_INFO("sax.cppunit","" << buf.toString()); SAL_INFO("sax.cppunit","" << buf.toString());
CPPUNIT_ASSERT(buf.makeStringAndClear().equalsAscii(pos)); CPPUNIT_ASSERT(buf.makeStringAndClear().equalsAscii(pos));
@ -159,7 +159,7 @@ void doTest(util::DateTime const & rdt, char const*const pis,
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << static_cast<bool>(odt.IsUTC)); SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << static_cast<bool>(odt.IsUTC));
CPPUNIT_ASSERT(bSuccess); CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT(eqDateTime(rdt, odt)); CPPUNIT_ASSERT(eqDateTime(rdt, odt));
OUStringBuffer buf; OUStringBuffer buf(32);
Converter::convertDateTime(buf, odt, nullptr, true); Converter::convertDateTime(buf, odt, nullptr, true);
SAL_INFO("sax.cppunit","" << buf.toString()); SAL_INFO("sax.cppunit","" << buf.toString());
CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos), CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos),
@ -253,7 +253,7 @@ void doTestTime(util::DateTime const & rdt, char const*const pis,
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << static_cast<bool>(odt.IsUTC)); SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << static_cast<bool>(odt.IsUTC));
CPPUNIT_ASSERT(bSuccess); CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT(eqDateTime(rdt, odt)); CPPUNIT_ASSERT(eqDateTime(rdt, odt));
OUStringBuffer buf; OUStringBuffer buf(32);
Converter::convertTimeOrDateTime(buf, odt); Converter::convertTimeOrDateTime(buf, odt);
SAL_INFO("sax.cppunit","" << buf.toString()); SAL_INFO("sax.cppunit","" << buf.toString());
CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos), CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos),

View File

@ -551,7 +551,8 @@ OUString lclGetErrorMessage( xmlParserCtxtPtr ctxt, const OUString& sSystemId, s
pMessage = error->message; pMessage = error->message;
else else
pMessage = "unknown error"; pMessage = "unknown error";
OUStringBuffer aBuffer( "[" ); OUStringBuffer aBuffer( 128 );
aBuffer.append( "[" );
aBuffer.append( sSystemId ); aBuffer.append( sSystemId );
aBuffer.append( " line " ); aBuffer.append( " line " );
aBuffer.append( nLine ); aBuffer.append( nLine );

View File

@ -227,7 +227,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
OUString SvGlobalName::GetHexName() const OUString SvGlobalName::GetHexName() const
{ {
OStringBuffer aHexBuffer; OStringBuffer aHexBuffer(36);
sal_Char buf[ 10 ]; sal_Char buf[ 10 ];
sprintf( buf, "%8.8" SAL_PRIXUINT32, pImp->szData.Data1 ); sprintf( buf, "%8.8" SAL_PRIXUINT32, pImp->szData.Data1 );

View File

@ -235,9 +235,9 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey,
NameSpaceMap::const_iterator aIter = aNameMap.find ( nKey ); NameSpaceMap::const_iterator aIter = aNameMap.find ( nKey );
if ( aIter != aNameMap.end() ) if ( aIter != aNameMap.end() )
{ {
OUStringBuffer sQName;
// ...if it's in our map, make the prefix // ...if it's in our map, make the prefix
const OUString & prefix( (*aIter).second->sPrefix ); const OUString & prefix( (*aIter).second->sPrefix );
OUStringBuffer sQName(prefix.getLength() + 1 + rLocalName.getLength());
if (!prefix.isEmpty()) // not default namespace if (!prefix.isEmpty()) // not default namespace
{ {
sQName.append( prefix ); sQName.append( prefix );