Re: [RFC][PATCH] Faster generic_fls

From: Andrew Morton (akpm@digeo.com)
Date: Thu May 01 2003 - 00:11:29 EST


hugang <hugang@soulinfo.com> wrote:
>
> Here is table version of the fls. Yes it fast than other.

nooo.. That has a big cache footprint. At the very least you should use
a binary search. gcc will do it for you:

        switch (n) {
        case 0 ... 1:
                return 1;
        case 2 ... 3:
                return 2;
        case 4 ... 7:
                return 3;
        case 8 ... 15:
                return 4;

etc.

-
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/



This archive was generated by hypermail 2b29 : Wed May 07 2003 - 22:00:12 EST