Skip to content

Commit

Permalink
Don't regenerate the required options every time in _add_module_object()
Browse files Browse the repository at this point in the history
  • Loading branch information
vpit committed Apr 22, 2012
1 parent b935c23 commit 26bd52c
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions lib/CPANPLUS/Internals/Source/Memory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,34 @@ sub _add_author_object {
return $obj;
}

sub _add_module_object {
my $self = shift;
my %hash = @_;
{
my @required_opts = map { $_ => { required => 1 } } qw[
module version path comment author package description dslip mtime
];

my $class;
my $tmpl = {
class => { default => 'CPANPLUS::Module', store => \$class },
map { $_ => { required => 1 } }
qw[ module version path comment author package description dslip mtime ]
};
sub _add_module_object {
my $self = shift;
my %hash = @_;

my $href = do {
local $Params::Check::NO_DUPLICATES = 1;
local $Params::Check::SANITY_CHECK_TEMPLATE = 0;
check( $tmpl, \%hash ) or return;
};
my $class;
my $tmpl = {
class => { default => 'CPANPLUS::Module', store => \$class },
@required_opts,
};

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

### Every module get's stored as a module object ###
$self->module_tree->{ $href->{module} } = $obj or return;
my $obj = $class->new( %$href, _id => $self->_id );

return $obj;
### Every module get's stored as a module object ###
$self->module_tree->{ $href->{module} } = $obj or return;

return $obj;
}
}

{ my %map = (
Expand Down

0 comments on commit 26bd52c

Please sign in to comment.