Skip to content

Commit 2b76e39

Browse files
committed
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 <[email protected]>
1 parent f372b22 commit 2b76e39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/vsprintf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
25682568
char flag;
25692569

25702570
/* we finished early by reading the field width */
2571-
if (fmt.state == FORMAT_STATE_WIDTH) {
2571+
if (unlikely(fmt.state == FORMAT_STATE_WIDTH)) {
25722572
if (spec->field_width < 0) {
25732573
spec->field_width = -spec->field_width;
25742574
spec->flags |= LEFT;
@@ -2578,7 +2578,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
25782578
}
25792579

25802580
/* we finished early by reading the precision */
2581-
if (fmt.state == FORMAT_STATE_PRECISION) {
2581+
if (unlikely(fmt.state == FORMAT_STATE_PRECISION)) {
25822582
if (spec->precision < 0)
25832583
spec->precision = 0;
25842584

@@ -2611,7 +2611,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
26112611

26122612
if (isdigit(*fmt.str))
26132613
spec->field_width = skip_atoi(&fmt.str);
2614-
else if (*fmt.str == '*') {
2614+
else if (unlikely(*fmt.str == '*')) {
26152615
/* it's the next argument */
26162616
fmt.state = FORMAT_STATE_WIDTH;
26172617
fmt.str++;
@@ -2621,7 +2621,7 @@ struct fmt format_decode(struct fmt fmt, struct printf_spec *spec)
26212621
precision:
26222622
/* get the precision */
26232623
spec->precision = -1;
2624-
if (*fmt.str == '.') {
2624+
if (unlikely(*fmt.str == '.')) {
26252625
fmt.str++;
26262626
if (isdigit(*fmt.str)) {
26272627
spec->precision = skip_atoi(&fmt.str);

0 commit comments

Comments
 (0)