harleypig has asked for the wisdom of the Perl Monks concerning the following question:
I ran across the following line of code in Class:Struct and was curious about it. I did some benchmarks and, depending on what and how it was used, it was anywhere from 10-15% faster for large iterations than what I would have used.
my $isa = do {
no strict 'refs';
\@{$class . '::ISA'};
};
I would have used the following:
my $isa;
{ no strict "refs";
$isa = \@{$class . '::ISA'};
}
Now, I understand *what* is happening with Damien's code, but not *why* it's so much faster. I'm thinking it has something to do with the separation of the declaration and definition of the $isa variable, but I don't see why.
Any ideas?
Harley J Pig
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hair Splitting?
by TheDamian (Vicar) on Dec 13, 2001 at 16:43 UTC | |
|
(tye)Re: Hair Splitting?
by tye (Sage) on Dec 13, 2001 at 02:07 UTC | |
by harleypig (Monk) on Dec 13, 2001 at 12:04 UTC |