Robin Sheat wrote:
yeah, I understand Perl references, but you can't (afaik) do C-style pointer
arithmetic with them.
Luckily!
Without pointer arithmetic, this access:
$details->[ $j ]
is something akin to (in C/Perl/psuedocode mishmash):
address_of($details) + sizeof(void *) * $j
That multiply is happening 100 million times.
Apart from Perl:
As a side note, I strongly discourage you to use this kind of
"optimization" in C with pointer arithmetic, as not only it doesn't make
the code faster, but it also makes the code less readable, and limits
the optimizer to do truly advanced optimizations, which gives MUCH MORE
savings, than what you could ever gain by supposedly "saving" a
multiplication at array indexing.
Read here for some beginning ideas about why:
http://en.wikipedia.org/wiki/Loop_transformation
Believe me, today's compilers are really smart when it comes to
optimizing age-old problems (which array indexing in loops is).
--
Greets,
Balázs
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>