develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34221 - trunk/languages/perl6/src/classes

From:
pmichaud
Date:
December 21, 2008 15:32
Subject:
[svn:parrot] r34221 - trunk/languages/perl6/src/classes
Message ID:
20081221233155.0ADDDCBA12@x12.develooper.com
Author: pmichaud
Date: Sun Dec 21 15:31:52 2008
New Revision: 34221

Modified:
   trunk/languages/perl6/src/classes/Complex.pir

Log:
[rakudo]:  Clean up .Complex method; eliminate unnecessary Complex objects.


Modified: trunk/languages/perl6/src/classes/Complex.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Complex.pir	(original)
+++ trunk/languages/perl6/src/classes/Complex.pir	Sun Dec 21 15:31:52 2008
@@ -109,7 +109,12 @@
 .sub 'Complex' :method :multi(_)
     $I0 = isa self, 'Complex'
     unless $I0 goto cast
+    $I0 = isa self, 'ObjectRef'
+    if $I0 goto deref
     .return (self)
+  deref:
+    $P0 = deref self
+    .return ($P0)
   cast:
     $P0 = new 'Complex'
     $N0 = self
@@ -147,7 +152,6 @@
     .param pmc a
     .param pmc b
     b = b.'Complex'()
-    $P0 = new 'Complex'
     add $P0, a, b
     .return ($P0)
 .end
@@ -156,7 +160,6 @@
     .param pmc a
     .param pmc b
     a = a.'Complex'()
-    $P0 = new 'Complex'
     add $P0, a, b
     .return ($P0)
 .end
@@ -178,7 +181,6 @@
     .param pmc a
     .param pmc b
     b = b.'Complex'()
-    $P0 = new 'Complex'
     sub $P0, a, b
     .return ($P0)
 .end
@@ -187,7 +189,6 @@
     .param pmc a
     .param pmc b
     a = a.'Complex'()
-    $P0 = new 'Complex'
     sub $P0, a, b
     .return ($P0)
 .end
@@ -211,7 +212,6 @@
     .param pmc a
     .param pmc b
     b = b.'Complex'()
-    $P0 = new 'Complex'
     mul $P0, a, b
     .return ($P0)
 .end
@@ -220,7 +220,6 @@
     .param pmc a
     .param pmc b
     a = a.'Complex'()
-    $P0 = new 'Complex'
     mul $P0, a, b
     .return ($P0)
 .end
@@ -234,7 +233,6 @@
     .param pmc a
     .param pmc b
     b = b.'Complex'()
-    $P0 = new 'Complex'
     div $P0, a, b
     .return ($P0)
 .end
@@ -243,7 +241,6 @@
     .param pmc a
     .param pmc b
     a = a.'Complex'()
-    $P0 = new 'Complex'
     div $P0, a, b
     .return ($P0)
 .end



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About