Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Efficient bit-twiddling in Perl.

by salva (Abbot)
on Feb 28, 2013 at 15:17 UTC ( #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 (Pope) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021066]
[ambrus]: Corion: if you're forking from perl, then schmorp has a module that helps this prefork magic
[Corion]: ambrus: yeah, but the longer I think about it the more I come to the conclusion that you shouldn't try to mix threads and fork anyway :)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-10-19 14:53 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (253 votes). Check out past polls.