optimize canonicalOrderHelper() for generic case
if there is no need to swap codepoints A and B, then we proceeding with advance to the next codepoint B that becomes A, and some next codepoint C becomes B; in such case we can easily skip the re-calculations for A by using previously calculated results for B Change-Id: I5c63589c274acaddf0f6a4cb1e0608d352a0c1b3 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
73423db31d
commit
f4d02ecdbf
@ -1526,10 +1526,14 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
|||||||
{
|
{
|
||||||
QString &s = *str;
|
QString &s = *str;
|
||||||
const int l = s.length()-1;
|
const int l = s.length()-1;
|
||||||
|
|
||||||
|
uint u1, u2;
|
||||||
|
ushort c1, c2;
|
||||||
|
|
||||||
int pos = from;
|
int pos = from;
|
||||||
while (pos < l) {
|
while (pos < l) {
|
||||||
int p2 = pos+1;
|
int p2 = pos+1;
|
||||||
uint u1 = s.at(pos).unicode();
|
u1 = s.at(pos).unicode();
|
||||||
if (QChar(u1).isHighSurrogate()) {
|
if (QChar(u1).isHighSurrogate()) {
|
||||||
ushort low = s.at(p2).unicode();
|
ushort low = s.at(p2).unicode();
|
||||||
if (QChar(low).isLowSurrogate()) {
|
if (QChar(low).isLowSurrogate()) {
|
||||||
@ -1539,7 +1543,10 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
|||||||
++p2;
|
++p2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint u2 = s.at(p2).unicode();
|
c1 = 0;
|
||||||
|
|
||||||
|
advance:
|
||||||
|
u2 = s.at(p2).unicode();
|
||||||
if (QChar(u2).isHighSurrogate() && p2 < l) {
|
if (QChar(u2).isHighSurrogate() && p2 < l) {
|
||||||
ushort low = s.at(p2+1).unicode();
|
ushort low = s.at(p2+1).unicode();
|
||||||
if (QChar(low).isLowSurrogate()) {
|
if (QChar(low).isLowSurrogate()) {
|
||||||
@ -1548,7 +1555,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort c2 = 0;
|
c2 = 0;
|
||||||
{
|
{
|
||||||
const QUnicodeTables::Properties *p = qGetProp(u2);
|
const QUnicodeTables::Properties *p = qGetProp(u2);
|
||||||
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
|
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
|
||||||
@ -1559,8 +1566,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort c1 = 0;
|
if (c1 == 0) {
|
||||||
{
|
|
||||||
const QUnicodeTables::Properties *p = qGetProp(u1);
|
const QUnicodeTables::Properties *p = qGetProp(u1);
|
||||||
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
|
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
|
||||||
c1 = p->combiningClass;
|
c1 = p->combiningClass;
|
||||||
@ -1590,6 +1596,16 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
|
|||||||
++pos;
|
++pos;
|
||||||
if (QChar::requiresSurrogates(u1))
|
if (QChar::requiresSurrogates(u1))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
|
u1 = u2;
|
||||||
|
c1 = c2; // != 0
|
||||||
|
p2 = pos + 1;
|
||||||
|
if (QChar::requiresSurrogates(u1))
|
||||||
|
++p2;
|
||||||
|
if (p2 > l)
|
||||||
|
break;
|
||||||
|
|
||||||
|
goto advance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user