From: Fuji, Goro Date: Sun, 26 Sep 2010 14:19:37 +0000 (+0900) Subject: Tweaks X-Git-Tag: 0.75~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f6c81f00b84bc277a9151337f2a7cc275937f3b8;p=gitmo%2FMouse.git Tweaks --- diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index d1215fa..f2319fa 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -1,6 +1,5 @@ package Mouse::Meta::TypeConstraint; use Mouse::Util qw(:meta); # enables strict and warnings -use Scalar::Util (); sub new { my $class = shift; @@ -222,7 +221,7 @@ sub assert_valid { } sub _as_string { $_[0]->name } # overload "" -sub _identity { Scalar::Util::refaddr($_[0]) } # overload 0+ +sub _identity; # overload 0+ sub _unite { # overload infix:<|> my($lhs, $rhs) = @_; diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index 8f5479e..a4fe59d 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -600,6 +600,8 @@ sub name { $_[0]->{name} } sub parent { $_[0]->{parent} } sub message { $_[0]->{message} } +sub _identity { Scalar::Util::refaddr($_[0]) } # overload 0+ + sub type_parameter { $_[0]->{type_parameter} } sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} } sub _compiled_type_coercion { $_[0]->{_compiled_type_coercion} } diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 47ef5c9..b7fd8e5 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -372,16 +372,14 @@ mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const } } -static SV* +STATIC_INLINE SV* mouse_initialize_metaclass(pTHX_ SV* const klass) { - SV* meta = get_metaclass(klass); - - if(!SvOK(meta)){ - meta = mcall1s(newSVpvs_flags("Mouse::Meta::Class", SVs_TEMP), - "initialize", klass); + SV* const meta = get_metaclass(klass); + if(LIKELY(SvOK(meta))){ + return meta; } - - return meta; + return mcall1s(newSVpvs_flags("Mouse::Meta::Class", SVs_TEMP), + "initialize", klass); } static void diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index 57ed21a..78ce1fd 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -713,6 +713,17 @@ BOOT: code_ref ); } +UV +_identity(SV* self, ...) +CODE: +{ + if(!SvROK(self)) { + croak("Invalid object instance: '%"SVf"'", self); + } + RETVAL = PTR2UV(SvRV(self)); +} +OUTPUT: + RETVAL void compile_type_constraint(SV* self)