From: Alexandre Duret-Lutz Date: Thu, 5 Aug 2004 23:01:25 +0000 (+0000) Subject: * lib/Automake/Item.pm (def): Rewrite more concisely, it's faster X-Git-Tag: Release-1-9b~319 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=851e3ef582e117919a5dcd78e0a21ad27ee00840;p=thirdparty%2Fautomake.git * lib/Automake/Item.pm (def): Rewrite more concisely, it's faster this way. --- diff --git a/ChangeLog b/ChangeLog index 41b19db01..bbe0b91f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-08-06 Alexandre Duret-Lutz + + * lib/Automake/Item.pm (def): Rewrite more concisely, it's faster + this way. + 2004-08-05 Alexandre Duret-Lutz Speed up make_paragraphs. diff --git a/lib/Automake/Item.pm b/lib/Automake/Item.pm index 02ea8dea7..6dc3b24d5 100644 --- a/lib/Automake/Item.pm +++ b/lib/Automake/Item.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -71,9 +71,12 @@ exists. Return 0 otherwise. sub def ($$) { - my ($self, $cond) = @_; - return $self->{'defs'}{$cond} if exists $self->{'defs'}{$cond}; - return 0; + # This method is called very often, so keep it small and fast. We + # don't mind the extra undefined items introduced by lookup failure; + # avoiding this with `exists' means doing two hash lookup on + # success, and proved worse on benchmark. + my $def = $_[0]->{'defs'}{$_[1]}; + return defined $def && $def; } =item C<$item-Erdef ($cond)>