Skip to content
Browse files

Performance optimization: replace slow Params::Validate validation wi…

…th a (functional equivalent) hand coded one. Makes deserialization 150% faster
  • Loading branch information...
1 parent 3554a8f commit 995e37444561b9d46408b90bf0cad0842df93fee José Micó committed
Showing with 6 additions and 10 deletions.
  1. +0 −1 Build.PL
  2. +0 −1 META.json
  3. +0 −1 META.yml
  4. +6 −7 lib/Net/AMQP/Frame.pm
View
1 Build.PL
@@ -9,7 +9,6 @@ my $build = Module::Build->new(
'Test::Deep' => 0,
},
requires => {
- 'Params::Validate' => 0,
'Class::Accessor' => 0,
'Class::Data::Inheritable' => 0,
'XML::LibXML' => 0,
View
1 META.json
@@ -30,7 +30,6 @@
"requires" : {
"Class::Accessor" : 0,
"Class::Data::Inheritable" : 0,
- "Params::Validate" : 0,
"XML::LibXML" : 0
}
}
View
1 META.yml
@@ -61,7 +61,6 @@ provides:
requires:
Class::Accessor: 0
Class::Data::Inheritable: 0
- Params::Validate: 0
XML::LibXML: 0
resources:
license: http://dev.perl.org/licenses/
View
13 lib/Net/AMQP/Frame.pm
@@ -10,7 +10,6 @@ use strict;
use warnings;
use base qw(Class::Data::Inheritable Class::Accessor);
use Net::AMQP::Common qw(:all);
-use Params::Validate qw(validate validate_with);
use Carp;
BEGIN {
@@ -60,12 +59,12 @@ Will attempt to identify a L<Net::AMQP::Frame> subclass for further parsing, and
=cut
sub factory {
- my $class = shift;
- my %args = validate(@_, {
- type_id => 1,
- channel => 1,
- payload => 1,
- });
+ my ($class, %args) = @_;
+
+ unless (exists $args{type_id}) { croak "Mandatory parameter 'type_id' missing in call to Net::AMQP::Frame::factory"; }
+ unless (exists $args{channel}) { croak "Mandatory parameter 'channel' missing in call to Net::AMQP::Frame::factory"; }
+ unless (exists $args{payload}) { croak "Mandatory parameter 'payload' missing in call to Net::AMQP::Frame::factory"; }
+ unless (keys %args == 3) { croak "Invalid parameter passed in call to Net::AMQP::Frame::factory"; }
my $subclass;
if ($args{type_id} == 1) {

0 comments on commit 995e374

Please sign in to comment.
Something went wrong with that request. Please try again.