mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 15:05:53 +00:00
ICU-10291 Optimize IDNA toASCII loop
This commit is contained in:
parent
ee71b22847
commit
2232a2b81e
2 changed files with 6 additions and 8 deletions
|
@ -57,18 +57,16 @@ toASCIILower(UChar ch){
|
|||
|
||||
inline static UBool
|
||||
startsWithPrefix(const UChar* src , int32_t srcLength){
|
||||
UBool startsWithPrefix = TRUE;
|
||||
|
||||
if(srcLength < ACE_PREFIX_LENGTH){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for(int8_t i=0; i< ACE_PREFIX_LENGTH; i++){
|
||||
if(toASCIILower(src[i]) != ACE_PREFIX[i]){
|
||||
startsWithPrefix = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return startsWithPrefix;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -441,6 +439,7 @@ _internal_toUnicode(const UChar* src, int32_t srcLength,
|
|||
for(int32_t j=0; j<srcLength; j++){
|
||||
if(src[j]> 0x7f){
|
||||
srcIsASCII = FALSE;
|
||||
break;
|
||||
}/*else if(isLDHChar(src[j])==FALSE){
|
||||
// here we do not assemble surrogates
|
||||
// since we know that LDH code points
|
||||
|
|
|
@ -35,17 +35,15 @@ public final class IDNA2003 {
|
|||
private static final StringPrep namePrep = StringPrep.getInstance(StringPrep.RFC3491_NAMEPREP);
|
||||
|
||||
private static boolean startsWithPrefix(StringBuffer src){
|
||||
boolean startsWithPrefix = true;
|
||||
|
||||
if(src.length() < ACE_PREFIX.length){
|
||||
return false;
|
||||
}
|
||||
for(int i=0; i<ACE_PREFIX.length;i++){
|
||||
if(toASCIILower(src.charAt(i)) != ACE_PREFIX[i]){
|
||||
startsWithPrefix = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return startsWithPrefix;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static char toASCIILower(char ch){
|
||||
|
@ -168,6 +166,7 @@ public final class IDNA2003 {
|
|||
while((ch = src.next())!= UCharacterIterator.DONE){
|
||||
if(ch> 0x7f){
|
||||
srcIsASCII = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int failPos = -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue