3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 03:33:06 +01:00

DualIndexHashObject: do not make copy of $data hash

This commit is contained in:
Pragmatic Software 2020-01-25 15:07:40 -08:00
parent ece85be33b
commit 02f1995654

View File

@ -274,6 +274,7 @@ sub add {
my $lc_secondary_index = lc $secondary_index;
if (exists $self->{hash}->{$lc_primary_index} and exists $self->{$lc_primary_index}->{$lc_secondary_index}) {
$self->{pbot}->{logger}->log("Entry $lc_primary_index/$lc_secondary_index already exists.\n");
return "Error: entry already exists";
}
@ -282,13 +283,14 @@ sub add {
}
$data->{_name} = $secondary_index; # preserve case
$self->{hash}->{$lc_primary_index}->{$lc_secondary_index} = {%$data};
$self->{hash}->{$lc_primary_index}->{$lc_secondary_index} = $data;
$self->save() unless $dont_save;
my $name1 = $self->{hash}->{$lc_primary_index}->{_name};
my $name2 = $self->{hash}->{$lc_primary_index}->{$lc_secondary_index}->{_name};
$name1 = 'global' if $name1 eq '.*';
$name2 = "\"$name2\"" if $name2 =~ / /;
$self->{pbot}->{logger}->log("$self->{name}: [$name1]: $name2 added.\n");
return "$self->{name}: [$name1]: $name2 added.";
}