Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Null-stripping performance

by BrowserUk (Pope)
on Feb 26, 2007 at 13:13 UTC ( #602115=note: print w/replies, xml ) Need Help??


in reply to Null-stripping performance

You'd almost certainly be faster to unpack the entire string into an array once and then just index into the array:

my @numbers = unpack '(a4)*', $string;; ## Requires 5.8.x sub fetchOne { my $index = shift; return $numbers[ $index ]; }

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.

Replies are listed 'Best First'.
Re^2: Null-stripping performance
by qiau (Initiate) on Feb 26, 2007 at 13:52 UTC
    Oh, forgot to say that the strings are pretty large so I don't think arrays would be the best solution.

    Each string is about 1 Mbyte that I read in from a file upon request so a standard use is to open about four files (sometimes more, sometimes less) and read values from different indexes in those strings.

    I think I tried with a array in the beginning but realized that splitting into 1 Mbyte arrays wasn't fast at all :).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-05-11 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (123 votes). Check out past polls.

    Notices?