in reply to Re^3: map vs for\foreach.
in thread map vs for\foreach.
Superstition makes me post-increment; I think it’s not slower anymore but was back in the dinosaur age.
Post-increment is necessarily slower since it requires making a copy of the scalar that pre-increment doesn't. However, Perl replaces post-increment operators in void context with pre-increment operators.
$ perl -MO=Deparse -e'$_++ for @a;' ++$_ foreach (@a); -e syntax OK $ perl -MO=Deparse -e'map { $_++ } @a;' map {$_++;} @a; -e syntax OK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: map vs for\foreach.
by karlgoethebier (Abbot) on Mar 13, 2015 at 18:31 UTC | |
by LanX (Saint) on Mar 13, 2015 at 18:38 UTC |