Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Efficient bit-twiddling in Perl.

by salva (Canon)
on Feb 28, 2013 at 15:17 UTC ( [id://1021066]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1021066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found