mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-7032 Instead of create UnicodeSet instances for validating named parameter syntax, use UCharacter.isUnicodeIdentifierXXX for the same operation. This change drastically improve the initialization performance of MessageFormat without paying any runtime penalties.
X-SVN-Rev: 26506
This commit is contained in:
parent
e24f8b9b03
commit
5414398199
1 changed files with 5 additions and 7 deletions
|
@ -32,6 +32,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
|
@ -2128,10 +2129,10 @@ public class MessageFormat extends UFormat implements BaseFormat<Object,StringBu
|
|||
return false;
|
||||
}
|
||||
for (int i = 0; i < argument.length(); ++i ) {
|
||||
if (i == 0 && !IDStartChars.contains(argument.charAt(i)) ||
|
||||
i > 0 && !IDContChars.contains(argument.charAt(i))){
|
||||
return false;
|
||||
}
|
||||
if (i == 0 && !UCharacter.isUnicodeIdentifierStart(argument.charAt(i)) ||
|
||||
i > 0 && !UCharacter.isUnicodeIdentifierPart(argument.charAt(i))){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2145,9 +2146,6 @@ public class MessageFormat extends UFormat implements BaseFormat<Object,StringBu
|
|||
private static final int STATE_IN_QUOTE = 2;
|
||||
private static final int STATE_MSG_ELEMENT = 3;
|
||||
|
||||
private static UnicodeSet IDStartChars = new UnicodeSet("[:ID_Start:]");
|
||||
private static UnicodeSet IDContChars = new UnicodeSet("[:ID_Continue:]");
|
||||
|
||||
/**
|
||||
* Convert an 'apostrophe-friendly' pattern into a standard
|
||||
* pattern. Standard patterns treat all apostrophes as
|
||||
|
|
Loading…
Add table
Reference in a new issue