ICU-11057 General cleanup for RBNF.

The TestFmwk change is a general 8-10% performance improvement for running the tests without changing the end results of the logging output.

X-SVN-Rev: 36154
This commit is contained in:
George Rhoten 2014-08-13 06:51:09 +00:00
parent 5af6a3d39f
commit 40682975b0
2 changed files with 22 additions and 21 deletions

View file

@ -206,12 +206,12 @@ final class NFRuleSet {
NFRule rule = tempRules.get(i);
switch ((int)rule.getBaseValue()) {
// if the rule's base value is 0, fill in a default
// base value (this will be 1 plus the preceding
// rule's base value for regular rule sets, and the
// same as the preceding rule's base value in fraction
// rule sets)
case 0:
// if the rule's base value is 0, fill in a default
// base value (this will be 1 plus the preceding
// rule's base value for regular rule sets, and the
// same as the preceding rule's base value in fraction
// rule sets)
rule.setBaseValue(defaultBaseValue);
if (!isFractionRuleSet) {
++defaultBaseValue;
@ -219,38 +219,38 @@ final class NFRuleSet {
++i;
break;
// if it's the negative-number rule, copy it into its own
// data member and delete it from the list
case NFRule.NEGATIVE_NUMBER_RULE:
// if it's the negative-number rule, copy it into its own
// data member and delete it from the list
negativeNumberRule = rule;
tempRules.remove(i);
break;
// if it's the improper fraction rule, copy it into the
// correct element of fractionRules
case NFRule.IMPROPER_FRACTION_RULE:
// if it's the improper fraction rule, copy it into the
// correct element of fractionRules
fractionRules[0] = rule;
tempRules.remove(i);
break;
// if it's the proper fraction rule, copy it into the
// correct element of fractionRules
case NFRule.PROPER_FRACTION_RULE:
// if it's the proper fraction rule, copy it into the
// correct element of fractionRules
fractionRules[1] = rule;
tempRules.remove(i);
break;
// if it's the master rule, copy it into the
// correct element of fractionRules
case NFRule.MASTER_RULE:
// if it's the master rule, copy it into the
// correct element of fractionRules
fractionRules[2] = rule;
tempRules.remove(i);
break;
// if it's a regular rule that already knows its base value,
// check to make sure the rules are in order, and update
// the default base value for the next rule
default:
// if it's a regular rule that already knows its base value,
// check to make sure the rules are in order, and update
// the default base value for the next rule
if (rule.getBaseValue() < defaultBaseValue) {
throw new IllegalArgumentException("Rules are not in order, base: " +
rule.getBaseValue() + " < " + defaultBaseValue);
@ -395,7 +395,7 @@ final class NFRuleSet {
* @return true if the rule set can be used for parsing.
*/
public boolean isParseable() {
return (isParseable);
return isParseable;
}
//-----------------------------------------------------------------------
@ -538,10 +538,11 @@ final class NFRuleSet {
if (hi > 0) {
while (lo < hi) {
int mid = (lo + hi) >>> 1;
if (rules[mid].getBaseValue() == number) {
long ruleBaseValue = rules[mid].getBaseValue();
if (ruleBaseValue == number) {
return rules[mid];
}
else if (rules[mid].getBaseValue() > number) {
else if (ruleBaseValue > number) {
hi = mid;
}
else {

View file

@ -1547,8 +1547,6 @@ public class TestFmwk extends AbstractTestLog {
private void msg(String message, int level, boolean incCount,
boolean newln) {
String testLocation = sourceLocation();
message = testLocation + message;
int oldLevel = level;
if (level == WARN && (!warnings && !nodata)){
level = ERR;
@ -1571,6 +1569,8 @@ public class TestFmwk extends AbstractTestLog {
log.print(MSGNAMES[oldLevel]);
}
String testLocation = sourceLocation();
message = testLocation + message;
log.print(message);
if (newln) {
log.println();