Skip to content

Commit

Permalink
Don't use the 'store' feature in C::I::S::M::_add_module_object()
Browse files Browse the repository at this point in the history
This way, the template becomes completely static and can be moved out of
_add_module_object(). We can also remove the $NO_DUPLICATES flag because
it only applies for 'store' clauses.

Moreover, recent versions of Params::Check have been optimized for the
non-store case, which is more efficient in this hot section of the code.
  • Loading branch information
vpit committed Apr 27, 2012
1 parent 3f8d095 commit a50743e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/CPANPLUS/Internals/Source/Memory.pm
Expand Up @@ -123,25 +123,22 @@ sub _add_author_object {
}

{
my @required_opts = map { $_ => { required => 1 } } qw[
module version path comment author package description dslip mtime
];
my $tmpl = {
class => { default => 'CPANPLUS::Module' },
map { $_ => { required => 1 } } qw[
module version path comment author package description dslip mtime
],
};

sub _add_module_object {
my $self = shift;
my %hash = @_;

my $class;
my $tmpl = {
class => { default => 'CPANPLUS::Module', store => \$class },
@required_opts,
};

my $href = do {
local $Params::Check::NO_DUPLICATES = 1;
local $Params::Check::SANITY_CHECK_TEMPLATE = 0;
check( $tmpl, \%hash ) or return;
};
my $class = delete $href->{class};

my $obj = $class->new( %$href, _id => $self->_id );

Expand Down

0 comments on commit a50743e

Please sign in to comment.