summaryrefslogtreecommitdiffstats
path: root/i18npool/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-02 09:18:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-02 11:20:32 +0100
commit6f0503c82c0a019678458ded9e339a71f96d837d (patch)
tree251162c3778839c6441978d241ef853b30bd3cae /i18npool/source
parentDocxExport::WriteSettings: add missing cast (diff)
downloadcore-6f0503c82c0a019678458ded9e339a71f96d837d.tar.gz
core-6f0503c82c0a019678458ded9e339a71f96d837d.zip
Related: fdo#49208 use UText adaptor to underlying rtl::OUString
Don't convert to icu UnicodeString, retain text as shallow-copy of original via rtl::OUString and use UText adaptor. Allows use of equals to do super fast compare that new string is the same as the old string Change-Id: Ie9a3dc981b22a6866f3712c786331a1d6fcf153a
Diffstat (limited to 'i18npool/source')
-rw-r--r--i18npool/source/breakiterator/breakiterator_unicode.cxx34
1 files changed, 13 insertions, 21 deletions
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 4005780a27d3..34e6918f5182 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -95,24 +95,6 @@ class OOoRuleBasedBreakIterator : public RuleBasedBreakIterator {
};
-namespace
-{
- bool isEqual(const UnicodeString &rOne, const rtl::OUString &rOther)
- {
- sal_Int32 nLength = rOne.length();
- if (nLength != rOther.getLength())
- return false;
-
- //fdo#49208 operator== is implemented by compareTo etc in icu which is
- //horrifically slow when all you want to know is that they're the same
- //or not
- const UChar *pOne = rOne.getBuffer();
- // UChar != sal_Unicode in MinGW
- const UChar *pOther = reinterpret_cast<const UChar *>(rOther.getStr());
- return memcmp(pOne, pOther, nLength * sizeof(UChar)) == 0;
- }
-}
-
// loading ICU breakiterator on demand.
void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const com::sun::star::lang::Locale& rLocale,
sal_Int16 rBreakType, sal_Int16 rWordType, const sal_Char *rule, const OUString& rText) throw(uno::RuntimeException)
@@ -218,12 +200,22 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const com::sun::star::
}
}
- if (newBreak || !isEqual(icuBI->aICUText, rText))
+ if (newBreak || !icuBI->aICUText.equals(rText))
{
// UChar != sal_Unicode in MinGW
const UChar *pText = reinterpret_cast<const UChar *>(rText.getStr());
- icuBI->aICUText=UnicodeString(pText, rText.getLength());
- icuBI->aBreakIterator->setText(icuBI->aICUText);
+
+ icuBI->ut = utext_openUChars(icuBI->ut, pText, rText.getLength(), &status);
+
+ if (!U_SUCCESS(status))
+ throw ERROR;
+
+ icuBI->aBreakIterator->setText(icuBI->ut, status);
+
+ if (!U_SUCCESS(status))
+ throw ERROR;
+
+ icuBI->aICUText = rText;
}
}