From: gfx Date: Tue, 27 Oct 2009 05:51:56 +0000 (+0900) Subject: Tiny optimization X-Git-Tag: 0.40_02~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5df48e596d4b685f53bf59ef581d6999ab14eb6;p=gitmo%2FMouse.git Tiny optimization --- diff --git a/mouse.h b/mouse.h index 1267c9e..9447037 100644 --- a/mouse.h +++ b/mouse.h @@ -43,6 +43,8 @@ AV* mouse_mro_get_linear_isa(pTHX_ HV* const stash); extern SV* mouse_package; extern SV* mouse_namespace; +extern SV* mouse_methods; +extern SV* mouse_name; 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 ccbf65f..a538e41 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -3,6 +3,7 @@ SV* mouse_package; SV* mouse_namespace; SV* mouse_methods; +SV* mouse_name; MODULE = Mouse PACKAGE = Mouse::Util @@ -12,6 +13,7 @@ BOOT: mouse_package = newSVpvs_share("package"); mouse_namespace = newSVpvs_share("namespace"); mouse_methods = newSVpvs_share("methods"); + mouse_name = newSVpvs_share("name"); MOUSE_CALL_BOOT(Mouse__Util__TypeConstraints); diff --git a/xs-src/mouse_accessor.xs b/xs-src/mouse_accessor.xs index dc91208..6222f74 100644 --- a/xs-src/mouse_accessor.xs +++ b/xs-src/mouse_accessor.xs @@ -45,7 +45,7 @@ static MGVTBL mouse_accessor_vtbl; /* MAGIC identity */ CV* mouse_instantiate_xs_accessor(pTHX_ SV* const attr, XSUBADDR_t const accessor_impl){ - SV* const slot = mcall0s(attr, "name"); + SV* const slot = mcall0(attr, mouse_name); AV* const xa = newAV(); CV* xsub; MAGIC* mg; @@ -91,7 +91,7 @@ mouse_instantiate_xs_accessor(pTHX_ SV* const attr, XSUBADDR_t const accessor_im else{ mouse_throw_error(attr, tc, "Can not auto de-reference the type constraint '%"SVf"'", - mcall0s(tc, "name")); + mcall0(tc, mouse_name)); } } @@ -162,7 +162,7 @@ mouse_apply_type_constraint(pTHX_ AV* const xa, SV* value, U16 const flags){ if(!mouse_tc_check(aTHX_ tc_code, value)){ mouse_throw_error(MOUSE_xa_attribute(xa), value, "Attribute (%"SVf") does not pass the type constraint because: %"SVf, - mcall0s(MOUSE_xa_attribute(xa), "name"), + mcall0(MOUSE_xa_attribute(xa), mouse_name), mcall1s(tc, "get_message", value)); }