From 851e3ef582e117919a5dcd78e0a21ad27ee00840 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 5 Aug 2004 23:01:25 +0000 Subject: [PATCH] * lib/Automake/Item.pm (def): Rewrite more concisely, it's faster this way. --- ChangeLog | 5 +++++ lib/Automake/Item.pm | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41b19db..bbe0b91 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 02ea8de..6dc3b24 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)> -- 2.7.4