Skip to content

Commit

Permalink
Ensure reblessing to the same type is cheap.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 16, 2012
1 parent a98083d commit 5fab963
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ops/nqp.ops
Expand Up @@ -990,11 +990,14 @@ inline op repr_change_type(invar PMC, invar PMC) :base_core {
PMC *obj = decontainerize(interp, $1);
PMC *new_type = decontainerize(interp, $2);
if (obj->vtable->base_type == smo_id && new_type->vtable->base_type == smo_id) {
if (REPR(obj)->change_type)
REPR(obj)->change_type(interp, obj, new_type);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Representation does not implement change_type");
/* Don't rebless without need. */
if (STABLE(obj)->WHAT != new_type) {
if (REPR(obj)->change_type)
REPR(obj)->change_type(interp, obj, new_type);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Representation does not implement change_type");
}
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
Expand Down

0 comments on commit 5fab963

Please sign in to comment.