summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-24 00:06:37 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-27 22:59:27 -0600
commit087dd70dac798ffe0448e2183614182442ebcc60 (patch)
tree76eda7c826ca547b1cf93c566f15b27164a617fd /svl
parenta49ced0b692d3af81a67da7d6d46d467dcea1f09 (diff)
convert first and replace after
the original code was converting one character at the time from whatever codepage of the input stream to unicode just to be able to substitute the 'euro' character that apparently is somehow not converted properly (why this is hacked here rather than fixed in the code page converted is another story) the change consist in translating the 'native' euro character in whatever the converter think it should be, then converting the whole string at once to Unicode and finally replace the 'bad' euro character representation with the the 'good' one. This turn the allocation pattern for O(N) to O(1) where N is the length of the string. Change-Id: Ie7ffeb813346953f539cf6dc34b43f890d8b970f
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zformat.cxx18
1 files changed, 4 insertions, 14 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index fe50e90ff98d..3b9f457de3a9 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1898,25 +1898,15 @@ rtl::OUString SvNumberformat::LoadString( SvStream& rStream )
CharSet eStream = rStream.GetStreamCharSet();
rtl::OString aStr = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rStream);
sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream );
- if (aStr.indexOf(cStream) == -1)
+ if (aStr.indexOf(cStream) < 0)
{
// simple conversion to unicode
return rtl::OStringToOUString(aStr, eStream);
}
-
+ sal_Unicode cSource = OUString(&cStream, 1, eStream).toChar();
sal_Unicode cTarget = NfCurrencyEntry::GetEuroSymbol();
- rtl::OUStringBuffer aBuf(aStr.getLength());
- for (sal_Int32 i = 0; i < aStr.getLength(); ++i)
- {
- if (aStr[i] == cStream)
- {
- aBuf.append(cTarget);
- }
- else
- {
- aBuf.append(rtl::OUString(aStr.getStr()+i, 1, eStream).toChar());
- }
- }
+ rtl::OUStringBuffer aBuf(rtl::OStringToOUString(aStr, eStream));
+ aBuf.replace(cSource, cTarget);
return aBuf.makeStringAndClear();
}