From: Jesse Luehrs Date: Thu, 21 Apr 2011 05:40:22 +0000 (-0500) Subject: fix a couple of unoptimized constraints X-Git-Tag: 2.0100~59 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a79639df8982127bd4c25f647b77a30845100bbb;p=gitmo%2FMoose.git fix a couple of unoptimized constraints there are still more that need to be fixed i think, but do we really care about these at all? they're pretty much only useful for informational purposes, i don't think there's any way to actually trigger this codepath --- diff --git a/lib/Moose/Util/TypeConstraints/Builtins.pm b/lib/Moose/Util/TypeConstraints/Builtins.pm index 1c623de..0b28d49 100644 --- a/lib/Moose/Util/TypeConstraints/Builtins.pm +++ b/lib/Moose/Util/TypeConstraints/Builtins.pm @@ -56,7 +56,7 @@ sub define_builtins { subtype 'Str' => as 'Value' - => where { ref(\$_) eq 'SCALAR' } + => where { ref(\$_) eq 'SCALAR' || ref(\(my $val = $_)) eq 'SCALAR' } => inline_as { 'defined(' . $_[1] . ') ' . '&& (ref(\\' . $_[1] . ') eq "SCALAR"' @@ -73,7 +73,7 @@ sub define_builtins { subtype 'Int' => as 'Num' - => where { "$_" =~ /\A-?[0-9]+\z/ } + => where { (my $val = $_) =~ /\A-?[0-9]+\z/ } => inline_as { 'defined(' . $_[1] . ') ' . '&& !ref(' . $_[1] . ') '