From: gfx Date: Wed, 4 Nov 2009 07:16:20 +0000 (+0900) Subject: Tweaks for speed X-Git-Tag: 0.40_06~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=047d7af00ab8b37c6369c032211bfe492fe6cd05;p=gitmo%2FMouse.git Tweaks for speed --- diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 4384fa0..bb18042 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -64,9 +64,11 @@ sub get_attribute_map { # DEPRECATED sub has_attribute { exists $_[0]->{attributes}->{$_[1]} } sub get_attribute { $_[0]->{attributes}->{$_[1]} } -sub get_attribute_list{ keys %{$_[0]->{attributes}} } sub remove_attribute { delete $_[0]->{attributes}->{$_[1]} } +sub get_attribute_list{ keys %{$_[0]->{attributes}} } + + # XXX: for backward compatibility my %foreign = map{ $_ => undef } qw( Mouse Mouse::Role Mouse::Util Mouse::Util::TypeConstraints diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index f5e3599..a999394 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -213,7 +213,7 @@ sub linearized_isa { @{ get_linear_isa($_[0]->{package}) } } sub get_all_attributes { my($self) = @_; - my %attrs = map { %{ $self->initialize($_)->_attribute_map } } reverse $self->linearized_isa; + my %attrs = map { %{ $self->initialize($_)->{attributes} } } reverse $self->linearized_isa; return values %attrs; } diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 0521e1d..7580f7a 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -5,9 +5,9 @@ SV* mouse_package; SV* mouse_namespace; SV* mouse_methods; SV* mouse_name; +SV* mouse_get_attribute; +SV* mouse_get_attribute_list; -static SV* mouse_all_attrs_cache; -static SV* mouse_all_attrs_cache_gen; #define MOUSE_xc_gen(a) MOUSE_av_at((a), MOUSE_XC_GEN) #define MOUSE_xc_attrall(a) ( (AV*)MOUSE_av_at((a), MOUSE_XC_ATTRALL) ) @@ -36,7 +36,7 @@ mouse_class_push_attribute_list(pTHX_ SV* const metaclass, AV* const attrall, HV XPUSHs(metaclass); PUTBACK; - n = call_method("get_attribute_list", G_ARRAY); + n = call_sv(mouse_get_attribute_list, G_ARRAY | G_METHOD); for(NOOP; n > 0; n--){ SV* name; @@ -49,7 +49,7 @@ mouse_class_push_attribute_list(pTHX_ SV* const metaclass, AV* const attrall, HV } (void)hv_store_ent(seen, name, &PL_sv_undef, 0U); - av_push(attrall, newSVsv( mcall1s(metaclass, "get_attribute", name) )); + av_push(attrall, newSVsv( mcall1(metaclass, mouse_get_attribute, name) )); } } @@ -83,7 +83,7 @@ mouse_class_update_xc(pTHX_ SV* const metaclass PERL_UNUSED_DECL, HV* const stas av_store(xc, MOUSE_XC_DEMOLISHALL, (SV*)demolishall); for(i = 0; i < len; i++){ - SV* const klass = MOUSE_av_at(linearized_isa, i); + SV* const klass = MOUSE_av_at(linearized_isa, i); SV* meta; GV* gv; @@ -171,8 +171,8 @@ BOOT: mouse_methods = newSVpvs_share("methods"); mouse_name = newSVpvs_share("name"); - mouse_all_attrs_cache = newSVpvs_share("__all_attrs_cache"); - mouse_all_attrs_cache_gen = newSVpvs_share("__all_attrs_cache_gen"); + mouse_get_attribute = newSVpvs_share("get_attribute"); + mouse_get_attribute_list = newSVpvs_share("get_attribute_list"); MOUSE_CALL_BOOT(Mouse__Util); MOUSE_CALL_BOOT(Mouse__Util__TypeConstraints);