From: Dave Rolsky Date: Sun, 5 Jun 2011 15:13:04 +0000 (-0500) Subject: Just fetch Value type once rather than each time inlining is done for Num and Int X-Git-Tag: 2.0100~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b47527bf39db1d3daa087bff51a99a9be5af739c;p=gitmo%2FMoose.git Just fetch Value type once rather than each time inlining is done for Num and Int --- diff --git a/lib/Moose/Util/TypeConstraints/Builtins.pm b/lib/Moose/Util/TypeConstraints/Builtins.pm index f9b2dfc..a19c90a 100644 --- a/lib/Moose/Util/TypeConstraints/Builtins.pm +++ b/lib/Moose/Util/TypeConstraints/Builtins.pm @@ -78,12 +78,13 @@ sub define_builtins { . ')' }; + my $value_type = Moose::Util::TypeConstraints::find_type_constraint('Value'); subtype 'Num' => as 'Str' => where { Scalar::Util::looks_like_number($_) } => inline_as { # the long Str tests are redundant here - Moose::Util::TypeConstraints::find_type_constraint('Value')->_inline_check($_[1]) + $value_type->_inline_check($_[1]) . ' && Scalar::Util::looks_like_number(' . $_[1] . ')' }; @@ -91,7 +92,7 @@ sub define_builtins { => as 'Num' => where { (my $val = $_) =~ /\A-?[0-9]+\z/ } => inline_as { - Moose::Util::TypeConstraints::find_type_constraint('Value')->_inline_check($_[1]) + $value_type->_inline_check($_[1]) . ' && (my $val = ' . $_[1] . ') =~ /\A-?[0-9]+\z/' };