From 6671fa81db0ecea4ada005bb79f55f08fb440ad4 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 27 Sep 2011 20:21:15 +0200 Subject: Removed uses of rtl::O[U]String[Buffer]::operator sal_{char|Unicode} const *(). --- package/source/manifest/Base64Codec.cxx | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'package/source/manifest') diff --git a/package/source/manifest/Base64Codec.cxx b/package/source/manifest/Base64Codec.cxx index b4f5b6d32ffd..189bdb35d2b3 100644 --- a/package/source/manifest/Base64Codec.cxx +++ b/package/source/manifest/Base64Codec.cxx @@ -85,7 +85,6 @@ void ThreeByteToFourByte (const sal_uInt8* pBuffer, const sal_Int32 nStart, cons nLen = 3; if (nLen == 0) { - sBuffer.setLength(0); return; } @@ -112,23 +111,24 @@ void ThreeByteToFourByte (const sal_uInt8* pBuffer, const sal_Int32 nStart, cons break; } - sBuffer.appendAscii("===="); + sal_Unicode buf[] = { '=', '=', '=', '=' }; sal_uInt8 nIndex = static_cast< sal_uInt8 >((nBinaer & 0xFC0000) >> 18); - sBuffer.setCharAt(0, aBase64EncodeTable [nIndex]); + buf[0] = aBase64EncodeTable [nIndex]; nIndex = static_cast< sal_uInt8 >((nBinaer & 0x3F000) >> 12); - sBuffer.setCharAt(1, aBase64EncodeTable [nIndex]); - if (nLen == 1) - return; - - nIndex = static_cast< sal_uInt8 >((nBinaer & 0xFC0) >> 6); - sBuffer.setCharAt(2, aBase64EncodeTable [nIndex]); - if (nLen == 2) - return; - - nIndex = static_cast< sal_uInt8 >(nBinaer & 0x3F); - sBuffer.setCharAt(3, aBase64EncodeTable [nIndex]); + buf[1] = aBase64EncodeTable [nIndex]; + if (nLen > 1) + { + nIndex = static_cast< sal_uInt8 >((nBinaer & 0xFC0) >> 6); + buf[2] = aBase64EncodeTable [nIndex]; + if (nLen > 2) + { + nIndex = static_cast< sal_uInt8 >(nBinaer & 0x3F); + buf[3] = aBase64EncodeTable [nIndex]; + } + } + sBuffer.append(buf, SAL_N_ELEMENTS(buf)); } void Base64Codec::encodeBase64(rtl::OUStringBuffer& aStrBuffer, const uno::Sequence < sal_Int8 >& aPass) @@ -138,9 +138,7 @@ void Base64Codec::encodeBase64(rtl::OUStringBuffer& aStrBuffer, const uno::Seque const sal_uInt8* pBuffer = reinterpret_cast< const sal_uInt8* >( aPass.getConstArray() ); while (i < nBufferLength) { - rtl::OUStringBuffer sBuffer; - ThreeByteToFourByte (pBuffer, i, nBufferLength, sBuffer); - aStrBuffer.append(sBuffer); + ThreeByteToFourByte (pBuffer, i, nBufferLength, aStrBuffer); i += 3; } } -- cgit