Kaydet (Commit) 6f0503c8 authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst bdbc1328
...@@ -84,11 +84,22 @@ protected: ...@@ -84,11 +84,22 @@ protected:
const sal_Char *cBreakIterator, *wordRule, *lineRule; const sal_Char *cBreakIterator, *wordRule, *lineRule;
Boundary result; // for word break iterator Boundary result; // for word break iterator
struct BI_Data { struct BI_Data
UnicodeString aICUText; {
rtl::OUString aICUText;
UText *ut;
icu::BreakIterator *aBreakIterator; icu::BreakIterator *aBreakIterator;
BI_Data() : aICUText(), aBreakIterator(NULL) {} BI_Data()
: ut(NULL)
, aBreakIterator(NULL)
{
}
~BI_Data()
{
utext_close(ut);
}
} character, word, sentence, line, *icuBI; } character, word, sentence, line, *icuBI;
com::sun::star::lang::Locale aLocale; com::sun::star::lang::Locale aLocale;
......
...@@ -95,24 +95,6 @@ class OOoRuleBasedBreakIterator : public RuleBasedBreakIterator { ...@@ -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. // loading ICU breakiterator on demand.
void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const com::sun::star::lang::Locale& rLocale, 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) 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:: ...@@ -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 // UChar != sal_Unicode in MinGW
const UChar *pText = reinterpret_cast<const UChar *>(rText.getStr()); 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;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment