basic/source/runtime/iosys.cxx                  |    7 +++----
 connectivity/source/drivers/dbase/DTable.cxx    |    6 ++----
 svtools/source/svhtml/parhtml.cxx               |    4 +---
 sw/source/filter/ww8/docxtableexport.cxx        |    5 +----
 vcl/source/accessibility/vclxaccessibleedit.cxx |    4 +---
 vcl/source/app/help.cxx                         |    4 +---
 vcl/source/control/edit.cxx                     |    4 +---
 vcl/source/control/field.cxx                    |   11 +++++------
 vcl/source/control/fixed.cxx                    |   12 ++++--------
 vcl/source/control/fmtfield.cxx                 |    3 +--
 vcl/source/filter/ipdf/pdfdocument.cxx          |    8 ++------
 vcl/source/gdi/pdfwriter_impl.cxx               |   11 +++--------
 xmloff/source/style/xmlnumfe.cxx                |    6 +++---
 13 files changed, 28 insertions(+), 57 deletions(-)

New commits:
commit 4b750f6ed5c106f8adb86a5579ad96dc60c5e72f
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Aug 29 02:57:41 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Aug 29 06:12:07 2025 +0200

    Use RepeatedChar
    
    Change-Id: I3eb055746d9600b5290f7390900ad2f932345fd7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190347
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index a30f8e763aff..d49890d52790 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -507,11 +507,10 @@ ErrCode SbiStream::Read(OString& rBuf, sal_uInt16 n, bool 
bForceReadingPerByte)
         {
             return nError = ERRCODE_BASIC_BAD_RECORD_LENGTH;
         }
-        OStringBuffer aBuffer(read_uInt8s_ToOString(*pStrm, n));
+        rBuf = read_uInt8s_ToOString(*pStrm, n);
         //Pad it out with ' ' to the requested length on short read
-        sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n);
-        comphelper::string::padToLength(aBuffer, nRequested, ' ');
-        rBuf = aBuffer.makeStringAndClear();
+        if (rBuf.getLength() < static_cast<sal_Int32>(n))
+            rBuf += OString::Concat(RepeatedChar(' ', n));
     }
     MapError();
     if( !nError && pStrm->eof() )
diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index c7b6802209fd..a3d68bffb2ce 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1930,11 +1930,9 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, 
const OValueRefRow& pOrgRo
                         break;
                     WriteMemo(thisColVal, nBlockNo);
 
-                    OString aBlock(OString::number(nBlockNo));
+                    auto aBlock(OString::number(nBlockNo));
                     //align aBlock at the right of a nLen sequence, fill to 
the left with '0'
-                    OStringBuffer aStr;
-                    comphelper::string::padToLength(aStr, nLen - 
aBlock.getLength(), '0');
-                    aStr.append(aBlock);
+                    OString aStr = RepeatedChar('0', nLen - aBlock.length) + 
aBlock;
 
                     // Copy characters:
                     memcpy(pData, aStr.getStr(), nLen);
diff --git a/sw/source/filter/ww8/docxtableexport.cxx 
b/sw/source/filter/ww8/docxtableexport.cxx
index 30124265e7c9..721f49a191cd 100644
--- a/sw/source/filter/ww8/docxtableexport.cxx
+++ b/sw/source/filter/ww8/docxtableexport.cxx
@@ -55,10 +55,7 @@ OString lcl_padStartToLength(OString const& aString, 
sal_Int32 nLen, char cFill)
     if (nLen > aString.getLength())
     {
         sal_Int32 nDiff = nLen - aString.getLength();
-        OStringBuffer aBuffer;
-        comphelper::string::padToLength(aBuffer, nDiff, cFill);
-        aBuffer.append(aString);
-        return aBuffer.makeStringAndClear();
+        return RepeatedChar(cFill, nDiff) + aString;
     }
     else
         return aString;
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 270248f533d9..4595047a347b 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -140,9 +140,7 @@ sal_Int32 
PDFDocument::WriteSignatureObject(svl::crypto::SigningContext& rSignin
                                "<</Contents <");
     rContentOffset = aSignatureEntry.GetOffset() + aSigBuffer.getLength();
     // Reserve space for the PKCS#7 object.
-    OStringBuffer aContentFiller(MAX_SIGNATURE_CONTENT_LENGTH);
-    comphelper::string::padToLength(aContentFiller, 
MAX_SIGNATURE_CONTENT_LENGTH, '0');
-    aSigBuffer.append(aContentFiller + ">
/Type/Sig/SubFilter");
+    aSigBuffer.append(RepeatedChar('0', MAX_SIGNATURE_CONTENT_LENGTH) + ">
/Type/Sig/SubFilter");
     if (bAdES)
         aSigBuffer.append("/ETSI.CAdES.detached");
     else
@@ -161,9 +159,7 @@ sal_Int32 
PDFDocument::WriteSignatureObject(svl::crypto::SigningContext& rSignin
     rLastByteRangeOffset = aSignatureEntry.GetOffset() + 
aSigBuffer.getLength();
     // We don't know how many bytes we need for the last ByteRange value, this
     // should be enough.
-    OStringBuffer aByteRangeFiller;
-    comphelper::string::padToLength(aByteRangeFiller, 100, ' ');
-    aSigBuffer.append(aByteRangeFiller
+    aSigBuffer.append(RepeatedChar(' ', 100)
                       // Finish the Sig obj.
                       + " /Filter/Adobe.PPKMS");
 
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index eafe17b67b80..e10d4b725298 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5556,10 +5556,8 @@ bool PDFWriterImpl::emitSignature()
     m_nSignatureContentOffset = nOffset + aLine.getLength();
 
     // reserve some space for the PKCS#7 object
-    OStringBuffer aContentFiller( MAX_SIGNATURE_CONTENT_LENGTH );
-    comphelper::string::padToLength(aContentFiller, 
MAX_SIGNATURE_CONTENT_LENGTH, '0');
-    aLine.append( aContentFiller );
-    aLine.append( ">
/Type/Sig/SubFilter/adbe.pkcs7.detached");
+    aLine.append(RepeatedChar('0', MAX_SIGNATURE_CONTENT_LENGTH)
+                 + ">
/Type/Sig/SubFilter/adbe.pkcs7.detached");
 
     if( !m_aContext.DocumentInfo.Author.isEmpty() )
     {
@@ -5581,10 +5579,7 @@ bool PDFWriterImpl::emitSignature()
     // mark the last ByteRange no and add some space. Now, we don't know
     // how many bytes we need for this ByteRange value
     // The real value will be overwritten in the finalizeSignature method
-    OStringBuffer aByteRangeFiller( 100  );
-    comphelper::string::padToLength(aByteRangeFiller, 100, ' ');
-    aLine.append( aByteRangeFiller );
-    aLine.append("  /Filter/Adobe.PPKMS");
+    aLine.append(RepeatedChar(' ', 100) + "  /Filter/Adobe.PPKMS");
 
     //emit reason, location and contactinfo
     if ( !m_aContext.SignReason.isEmpty() )
commit 815480b7488d5c1b409207ee56fe517ebbbdc476
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Aug 29 02:14:02 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Aug 29 06:12:00 2025 +0200

    No need to create another buffer to pad original one
    
    Change-Id: I071f7c1af619309d1256eee25594112a6918b4a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190346
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/svtools/source/svhtml/parhtml.cxx 
b/svtools/source/svhtml/parhtml.cxx
index a5bffbd9dcbd..0356d7c1a645 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -1658,9 +1658,7 @@ HtmlTokenId HTMLParser::FilterPRE( HtmlTokenId nToken )
             DBG_ASSERT( aToken.isEmpty(), "Why is the token not empty?" );
             if (aToken.getLength() < nSpaces)
             {
-                using comphelper::string::padToLength;
-                OUStringBuffer aBuf(aToken);
-                aToken = padToLength(aBuf, nSpaces, ' ');
+                comphelper::string::padToLength(aToken, nSpaces, ' ');
             }
             nPre_LinePos += nSpaces;
             nToken = HtmlTokenId::TEXTTOKEN;
commit 1f0d2531dbeff80eeb3a4fe8485ef1baec6d5752
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Aug 29 02:09:35 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Aug 29 06:11:54 2025 +0200

    Use RepeatedUChar in vcl and xmloff
    
    Change-Id: I4c59d50766f6c695ae0b492f458f3ad152598020
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190345
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/source/accessibility/vclxaccessibleedit.cxx 
b/vcl/source/accessibility/vclxaccessibleedit.cxx
index 5aede6aedb7e..fd2938a38aaf 100644
--- a/vcl/source/accessibility/vclxaccessibleedit.cxx
+++ b/vcl/source/accessibility/vclxaccessibleedit.cxx
@@ -138,9 +138,7 @@ OUString VCLXAccessibleEdit::implGetText()
             sal_Unicode cEchoChar = pEdit->GetEchoChar();
             if ( !cEchoChar )
                 cEchoChar = '*';
-            OUStringBuffer sTmp(aText.getLength());
-            aText = comphelper::string::padToLength(sTmp, aText.getLength(),
-                cEchoChar).makeStringAndClear();
+            aText = OUString::Concat(RepeatedUChar(cEchoChar, 
aText.getLength()));
         }
     }
 
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index fc8340a489fb..a8256cddf8fb 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -341,9 +341,7 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText 
)
         else
             nCharsInLine = 35 + ((nHelpTextLength / 100) * 5);
         // average width to have all windows consistent
-        OUStringBuffer aBuf(nCharsInLine);
-        comphelper::string::padToLength(aBuf, nCharsInLine, 'x');
-        tools::Long nWidth = GetTextWidth( OUString::unacquired(aBuf) );
+        tools::Long nWidth = GetTextWidth(OUString::Concat(RepeatedUChar('x', 
nCharsInLine)));
         Size aTmpSize( nWidth, 0x7FFFFFFF );
         tools::Rectangle aTry1( Point(), aTmpSize );
         DrawTextFlags nDrawFlags = DrawTextFlags::MultiLine | 
DrawTextFlags::WordBreak |
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 666db74c89b6..4e4f6eab34c4 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -400,9 +400,7 @@ OUString Edit::ImplGetText() const
             cEchoChar = mcEchoChar;
         else
             cEchoChar = u'\x2022';
-        OUStringBuffer aText(maText.getLength());
-        comphelper::string::padToLength(aText, maText.getLength(), cEchoChar);
-        return aText.makeStringAndClear();
+        return OUString::Concat(RepeatedUChar(cEchoChar, maText.getLength()));
     }
     else
         return maText.toString();
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 7f69fb078d59..374abc63ccea 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -784,13 +784,13 @@ namespace
         OUStringBuffer aBuf;
         sal_Int32 nTextLen;
 
-        nTextLen = 
std::u16string_view(OUString::number(rFormatter.GetMin())).size();
+        nTextLen = OUString::number(rFormatter.GetMin()).length;
         comphelper::string::padToLength(aBuf, nTextLen, '9');
         Size aMinTextSize = rSpinField.CalcMinimumSizeForText(
             rFormatter.CreateFieldText(OUString::unacquired(aBuf).toInt64()));
         aBuf.setLength(0);
 
-        nTextLen = 
std::u16string_view(OUString::number(rFormatter.GetMax())).size();
+        nTextLen = OUString::number(rFormatter.GetMax()).length;
         comphelper::string::padToLength(aBuf, nTextLen, '9');
         Size aMaxTextSize = rSpinField.CalcMinimumSizeForText(
             rFormatter.CreateFieldText(OUString::unacquired(aBuf).toInt64()));
@@ -799,14 +799,13 @@ namespace
         Size aRet(std::max(aMinTextSize.Width(), aMaxTextSize.Width()),
                   std::max(aMinTextSize.Height(), aMaxTextSize.Height()));
 
-        OUStringBuffer sBuf("999999999");
+        aBuf = "999999999";
         sal_uInt16 nDigits = rFormatter.GetDecimalDigits();
         if (nDigits)
         {
-            sBuf.append('.');
-            comphelper::string::padToLength(aBuf, aBuf.getLength() + nDigits, 
'9');
+            aBuf.append("." + RepeatedUChar('9', nDigits));
         }
-        aMaxTextSize = 
rSpinField.CalcMinimumSizeForText(sBuf.makeStringAndClear());
+        aMaxTextSize = 
rSpinField.CalcMinimumSizeForText(aBuf.makeStringAndClear());
         aRet.setWidth( std::min(aRet.Width(), aMaxTextSize.Width()) );
 
         return aRet;
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 571cace0b8df..c105accbf98b 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -336,18 +336,14 @@ Size FixedText::GetOptimalSize() const
     sal_Int32 nMaxAvailWidth = 0x7fffffff;
     if (m_nMaxWidthChars != -1)
     {
-        OUStringBuffer aBuf(m_nMaxWidthChars);
-        comphelper::string::padToLength(aBuf, m_nMaxWidthChars, 'x');
-        nMaxAvailWidth = getTextDimensions(this,
-            aBuf.makeStringAndClear(), 0x7fffffff).Width();
+        OUString aBuf(OUString::Concat(RepeatedUChar('x', m_nMaxWidthChars)));
+        nMaxAvailWidth = getTextDimensions(this, aBuf, 0x7fffffff).Width();
     }
     Size aRet = CalcMinimumSize(nMaxAvailWidth);
     if (m_nMinWidthChars != -1)
     {
-        OUStringBuffer aBuf(m_nMinWidthChars);
-        comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x');
-        Size aMinAllowed = getTextDimensions(this,
-            aBuf.makeStringAndClear(), 0x7fffffff);
+        OUString aBuf(OUString::Concat(RepeatedUChar('x', m_nMinWidthChars)));
+        Size aMinAllowed = getTextDimensions(this, aBuf, 0x7fffffff);
         aRet.setWidth(std::max(aMinAllowed.Width(), aRet.Width()));
     }
     return aRet;
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 24d1175d5bde..24165e002730 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -1117,8 +1117,7 @@ void DoubleCurrencyField::UpdateCurrencyFormat()
 
     if (nDigits)
     {
-        sNewFormat.append(aLocaleInfo.getNumDecimalSep());
-        comphelper::string::padToLength(sNewFormat, sNewFormat.getLength() + 
nDigits, '0');
+        sNewFormat.append(aLocaleInfo.getNumDecimalSep() + RepeatedUChar('0', 
nDigits));
     }
 
     if (getPrependCurrSym())
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index ade9e56238a7..d5f653e0b072 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -1677,14 +1677,14 @@ void SvXMLNumFmtExport::ExportPart_Impl( const 
SvNumberformat& rFormat, sal_uInt
                                     //  string for decimal replacement
                                     //  has to be taken from nPrecision
                                     //  (positive number even for automatic 
decimals)
-                                    OUStringBuffer sDashStr;
+                                    OUString sDashStr;
                                     if (bDecDashes && nPrecision > 0)
-                                        
comphelper::string::padToLength(sDashStr, nPrecision, '-');
+                                        sDashStr = 
OUString::Concat(RepeatedUChar('-', nPrecision));
                                     // "?" in decimal part are replaced by 
space character
                                     if (bDecAlign && nPrecision > 0)
                                         sDashStr = " ";
 
-                                    WriteNumberElement_Impl(nDecimals, 
nMinDecimals, nInteger, nBlankInteger, sDashStr.makeStringAndClear(),
+                                    WriteNumberElement_Impl(nDecimals, 
nMinDecimals, nInteger, nBlankInteger, sDashStr,
                                         bThousand, nTrailingThousands, 
aEmbeddedEntries);
                                     bAnyContent = true;
                                 }

Reply via email to