[svn:parrot] r40780 - trunk/src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue Aug 25 10:42:41 UTC 2009
Author: NotFound
Date: Tue Aug 25 10:42:40 2009
New Revision: 40780
URL: https://trac.parrot.org/parrot/changeset/40780
Log:
[cage] don't duplicate find override logic in Object.clone
Modified:
trunk/src/pmc/object.pmc
Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc Tue Aug 25 10:36:45 2009 (r40779)
+++ trunk/src/pmc/object.pmc Tue Aug 25 10:42:40 2009 (r40780)
@@ -644,26 +644,16 @@
*/
VTABLE PMC * clone() {
- Parrot_Object_attributes * const obj = PARROT_OBJECT(pmc);
- Parrot_Class_attributes * const _class = PARROT_CLASS(obj->_class);
- STRING * const meth_name = CONST_STRING(interp, "clone");
-
- /* See if we have a custom override of the method first. */
- const int num_classes = VTABLE_elements(interp, _class->all_parents);
- int i;
- for (i = 0; i < num_classes; i++) {
- /* Get the class. */
- PMC * const cur_class = VTABLE_get_pmc_keyed_int(interp, _class->all_parents, i);
-
- /* Look for a method and run it if we find one. */
- PMC * const meth =
- Parrot_oo_find_vtable_override_for_class(interp, cur_class, meth_name);
- if (!PMC_IS_NULL(meth))
- return (PMC*)Parrot_run_meth_fromc_args(interp, meth, pmc, meth_name, "P");
- }
-
- /* If we get here, no custom clone. Create a new object PMC. */
- return Parrot_oo_clone_object(interp, SELF, obj->_class, NULL);
+ Parrot_Object_attributes * const obj = PARROT_OBJECT(pmc);
+ /* If we have a custom override, invoke it.
+ * If not, use the oo function. */
+ STRING * const meth_name = CONST_STRING(interp, "clone");
+ PMC * const meth =
+ Parrot_oo_find_vtable_override(interp, obj->_class, meth_name);
+ if (!PMC_IS_NULL(meth))
+ return (PMC*)Parrot_run_meth_fromc_args(interp, meth, pmc, meth_name, "P");
+ else
+ return Parrot_oo_clone_object(interp, SELF, obj->_class, NULL);
}
/*
More information about the parrot-commits
mailing list