mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
AK: Merge print_i64 into print_signed_number
Those functions only differ by the input type of `number`. No other wrapper does this, as they rely on adjusting the type of the argument on the caller side instead. Avoid specializing too much by just doing the same for signed numbers.
This commit is contained in:
parent
399202f1d3
commit
0d5098fdc0
Notes:
sideshowbarker
2024-07-17 11:49:36 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/0d5098fdc0 Pull-request: https://github.com/SerenityOS/serenity/pull/13581
1 changed files with 3 additions and 8 deletions
|
@ -210,12 +210,6 @@ ALWAYS_INLINE int print_double(PutChFunc putch, CharType*& bufptr, double number
|
|||
return length;
|
||||
}
|
||||
|
||||
template<typename PutChFunc, typename CharType>
|
||||
ALWAYS_INLINE int print_i64(PutChFunc putch, CharType*& bufptr, i64 number, bool always_sign, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
||||
{
|
||||
return print_decimal(putch, bufptr, (number < 0) ? 0 - number : number, number < 0, always_sign, left_pad, zero_pad, field_width, has_precision, precision);
|
||||
}
|
||||
|
||||
template<typename PutChFunc, typename CharType>
|
||||
ALWAYS_INLINE int print_octal_number(PutChFunc putch, CharType*& bufptr, u64 number, bool alternate_form, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
||||
{
|
||||
|
@ -307,8 +301,9 @@ ALWAYS_INLINE int print_string(PutChFunc putch, CharType*& bufptr, T str, size_t
|
|||
}
|
||||
|
||||
template<typename PutChFunc, typename CharType>
|
||||
ALWAYS_INLINE int print_signed_number(PutChFunc putch, CharType*& bufptr, int number, bool always_sign, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
||||
ALWAYS_INLINE int print_signed_number(PutChFunc putch, CharType*& bufptr, i64 number, bool always_sign, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision)
|
||||
{
|
||||
// FIXME: `0 - number` overflows if we are trying to negate the smallest possible value.
|
||||
return print_decimal(putch, bufptr, (number < 0) ? 0 - number : number, number < 0, always_sign, left_pad, zero_pad, field_width, has_precision, precision);
|
||||
}
|
||||
|
||||
|
@ -359,7 +354,7 @@ struct PrintfImpl {
|
|||
ALWAYS_INLINE int format_d(ModifierState const& state, ArgumentListRefT ap) const
|
||||
{
|
||||
if (state.long_qualifiers >= 2)
|
||||
return print_i64(m_putch, m_bufptr, NextArgument<i64>()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return print_signed_number(m_putch, m_bufptr, NextArgument<i64>()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
|
||||
return print_signed_number(m_putch, m_bufptr, NextArgument<int>()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue