Commit 3777f419 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Remove unnecessary COUNT from enum

Bug: v8:9523
Change-Id: Ib9d6772d2025b0452ddcd777cc777276f9038e97
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710960Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62836}
parent 27b68b8e
......@@ -25,7 +25,6 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
}
inline void JSV8BreakIterator::set_type(Type type) {
DCHECK_GT(JSV8BreakIterator::Type::COUNT, type);
set_raw_type(static_cast<int>(type));
}
......
......@@ -146,9 +146,8 @@ Handle<String> JSV8BreakIterator::TypeAsString() const {
return GetReadOnlyRoots().sentence_string_handle();
case Type::LINE:
return GetReadOnlyRoots().line_string_handle();
case Type::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
Handle<Object> JSV8BreakIterator::Current(
......
......@@ -51,7 +51,7 @@ class JSV8BreakIterator : public JSObject {
static String BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator);
enum class Type { CHARACTER, WORD, SENTENCE, LINE, COUNT };
enum class Type { CHARACTER, WORD, SENTENCE, LINE };
inline void set_type(Type type);
inline Type type() const;
......
......@@ -27,7 +27,7 @@ ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>,
SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset)
inline void JSListFormat::set_style(Style style) {
DCHECK_GT(Style::COUNT, style);
DCHECK_GE(StyleBits::kMax, style);
int hints = flags();
hints = StyleBits::update(hints, style);
set_flags(hints);
......@@ -38,7 +38,7 @@ inline JSListFormat::Style JSListFormat::style() const {
}
inline void JSListFormat::set_type(Type type) {
DCHECK_GT(Type::COUNT, type);
DCHECK_GE(TypeBits::kMax, type);
int hints = flags();
hints = TypeBits::update(hints, type);
set_flags(hints);
......
......@@ -50,8 +50,6 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kStandardShort;
case JSListFormat::Style::NARROW:
return kStandardNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
}
case JSListFormat::Type::DISJUNCTION:
switch (style) {
......@@ -61,8 +59,6 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kOrShort;
case JSListFormat::Style::NARROW:
return kOrNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
}
case JSListFormat::Type::UNIT:
switch (style) {
......@@ -72,12 +68,9 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kUnitShort;
case JSListFormat::Style::NARROW:
return kUnitNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
}
case JSListFormat::Type::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
} // namespace
......@@ -238,9 +231,8 @@ Handle<String> JSListFormat::StyleAsString() const {
return GetReadOnlyRoots().short_string_handle();
case Style::NARROW:
return GetReadOnlyRoots().narrow_string_handle();
case Style::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
Handle<String> JSListFormat::TypeAsString() const {
......@@ -251,9 +243,8 @@ Handle<String> JSListFormat::TypeAsString() const {
return GetReadOnlyRoots().disjunction_string_handle();
case Type::UNIT:
return GetReadOnlyRoots().unit_string_handle();
case Type::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
namespace {
......
......@@ -64,10 +64,9 @@ class JSListFormat : public JSObject {
//
// ecma402/#sec-properties-of-intl-listformat-instances
enum class Style {
LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible.
NARROW, // Use the shortest possible form.
COUNT
LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible.
NARROW // Use the shortest possible form.
};
inline void set_style(Style style);
inline Style style() const;
......@@ -78,8 +77,7 @@ class JSListFormat : public JSObject {
enum class Type {
CONJUNCTION, // for "and"-based lists (e.g., "A, B and C")
DISJUNCTION, // for "or"-based lists (e.g., "A, B or C"),
UNIT, // for lists of values with units (e.g., "5 pounds, 12 ounces").
COUNT
UNIT // for lists of values with units (e.g., "5 pounds, 12 ounces").
};
inline void set_type(Type type);
inline Type type() const;
......
......@@ -30,7 +30,7 @@ ACCESSORS(JSPluralRules, icu_number_formatter,
kIcuNumberFormatterOffset)
inline void JSPluralRules::set_type(Type type) {
DCHECK_LT(type, Type::COUNT);
DCHECK_LE(type, TypeBits::kMax);
int hints = flags();
hints = TypeBits::update(hints, type);
set_flags(hints);
......
......@@ -55,9 +55,8 @@ Handle<String> JSPluralRules::TypeAsString() const {
return GetReadOnlyRoots().cardinal_string_handle();
case Type::ORDINAL:
return GetReadOnlyRoots().ordinal_string_handle();
case Type::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
// static
......
......@@ -47,12 +47,7 @@ class JSPluralRules : public JSObject {
// [[Type]] is one of the values "cardinal" or "ordinal",
// identifying the plural rules used.
enum class Type {
CARDINAL,
ORDINAL,
COUNT
};
enum class Type { CARDINAL, ORDINAL };
inline void set_type(Type type);
inline Type type() const;
......
......@@ -27,7 +27,7 @@ ACCESSORS(JSRelativeTimeFormat, icu_formatter,
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
inline void JSRelativeTimeFormat::set_style(Style style) {
DCHECK_GT(Style::COUNT, style);
DCHECK_GE(StyleBits::kMax, style);
int hints = flags();
hints = StyleBits::update(hints, style);
set_flags(hints);
......@@ -38,7 +38,7 @@ inline JSRelativeTimeFormat::Style JSRelativeTimeFormat::style() const {
}
inline void JSRelativeTimeFormat::set_numeric(Numeric numeric) {
DCHECK_GT(Numeric::COUNT, numeric);
DCHECK_GE(NumericBits::kMax, numeric);
int hints = flags();
hints = NumericBits::update(hints, numeric);
set_flags(hints);
......
......@@ -34,9 +34,8 @@ UDateRelativeDateTimeFormatterStyle getIcuStyle(
return UDAT_STYLE_SHORT;
case JSRelativeTimeFormat::Style::NARROW:
return UDAT_STYLE_NARROW;
case JSRelativeTimeFormat::Style::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
} // namespace
......@@ -220,9 +219,8 @@ Handle<String> JSRelativeTimeFormat::StyleAsString() const {
return GetReadOnlyRoots().short_string_handle();
case Style::NARROW:
return GetReadOnlyRoots().narrow_string_handle();
case Style::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
Handle<String> JSRelativeTimeFormat::NumericAsString() const {
......@@ -231,9 +229,8 @@ Handle<String> JSRelativeTimeFormat::NumericAsString() const {
return GetReadOnlyRoots().always_string_handle();
case Numeric::AUTO:
return GetReadOnlyRoots().auto_string_handle();
case Numeric::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
namespace {
......
......@@ -66,10 +66,9 @@ class JSRelativeTimeFormat : public JSObject {
// ecma402/#sec-properties-of-intl-relativetimeformat-instances
enum class Style {
LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible.
NARROW, // Use the shortest possible form.
COUNT
LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible.
NARROW // Use the shortest possible form.
};
inline void set_style(Style style);
inline Style style() const;
......@@ -81,9 +80,8 @@ class JSRelativeTimeFormat : public JSObject {
// ecma402/#sec-properties-of-intl-relativetimeformat-instances
enum class Numeric {
ALWAYS, // numerical descriptions are always used ("1 day ago")
AUTO, // numerical descriptions are used only when no more specific
AUTO // numerical descriptions are used only when no more specific
// version is available ("yesterday")
COUNT
};
inline void set_numeric(Numeric numeric);
inline Numeric numeric() const;
......
......@@ -35,7 +35,7 @@ CAST_ACCESSOR(JSSegmentIterator)
inline void JSSegmentIterator::set_granularity(
JSSegmenter::Granularity granularity) {
DCHECK_GT(JSSegmenter::Granularity::COUNT, granularity);
DCHECK_GE(GranularityBits::kMax, granularity);
int hints = flags();
hints = GranularityBits::update(hints, granularity);
set_flags(hints);
......
......@@ -37,9 +37,8 @@ Handle<String> JSSegmentIterator::GranularityAsString() const {
return GetReadOnlyRoots().word_string_handle();
case JSSegmenter::Granularity::SENTENCE:
return GetReadOnlyRoots().sentence_string_handle();
case JSSegmenter::Granularity::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create(
......@@ -122,9 +121,8 @@ Handle<Object> JSSegmentIterator::BreakType() const {
return GetReadOnlyRoots().sep_string_handle();
}
return GetReadOnlyRoots().undefined_value_handle();
case JSSegmenter::Granularity::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
// ecma402 #sec-segment-iterator-prototype-index
......
......@@ -27,7 +27,7 @@ ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)
inline void JSSegmenter::set_granularity(Granularity granularity) {
DCHECK_GT(Granularity::COUNT, granularity);
DCHECK_GE(GranularityBits::kMax, granularity);
int hints = flags();
hints = GranularityBits::update(hints, granularity);
set_flags(hints);
......
......@@ -99,8 +99,6 @@ MaybeHandle<JSSegmenter> JSSegmenter::New(Isolate* isolate, Handle<Map> map,
icu_break_iterator.reset(
icu::BreakIterator::createSentenceInstance(icu_locale, status));
break;
case Granularity::COUNT:
UNREACHABLE();
}
CHECK(U_SUCCESS(status));
......@@ -161,9 +159,8 @@ Handle<String> JSSegmenter::GranularityAsString() const {
return GetReadOnlyRoots().word_string_handle();
case Granularity::SENTENCE:
return GetReadOnlyRoots().sentence_string_handle();
case Granularity::COUNT:
UNREACHABLE();
}
UNREACHABLE();
}
const std::set<std::string>& JSSegmenter::GetAvailableLocales() {
......
......@@ -56,8 +56,7 @@ class JSSegmenter : public JSObject {
enum class Granularity {
GRAPHEME, // for character-breaks
WORD, // for word-breaks
SENTENCE, // for sentence-breaks
COUNT
SENTENCE // for sentence-breaks
};
inline void set_granularity(Granularity granularity);
inline Granularity granularity() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment