Skip to content

Commit

Permalink
Remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jan 15, 2024
1 parent 5f30d37 commit c98a5a5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,9 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
int num_digits = 0;
auto buffer = memory_buffer();
switch (specs.type) {
default:
FMT_ASSERT(false, "");
FMT_FALLTHROUGH;
case presentation_type::none:
case presentation_type::dec: {
num_digits = count_digits(value);
Expand Down Expand Up @@ -2127,8 +2130,6 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
}
case presentation_type::chr:
return write_char(out, static_cast<Char>(value), specs);
default:
throw_format_error("invalid format specifier");
}

unsigned size = (prefix != 0 ? prefix >> 24 : 0) + to_unsigned(num_digits) +
Expand Down Expand Up @@ -2200,6 +2201,9 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg<T> arg,
auto abs_value = arg.abs_value;
auto prefix = arg.prefix;
switch (specs.type) {
default:
FMT_ASSERT(false, "");
FMT_FALLTHROUGH;
case presentation_type::none:
case presentation_type::dec: {
auto num_digits = count_digits(abs_value);
Expand Down Expand Up @@ -2243,8 +2247,6 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg<T> arg,
}
case presentation_type::chr:
return write_char(out, static_cast<Char>(abs_value), specs);
default:
throw_format_error("invalid format specifier");
}
return out;
}
Expand Down Expand Up @@ -2448,6 +2450,9 @@ FMT_CONSTEXPR auto parse_float_type_spec(const format_specs<Char>& specs)
result.showpoint = specs.alt;
result.locale = specs.localized;
switch (specs.type) {
default:
FMT_ASSERT(false, "");
FMT_FALLTHROUGH;
case presentation_type::none:
result.format = float_format::general;
break;
Expand Down Expand Up @@ -2477,9 +2482,6 @@ FMT_CONSTEXPR auto parse_float_type_spec(const format_specs<Char>& specs)
case presentation_type::hexfloat_lower:
result.format = float_format::hex;
break;
default:
throw_format_error("invalid format specifier");
break;
}
return result;
}
Expand Down

0 comments on commit c98a5a5

Please sign in to comment.