summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-01 16:09:25 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-01 16:27:17 +0100
commitccc47b3db3eae25cc11bb709416c0b61747ca89e (patch)
tree7c4972b568fce2a4767fc320c53f55a5ec9727bb /i18npool
parentfd4fe85329654883a0bf3304ad0aa8ef0bfde844 (diff)
Resolves: fdo#49208 icu string compare is shocking slow
Change-Id: Iee3ab0ebbbb72e88e33dcbe0fcb4df1e4f60c301
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/breakiterator/breakiterator_unicode.cxx25
1 files changed, 22 insertions, 3 deletions
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 08a5e6c7feb6..4005780a27d3 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -34,6 +34,7 @@
#include <unicode/udata.h>
#include <rtl/strbuf.hxx>
#include <rtl/ustring.hxx>
+#include <string.h>
U_CDECL_BEGIN
extern const char OpenOffice_dat[];
@@ -94,6 +95,24 @@ 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)
@@ -199,10 +218,10 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const com::sun::star::
}
}
- // UChar != sal_Unicode in MinGW
- const UChar *pText = reinterpret_cast<const UChar *>(rText.getStr());
- if (newBreak || icuBI->aICUText.compare(pText, rText.getLength()))
+ if (newBreak || !isEqual(icuBI->aICUText, 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);
}