ICU-20709 Use SIGNUM_COUNT for number of entries in Signum enum.

This commit is contained in:
Shane Carr 2019-10-31 15:13:44 -07:00 committed by Shane F. Carr
parent 00946cef43
commit cfb298f035
5 changed files with 14 additions and 5 deletions

View file

@ -322,9 +322,9 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory {
const Modifier *mods[4 * StandardPlural::COUNT] = {};
inline static int32_t getModIndex(Signum signum, StandardPlural::Form plural) {
U_ASSERT(signum >= 0 && signum <= 3);
U_ASSERT(signum >= 0 && signum < SIGNUM_COUNT);
U_ASSERT(plural >= 0 && plural < StandardPlural::COUNT);
return static_cast<int32_t>(plural) * 4 + signum;
return static_cast<int32_t>(plural) * SIGNUM_COUNT + signum;
}
};

View file

@ -1072,6 +1072,8 @@ PatternSignType PatternStringUtils::resolveSignDisplay(UNumberSignDisplay signDi
case SIGNUM_POS_ZERO:
case SIGNUM_POS:
return PATTERN_SIGN_TYPE_POS;
default:
break;
}
break;
@ -1084,6 +1086,8 @@ PatternSignType PatternStringUtils::resolveSignDisplay(UNumberSignDisplay signDi
case SIGNUM_POS_ZERO:
case SIGNUM_POS:
return PATTERN_SIGN_TYPE_POS_SIGN;
default:
break;
}
break;
@ -1097,6 +1101,8 @@ PatternSignType PatternStringUtils::resolveSignDisplay(UNumberSignDisplay signDi
return PATTERN_SIGN_TYPE_POS;
case SIGNUM_POS:
return PATTERN_SIGN_TYPE_POS_SIGN;
default:
break;
}
break;

View file

@ -95,7 +95,8 @@ enum Signum {
SIGNUM_NEG = 0,
SIGNUM_NEG_ZERO = 1,
SIGNUM_POS_ZERO = 2,
SIGNUM_POS = 3
SIGNUM_POS = 3,
SIGNUM_COUNT = 4,
};

View file

@ -86,6 +86,6 @@ public class AdoptingModifierStore implements ModifierStore {
private static int getModIndex(Signum signum, StandardPlural plural) {
assert signum != null;
assert plural != null;
return plural.ordinal() * 4 + signum.ordinal();
return plural.ordinal() * Signum.COUNT + signum.ordinal();
}
}

View file

@ -21,7 +21,9 @@ public interface Modifier {
NEG,
NEG_ZERO,
POS_ZERO,
POS
POS;
static final int COUNT = Signum.values().length;
};
/**