Subject: | Inline type check in Moose 2.0200 or newer |
Attached is a patch to inline the type check for Moose 2.0200 or newer. Profiling suggested that this was a hotspot in our code.
Subject: | inlined.patch |
diff -ru MooseX-Types-UUID-0.03/Changes MooseX-Types-UUID-0.03-inlined/Changes
--- MooseX-Types-UUID-0.03/Changes 2012-02-06 11:11:57.000000000 -0800
+++ MooseX-Types-UUID-0.03-inlined/Changes 2017-11-09 09:30:36.933823632 -0800
@@ -1,3 +1,5 @@
+ Inline the type check on Moose 2.0200 or newer
+
0.03 Mon Jan 06 19:11:00 GMT 2012
Lower case UUIDs are now supported, as this is documented in the standard
at: http://www.itu.int/rec/T-REC-X.667-200409-S/dologin.asp?lang=e&id=T-REC-X.667-200409-S!!PDF-E&type=items
diff -ru MooseX-Types-UUID-0.03/lib/MooseX/Types/UUID.pm MooseX-Types-UUID-0.03-inlined/lib/MooseX/Types/UUID.pm
--- MooseX-Types-UUID-0.03/lib/MooseX/Types/UUID.pm 2012-02-06 11:10:52.000000000 -0800
+++ MooseX-Types-UUID-0.03-inlined/lib/MooseX/Types/UUID.pm 2017-11-09 09:26:06.805444308 -0800
@@ -14,7 +14,14 @@
}
subtype UUID,
- as Str, where { _validate_uuid($_) };
+ as Str, where { _validate_uuid($_) },
+ ( $Moose::VERSION >= 2.0200
+ ? inline_as {
+ $_[0]->parent()->_inline_check( $_[1] ) . ' && '
+ . qq{ MooseX::Types::UUID::_validate_uuid($_[1]) };
+ }
+ : ()
+ );
coerce UUID,
# i've never seen lowercase UUIDs, but someone's bound to try it