[perl #85482] Make bmuladd() able to handle third arg properly.
authorPeter John Acklam <pjacklam@online.no>
Sun, 6 Mar 2011 00:55:30 +0000 (16:55 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 6 Mar 2011 01:16:20 +0000 (17:16 -0800)
bmuladd() contains a test to avoid calling objectify() when it isn't
necessary. This test catches too much, so objectify() isn't always called
when it should have been, e.g., when the two first arguments are are
Math::BigInts and the third is something else, a Math::BigInt::Lite for
example. This causes tests in Math::BigInt::Lite to fail (RT #66369). Also
fix bmuladd() in Math::BigFloat since it suffers from the same problem.

dist/Math-BigInt/lib/Math/BigFloat.pm
dist/Math-BigInt/lib/Math/BigInt.pm

index 07d33cc..06a6e48 100644 (file)
@@ -1697,12 +1697,7 @@ sub bmuladd
   # multiply two numbers and add the third to the result
   
   # set up parameters
-  my ($self,$x,$y,$z,@r) = (ref($_[0]),@_);
-  # objectify is costly, so avoid it
-  if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
-    {
-    ($self,$x,$y,$z,@r) = objectify(3,@_);
-    }
+  my ($self,$x,$y,$z,@r) = objectify(3,@_);
 
   return $x if $x->modify('bmuladd');
 
index e806a75..bb1f518 100644 (file)
@@ -1573,12 +1573,7 @@ sub bmuladd
   # (BINT or num_str, BINT or num_str, BINT or num_str) return BINT
 
   # set up parameters
-  my ($self,$x,$y,$z,@r) = (ref($_[0]),@_);
-  # objectify is costly, so avoid it
-  if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
-    {
-    ($self,$x,$y,$z,@r) = objectify(3,@_);
-    }
+  my ($self,$x,$y,$z,@r) = objectify(3,@_);
 
   return $x if $x->modify('bmuladd');