From: gfx Date: Tue, 2 Feb 2010 03:46:51 +0000 (+0900) Subject: Optimize coercion X-Git-Tag: 0.49~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d39ac61c301d8857e33e6077252e461654d8a37f;p=gitmo%2FMouse.git Optimize coercion --- diff --git a/mouse.h b/mouse.h index f30029f..01518fd 100644 --- a/mouse.h +++ b/mouse.h @@ -60,6 +60,7 @@ extern SV* mouse_package; extern SV* mouse_namespace; extern SV* mouse_methods; extern SV* mouse_name; +extern SV* mouse_coerce; void mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const char* const fmt, ...) diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 0a7d3f9..cad8f5a 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -1,12 +1,14 @@ #define NEED_newSVpvn_flags_GLOBAL #include "mouse.h" +/* keywords for methods/keys */ SV* mouse_package; SV* mouse_namespace; SV* mouse_methods; SV* mouse_name; SV* mouse_get_attribute; SV* mouse_get_attribute_list; +SV* mouse_coerce; #define MOUSE_xc_flags(a) SvUVX(MOUSE_av_at((a), MOUSE_XC_FLAGS)) #define MOUSE_xc_gen(a) MOUSE_av_at((a), MOUSE_XC_GEN) @@ -366,6 +368,7 @@ BOOT: mouse_namespace = newSVpvs_share("namespace"); mouse_methods = newSVpvs_share("methods"); mouse_name = newSVpvs_share("name"); + mouse_coerce = newSVpvs_share("coerce"); mouse_get_attribute = newSVpvs_share("get_attribute"); mouse_get_attribute_list = newSVpvs_share("get_attribute_list"); diff --git a/xs-src/MouseAttribute.xs b/xs-src/MouseAttribute.xs index 0ec9a89..63da0ce 100644 --- a/xs-src/MouseAttribute.xs +++ b/xs-src/MouseAttribute.xs @@ -111,7 +111,7 @@ mouse_xa_apply_type_constraint(pTHX_ AV* const xa, SV* value, U16 const flags){ SV* tc_code; if(flags & MOUSEf_ATTR_SHOULD_COERCE){ - value = mcall1s(tc, "coerce", value); + value = mcall1(tc, mouse_coerce, value); } if(!SvOK(MOUSE_xa_tc_code(xa))){