diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-07 10:34:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-14 08:35:00 +0200 |
commit | cd66852f6dd08631a25d15a1527a647e69ab8ce3 (patch) | |
tree | 0ac1fab1d063046376e31e21d6656ee05eebb627 /svl | |
parent | 095e1ca4372d90da7fc56051f1271ddd975a9e3a (diff) |
create appendCopy method in OUStringBuffer
so we can avoid temporary copies when appending a substring of an
OUString to the buffer. I would have preferred to call the method just
"append" but that results in ambiguous method errors when the callsite
is something like
sal_Int32 n;
OUStringBuffer s;
s.append(n, 10);
I'm not sure why
Change-Id: I6b5b6641fcb5b26ce2269f89ef06e03c0b6aa76f
Reviewed-on: https://gerrit.libreoffice.org/58666
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/misc/urihelper.cxx | 5 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index f757b2524947..290d81cca769 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -783,12 +783,11 @@ OUString URIHelper::resolveIdnaHost(OUString const & url) { return url; } OUStringBuffer buf(uri->getScheme()); - buf.append("://").append(auth.getStr(), hostStart); + buf.append("://").appendCopy(auth, 0, hostStart); buf.append( reinterpret_cast<sal_Unicode const *>(ascii.getBuffer()), ascii.length()); - buf.append(auth.getStr() + hostEnd, auth.getLength() - hostEnd) - .append(uri->getPath()); + buf.appendCopy(auth, hostEnd).append(uri->getPath()); if (uri->hasQuery()) { buf.append('?').append(uri->getQuery()); } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index f9e0b944b615..38b8f243f22d 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1706,7 +1706,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString, 0 <= nNatNumNum && nNatNumNum <= 19 ) { sBuffSymbol.stripStart('['); - sBuffSymbol.append( aBufStr.copy( --nPos, aNatNum.getLength()+1 )); + sBuffSymbol.appendCopy( aBufStr, --nPos, aNatNum.getLength()+1 ); nPos += aNatNum.getLength()+1; //! SymbolType is negative eSymbolType = static_cast<short>(BRACKET_SYMBOLTYPE_NATNUM0 - nNatNumNum); @@ -1716,7 +1716,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString, 1 <= nDBNum && nDBNum <= 9 ) { sBuffSymbol.stripStart('['); - sBuffSymbol.append( aBufStr.copy( --nPos, aDBNum.getLength()+1 )); + sBuffSymbol.appendCopy( aBufStr, --nPos, aDBNum.getLength()+1 ); nPos += aDBNum.getLength()+1; //! SymbolType is negative eSymbolType = sal::static_int_cast< short >( BRACKET_SYMBOLTYPE_DBNUM1 - (nDBNum - 1) ); @@ -1944,7 +1944,7 @@ OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr ) } else { - aTmp.append(rStr.copy( nStartPos, nPos - nStartPos )); + aTmp.appendCopy(rStr, nStartPos, nPos - nStartPos ); nStartPos = nPos + 2; sal_Int32 nDash; nEnd = nStartPos - 1; @@ -1975,13 +1975,13 @@ OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr ) { nPos = nDash; } - aTmp.append(rStr.copy( nStartPos, nPos - nStartPos )); + aTmp.appendCopy(rStr, nStartPos, nPos - nStartPos ); nStartPos = nClose + 1; } } if ( nLen > nStartPos ) { - aTmp.append(rStr.copy( nStartPos, nLen - nStartPos )); + aTmp.appendCopy(rStr, nStartPos, nLen - nStartPos ); } return aTmp.makeStringAndClear(); } |