Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Null-stripping performance

by BrowserUk (Patriarch)
on Feb 26, 2007 at 13:13 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://602115]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-18 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found