mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* seq_put_decimal_* optimization
@ 2012-03-24 12:52 Ulrich Drepper
  2012-03-26  1:01 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Drepper @ 2012-03-24 12:52 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki, Linux Kernel Mailing List

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-26  1:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24 12:52 seq_put_decimal_* optimization Ulrich Drepper
2012-03-26  1:01 ` KAMEZAWA Hiroyuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome