develooper Front page | perl.perl5.porters | Postings from October 2004

Re: optimization idea

Thread Previous | Thread Next
Nicholas Clark
October 26, 2004 03:49
Re: optimization idea
Message ID:
On Tue, Oct 26, 2004 at 12:32:07PM +0200, H.Merijn Brand wrote:
> On Tue 26 Oct 2004 12:24, Elizabeth Mattijsen <> wrote:
> > >>  > sub statename {
> > >>  >     my $name = 'david';
> > >>  >     ${\$name} = 'liz';
> > >>  >     return "hello, my name is $name";
> > >>  > }
> > >
> > >But surely in this case the ${\$name} should itself be optimised to $name
> > >first?
> > 
> > Well, possibly.  I just wrote it that way to be as succinct as 
> > possible.  I seriously doubt whether spending the extra cycles for 
> > checking for this particular type of situation are worth the 
> > optimization.
> This one would be a compile time optimilization, and would happen only once.
> The de-ref would be done run-time, and the time gained is completely depending
> on how often it would happen

It seems to be a complex optimisation, in that there are a lot of edge cases
to detect where it's not valid. Hence the chance of making a bug in the
optimiser seems high. Therefore it's likely that the time gained by the
optimisation won't outweigh the time lost by debugging and subsequent bug

If people are interested in optimisation, one which could be applicable to
many existing scripts is mentioned in pod/perltodo.pod - trie optimization
for regexp groups. There are several other suggestions for things for the
helpful/brave/clinically insane to get their teeth into in that file, if
people are looking for things to work on.

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About