add inlined versions of the base forms of the parameterizable tcs
Jesse Luehrs [Sat, 17 Apr 2010 02:27:36 +0000 (21:27 -0500)]
lib/Moose/Util/TypeConstraints.pm
lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm

index e86d041..9109bbd 100644 (file)
@@ -721,8 +721,8 @@ $REGISTRY->add_type_constraint(
         package_defined_in => __PACKAGE__,
         parent             => find_type_constraint('Ref'),
         constraint         => sub { ref($_) eq 'SCALAR' || ref($_) eq 'REF' },
-        optimized =>
-            \&Moose::Util::TypeConstraints::OptimizedConstraints::ScalarRef,
+        inline_optimized   =>
+            Moose::Util::TypeConstraints::OptimizedConstraints::InlineScalarRef,
         constraint_generator => sub {
             my $type_parameter = shift;
             my $check          = $type_parameter->_compiled_type_constraint;
@@ -739,8 +739,8 @@ $REGISTRY->add_type_constraint(
         package_defined_in => __PACKAGE__,
         parent             => find_type_constraint('Ref'),
         constraint         => sub { ref($_) eq 'ARRAY' },
-        optimized =>
-            \&Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef,
+        inline_optimized   =>
+            Moose::Util::TypeConstraints::OptimizedConstraints::InlineArrayRef,
         constraint_generator => sub {
             my $type_parameter = shift;
             my $check          = $type_parameter->_compiled_type_constraint;
@@ -760,8 +760,8 @@ $REGISTRY->add_type_constraint(
         package_defined_in => __PACKAGE__,
         parent             => find_type_constraint('Ref'),
         constraint         => sub { ref($_) eq 'HASH' },
-        optimized =>
-            \&Moose::Util::TypeConstraints::OptimizedConstraints::HashRef,
+        inline_optimized   =>
+            Moose::Util::TypeConstraints::OptimizedConstraints::InlineHashRef,
         constraint_generator => sub {
             my $type_parameter = shift;
             my $check          = $type_parameter->_compiled_type_constraint;
@@ -781,6 +781,7 @@ $REGISTRY->add_type_constraint(
         package_defined_in   => __PACKAGE__,
         parent               => find_type_constraint('Item'),
         constraint           => sub {1},
+        inline_optimized     => '1',
         constraint_generator => sub {
             my $type_parameter = shift;
             my $check          = $type_parameter->_compiled_type_constraint;
index 9c632e1..3108a1a 100644 (file)
@@ -30,7 +30,6 @@ sub InlineInt {
     q{defined($_[0]) && !ref($_[0]) && $_[0] =~ /^-?[0-9]+$/}
 }
 
-# XXX: not used yet
 sub InlineScalarRef { q{ref($_[0]) eq 'SCALAR' || ref($_[0]) eq 'REF'} }
 sub InlineArrayRef  { q{ref($_[0]) eq 'ARRAY'}                         }
 sub InlineHashRef   { q{ref($_[0]) eq 'HASH'}                          }
@@ -38,13 +37,6 @@ sub InlineCodeRef   { q{ref($_[0]) eq 'CODE'}                          }
 sub InlineRegexpRef { q{ref($_[0]) eq 'Regexp'}                        }
 sub InlineGlobRef   { q{ref($_[0]) eq 'GLOB'}                          }
 
-sub ScalarRef { ref($_[0]) eq 'SCALAR' || ref($_[0]) eq 'REF' }
-sub ArrayRef  { ref($_[0]) eq 'ARRAY'  }
-sub HashRef   { ref($_[0]) eq 'HASH'   }
-sub CodeRef   { ref($_[0]) eq 'CODE'   }
-sub RegexpRef { ref($_[0]) eq 'Regexp' }
-sub GlobRef   { ref($_[0]) eq 'GLOB'   }
-
 sub InlineFileHandle {
         q{(ref($_[0]) eq 'GLOB' && Scalar::Util::openhandle($_[0]))}
   . q{ or (Scalar::Util::blessed($_[0]) && $_[0]->isa('IO::Handle'))}