[perl #41775] Memoize bug (and patch): problem with LIST_CACHE => MERGE
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Mar 2007 12:18:35 +0000 (04:18 -0800)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 23 Mar 2007 17:34:48 +0000 (17:34 +0000)
From: Father Chrysostomos (via RT) <perlbug-followup@perl.org>
Message-ID: <rt-3.6.HEAD-30201-1173557915-1780.41775-75-0@perl.org>

p4raw-id: //depot/perl@30729

lib/Memoize.pm

index cf84542..f14a34a 100644 (file)
@@ -11,7 +11,7 @@
 # Version 1.01 $Revision: 1.18 $ $Date: 2001/06/24 17:16:47 $
 
 package Memoize;
-$VERSION = '1.01_01';
+$VERSION = '1.01_02';
 
 # Compile-time constants
 sub SCALAR () { 0 } 
@@ -266,8 +266,9 @@ sub _memoizer {
       # Otherwise, we cached an array containing the returned list:
       return @$val;
     } else {
-      my $q = $cache->{$argstr} = [&{$info->{U}}(@_)];
-      @$q;
+        my @q = &{$info->{U}}(@_);
+        $cache->{$argstr} = $info->{O}{LIST_CACHE} eq 'MERGE' ? $q [0] : \@q;
+        @q;
     }
   } else {
     croak "Internal error \#42; context was neither LIST nor SCALAR\n";