vsnprintf: mark the indirect width and precision cases unlikely

Make the format_decode() code generation easier to look at by getting
the strange and unlikely cases out of line.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2024-12-19 11:42:15 -08:00
parent f372b2256a
commit 2b76e39fca
1 changed files with 4 additions and 4 deletions

View File

@ -2568,7 +2568,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
char flag; char flag;
/* we finished early by reading the field width */ /* we finished early by reading the field width */
if (fmt.state == FORMAT_STATE_WIDTH) { if (unlikely(fmt.state == FORMAT_STATE_WIDTH)) {
if (spec->field_width < 0) { if (spec->field_width < 0) {
spec->field_width = -spec->field_width; spec->field_width = -spec->field_width;
spec->flags |= LEFT; spec->flags |= LEFT;
@ -2578,7 +2578,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
} }
/* we finished early by reading the precision */ /* we finished early by reading the precision */
if (fmt.state == FORMAT_STATE_PRECISION) { if (unlikely(fmt.state == FORMAT_STATE_PRECISION)) {
if (spec->precision < 0) if (spec->precision < 0)
spec->precision = 0; spec->precision = 0;
@ -2611,7 +2611,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
if (isdigit(*fmt.str)) if (isdigit(*fmt.str))
spec->field_width = skip_atoi(&fmt.str); spec->field_width = skip_atoi(&fmt.str);
else if (*fmt.str == '*') { else if (unlikely(*fmt.str == '*')) {
/* it's the next argument */ /* it's the next argument */
fmt.state = FORMAT_STATE_WIDTH; fmt.state = FORMAT_STATE_WIDTH;
fmt.str++; fmt.str++;
@ -2621,7 +2621,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
precision: precision:
/* get the precision */ /* get the precision */
spec->precision = -1; spec->precision = -1;
if (*fmt.str == '.') { if (unlikely(*fmt.str == '.')) {
fmt.str++; fmt.str++;
if (isdigit(*fmt.str)) { if (isdigit(*fmt.str)) {
spec->precision = skip_atoi(&fmt.str); spec->precision = skip_atoi(&fmt.str);