Commit a4e23021 authored by sikeda's avatar sikeda
Browse files

[dev] dup_var() with complex data is very inefficient and makes response very...

[dev] dup_var() with complex data is very inefficient and makes response very slow.  Experimentally use Clone::clone().


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12955 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 540d14ee
......@@ -61,6 +61,11 @@ our %cpan_modules = (
mandatory => 1,
'gettext_id' => 'used to construct various singleton classes.',
},
'Clone' => {
required_version => '0.31',
package_name => 'Clone',
'gettext_id' => 'used to make copy of internal data structures.',
},
'Crypt::CipherSaber' => {
required_version => '0.50',
package_name => 'Crypt-CipherSaber',
......
......@@ -367,7 +367,7 @@ Returns hashref to list parameter information.
sub list_params {
my $robot_id = shift;
my $pinfo = Sympa::Tools::Data::dup_var(\%Sympa::ListDef::pinfo);
my $pinfo = Sympa::Tools::Data::clone_var(\%Sympa::ListDef::pinfo);
$pinfo->{'lang'}{'format'} = [Sympa::get_supported_languages($robot_id)];
return $pinfo;
......
......@@ -30,6 +30,7 @@ use Encode qw();
use English qw(-no_match_vars);
use POSIX qw();
use XML::LibXML qw();
BEGIN { eval 'use Clone qw()'; }
use Sympa::Tools::Text;
......@@ -131,6 +132,14 @@ sub dump_html_var {
return $html;
}
# Duplicates a complex variable (faster).
# CAUTION: This duplicates blessed elements even if they are
# singleton/multiton; this breaks subroutine references.
sub clone_var {
return Clone::clone($_[0]) if $Clone::VERSION;
goto &dup_var; # '&' needed
}
## Duplictate a complex variable
sub dup_var {
my ($var) = @_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment