Skip to contentSkip to conversation

seq_file: delete small-value optimization

PATCH In review Alexey Dobriyan 2 participants 2 messages May 16, 2017 – May 17, 2017 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 seq_file: delete small-value optimization

num_to_str() optimizes printing small integers [0..9], so the same check higher in callchain is unnecessary.

---

 fs/seq_file.c |   10 ----------
 1 file changed, 10 deletions(-)
fs/seq_file.c +0 -10
@@ -694,11 +694,6 @@ void seq_put_decimal_ull(struct seq_file *m, const char *delimiter,
 	if (m->count + 1 >= m->size)
 		goto overflow;
 
-	if (num < 10) {
-		m->buf[m->count++] = num + '0';
-		return;
-	}
-
 	len = num_to_str(m->buf + m->count, m->size - m->count, num);
 	if (!len)
 		goto overflow;
@@ -733,11 +728,6 @@ void seq_put_decimal_ll(struct seq_file *m, const char *delimiter, long long num
 		num = -num;
 	}
 
-	if (num < 10) {
-		m->buf[m->count++] = num + '0';
-		return;
-	}
-
 	len = num_to_str(m->buf + m->count, m->size - m->count, num);
 	if (!len)
 		goto overflow;
#1 lore raw
Quoted 2 lines · Alexey Dobriyan

num_to_str() optimizes printing small integers [0..9], so the same check higher in callchain is unnecessary.

Doesn't the optimization exists for the frequent use of 0 in seq output?

These seq_put_decimal calls are now slightly more expensive.