in reply to Efficient bit-twiddling in Perl.

Not a big improvement, but you can eliminate the AND operation when calculating $top14.

If you have to do that millions of times, you can try building a table for the combined three 6bit quantities:

my @table; $table[$_] = [..., ..., ...] for 0..0x0003ffff; ... for my $n (...) { my $top = $n >> 18; my ($nxt, $mid, $bot) = @{$table[$n & 0x0003ffff]}; ... }

Replies are listed 'Best First'.
Re^2: Efficient bit-twiddling in Perl.
by BrowserUk (Patriarch) on Feb 28, 2013 at 19:13 UTC
    you can try building a table for the combined three 6bit quantities:

    The lookup table gains about 20%. Less than I expected, but worth having. Thank you.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.