lkml.org 
[lkml]   [2004]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: seperator error in __mask_snprintf_len
Andrew wrote:
> Gad.

Could you elaborate a bit on this critique, Andrew?

You sketch an alternative, that loops by bit, with an sprintf each
nibble, instead of looping by u32 word. By the time that alternative is
fancied up to handle (optionally) suppression of leading zero words and
(vital, for very long masks) a 32-bit word separator, and various other
details, I doubt that it will be any simpler than the corresponding bit
of code in my patch:

int i = maskbytes/sizeof(u32) - 1;
int len = 0;
char *sep = "";

while (i >= 1 && wordp[M32X(i)] == 0)
i--;
while (i >= 0) {
len += snprintf(buf+len, buflen-len,
"%s%x", sep, wordp[M32X(i)]);
sep = ",";
i--;
}

I am at a loss to understand why the above u32 loop version of this code
is so much worse that it only merits a "Gad".

Did I provide too many comments?


> It is hardly performance-critical.

I quite agree on that. One thing I _do_ try to optimize in most code is
the number of "fussy details". The few operations, conditions, special
cases, and such, the better, given the finite limits of human brain power.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:00    [W:0.096 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site