Re: Speed of increment operators
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Mar 2006 06:43:10 -0800
axel@xxxxxxxxxxxxxxxxxxxxxx wrote:
Dr.Ruud <rvtol+news@xxxxxxxxxxxx> wrote:
The first two lines of my smaller Perl scripts often look like:
#!/usr/bin/perl
use strict; use warnings; ++$|;
On a slightly different track, is there any different in execution
speed between ++$i and $i++ in Perl. I seem to remember that there
was such a difference in C++ but may be mistaken.
perl -MO=Deparse -e'$x = 5; $x++; ++$x;'
$x = 5;
++$x;
++$x;
-e syntax OK
Seeing as how Perl optimizes away the post-fix notation when called in
a void context, I'm going to go on a limb and say "no, it doesn't make
a difference". In any case in which Perl would not optimize it away,
then you're doing something differently when you call one instead of
the other, and so speed should not be your concern.
Paul Lalli
.
- References:
- Speed of increment operators
- From: axel
- Speed of increment operators
- Prev by Date: Speed of increment operators
- Next by Date: Re: Find duplicates in a dat file
- Previous by thread: Speed of increment operators
- Index(es):
Relevant Pages
|
|