lkml.org 
[lkml]   [2012]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
Subjectseq_put_decimal_* optimization
If we want to squeeze out the last drop of slack from the /proc text
generation, shouldn't we then avoid code like

+ seq_put_decimal_ull(m, ' ', 0);

which is worse than what was there before? I realize that the code
actually becomes more readable like this. So how about automatically
optimizing the code by adding something like the following to
seq_file.h:

#define seq_put_decimal_ull(m, delimiter, num) \
(__builtin_constant_p(num) && \
__builtin_constant_p(delimiter) && (delimiter) == ' ' \
? seq_write(m, " " #num, sizeof(" " #num) - 1) \
: seq_put_decimal_ull(m, delimiter, num))

Completely untested and it is a minimal change. It could be written
using an inline function and probably made more general that way
(e.g., handle more delimiters). But this code should handle the case
that exist today and lead to a (very small) improvement without any
real costs to maintenance.


\
 
 \ /
  Last update: 2012-03-24 13:55    [from the cache]
©2003-2011 Jasper Spaans