[svn:parrot] r44986 - trunk/src
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Wed Mar 17 17:57:45 UTC 2010
Author: whiteknight
Date: Wed Mar 17 17:57:45 2010
New Revision: 44986
URL: https://trac.parrot.org/parrot/changeset/44986
Log:
[mmd] change the mmd distance calculating algorithm to count autoboxing as one step, and implicit type matching as a second. calling with an S register should match (String) more closely than (_). Fixes TT #1144
Modified:
trunk/src/multidispatch.c
Modified: trunk/src/multidispatch.c
==============================================================================
--- trunk/src/multidispatch.c Wed Mar 17 17:55:50 2010 (r44985)
+++ trunk/src/multidispatch.c Wed Mar 17 17:57:45 2010 (r44986)
@@ -633,16 +633,23 @@
continue;
/* promote primitives to their PMC equivalents, as PCC will autobox
- * the distance penalty makes primitive variants look cheaper */
+ * them. If it's a direct autobox, int->Integer, str->String, or
+ * num->Num, the distance is 1 and we move to the next arg. If it's
+ * autoboxing to "any" PMC type, we increment the distance and continue
+ * weighing other things. A direct autobox should be cheaper than an
+ * autobox plus type conversion or implicit type acceptance. */
switch (type_call) {
case enum_type_INTVAL:
if (type_sig == enum_class_Integer) { dist++; continue; }
+ if (type_sig == enum_type_PMC) dist++;
break;
case enum_type_FLOATVAL:
if (type_sig == enum_class_Float) { dist++; continue; }
+ if (type_sig == enum_type_PMC) dist++;
break;
case enum_type_STRING:
if (type_sig == enum_class_String) { dist++; continue; }
+ if (type_sig == enum_type_PMC) dist++;
break;
default:
break;
More information about the parrot-commits
mailing list