You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by qu...@apache.org on 2004/10/06 23:59:34 UTC

svn commit: rev 53916 - spamassassin/trunk/lib/Mail/SpamAssassin

Author: quinlan
Date: Wed Oct  6 14:59:34 2004
New Revision: 53916

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Log:
more get() optimizations


Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	Wed Oct  6 14:59:34 2004
@@ -1421,19 +1421,20 @@
   return $result;
 }
 
+# heavily optimized for speed
+# $_[0] is self
+# $_[1] is request
+# $_[2] is defval
 sub get {
-  my ($self, $request, $defval) = @_;
+  # fill in cache entry if it is empty
+  $_[0]->{c}->{$_[1]} = _get(@_) unless exists $_[0]->{c}->{$_[1]};
 
-  if (!exists $self->{hdr_cache}->{$request}) {
-    $self->{hdr_cache}->{$request} = _get(@_);
-  }
+  # return cache entry if it is defined
+  return $_[0]->{c}->{$_[1]} if defined $_[0]->{c}->{$_[1]};
 
-  my $result = $self->{hdr_cache}->{$request};
-  return $result if defined $result;
-
-  # If the requested header wasn't found, we should return either
-  # a default value as specified by the caller, or the blank string ''.
-  return $defval || '';
+  # if the requested header wasn't found, we should return either
+  # a default value as specified by the caller, or the blank string ''
+  return $_[2] || '';
 }
 
 ###########################################################################