mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
AK: Deduplicate formatting hexadecimal values
Both calls essentially only differ in one boolean, which dictates whether to print the value in uppercase or lowercase. Move the long function call into a new function and pass in the "uppercase" boolean seperately to avoid having to write everything twice.
This commit is contained in:
parent
0d5098fdc0
commit
fbfa378e74
Notes:
sideshowbarker
2024-07-17 11:49:33 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/fbfa378e74 Pull-request: https://github.com/SerenityOS/serenity/pull/13581
1 changed files with 8 additions and 6 deletions
|
@ -388,17 +388,19 @@ struct PrintfImpl {
|
|||
{
|
||||
return print_octal_number(m_putch, m_bufptr, NextArgument<u32>()(ap), state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
}
|
||||
ALWAYS_INLINE int format_x(ModifierState const& state, ArgumentListRefT ap) const
|
||||
ALWAYS_INLINE int format_unsigned_hex(ModifierState const& state, ArgumentListRefT ap, bool uppercase) const
|
||||
{
|
||||
if (state.long_qualifiers >= 2)
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u64>()(ap), false, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u32>()(ap), false, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u64>()(ap), uppercase, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u32>()(ap), uppercase, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
}
|
||||
ALWAYS_INLINE int format_x(ModifierState const& state, ArgumentListRefT ap) const
|
||||
{
|
||||
return format_unsigned_hex(state, ap, false);
|
||||
}
|
||||
ALWAYS_INLINE int format_X(ModifierState const& state, ArgumentListRefT ap) const
|
||||
{
|
||||
if (state.long_qualifiers >= 2)
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u64>()(ap), true, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return print_hex(m_putch, m_bufptr, NextArgument<u32>()(ap), true, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision);
|
||||
return format_unsigned_hex(state, ap, true);
|
||||
}
|
||||
ALWAYS_INLINE int format_n(ModifierState const&, ArgumentListRefT ap) const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue