[svn:parrot] r48676 - trunk/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Thu Aug 26 19:54:42 UTC 2010


Author: chromatic
Date: Thu Aug 26 19:54:42 2010
New Revision: 48676
URL: https://trac.parrot.org/parrot/changeset/48676

Log:
[PMC] Optimized Integer cmp() VTABLE.

Modified:
   trunk/src/pmc/integer.pmc

Modified: trunk/src/pmc/integer.pmc
==============================================================================
--- trunk/src/pmc/integer.pmc	Thu Aug 26 19:54:37 2010	(r48675)
+++ trunk/src/pmc/integer.pmc	Thu Aug 26 19:54:42 2010	(r48676)
@@ -1027,15 +1027,20 @@
 */
 
     MULTI INTVAL cmp(String value) {
-        const FLOATVAL fdiff = SELF.get_number() - VTABLE_get_number(INTERP, value);
+        INTVAL iv;
+        GET_ATTR_iv(INTERP, SELF, iv);
+        {
+            const FLOATVAL fdiff =
+                (FLOATVAL)iv - VTABLE_get_number(INTERP, value);
 
-        if (FLOAT_IS_ZERO(fdiff)) {
-            const INTVAL idiff =
-                SELF.get_integer() - VTABLE_get_integer(INTERP, value);
-            return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
-        }
+            if (FLOAT_IS_ZERO(fdiff)) {
+                const INTVAL idiff =
+                    SELF.get_integer() - VTABLE_get_integer(INTERP, value);
+                return idiff > 0 ? 1 : idiff < 0 ? -1 : 0;
+            }
 
-        return fdiff > 0 ? 1 : -1;
+            return fdiff > 0 ? 1 : -1;
+        }
     }
 
 


More information about the parrot-commits mailing list