Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Optimizations and Efficiency

by bobione (Pilgrim)
on Jun 30, 2001 at 14:38 UTC ( #92893=note: print w/replies, xml ) Need Help??


in reply to Optimizations and Efficiency

Monk dimmesdale,
I don't understand your first exemple...
It appear to me that it's not the same things:
This...

for($i = 0; $i <= 10_000; $i++) { $ary[$i] = init_val($i); }

means...

$ary[0] = init_val(0) $ary[1] = init_val(1) $ary[2] = init_val(2) ...

and...

$idx = 0; for($i = 0; $i < 10_000; $i += 10) { $ary[$idx++] = init_val($i); $ary[$idx++] = init_val($i); $ary[$idx++] = init_val($i); ... }

means...

$ary[0] = init_val(0) $ary[1] = init_val(0) $ary[2] = init_val(0) ... $ary[10] = init_val(10) $ary[11] = init_val(10) $ary[12] = init_val(10) ...

It should be :

$idx = 0; for($i = 0; $i < 10_000; $i += 10) { $ary[$idx++] = init_val($idx); $ary[$idx++] = init_val($idx); $ary[$idx++] = init_val($idx); ... }

Am I wrong ?

BobiOne KenoBi ;)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-11-15 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (84 votes). Check out past polls.

    Notices?