summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2012-02-29 15:18:38 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2012-02-29 15:18:38 +0100
commit2231368ed7461a3be4f802462628cb7b261f829c (patch)
tree792d7090b4e23325a02e6b712f7fbfd07f040886
parent8ceb72c2709da6ec31f30671286445c4a110c8cd (diff)
downloadbugzilla-2231368ed7461a3be4f802462628cb7b261f829c.tar.gz
bugzilla-2231368ed7461a3be4f802462628cb7b261f829c.tar.xz
Bug 730877: Improve _get_string_from_file() performances by caching loaded files
r=glob a=LpSolit
-rw-r--r--Bugzilla/Install/Util.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm
index 4b6e22e90..ed23d0093 100644
--- a/Bugzilla/Install/Util.pm
+++ b/Bugzilla/Install/Util.pm
@@ -529,6 +529,11 @@ sub no_checksetup_from_cgi {
# Used by install_string
sub _get_string_from_file {
my ($string_id, $file) = @_;
+ # If we already loaded the file, then use its copy from the cache.
+ if (my $strings = _cache()->{strings_from_file}->{$file}) {
+ return $strings->{$string_id};
+ }
+
# This module is only needed by checksetup.pl,
# so only load it when needed.
require Safe;
@@ -537,6 +542,7 @@ sub _get_string_from_file {
my $safe = new Safe;
$safe->rdo($file);
my %strings = %{$safe->varglob('strings')};
+ _cache()->{strings_from_file}->{$file} = \%strings;
return $strings{$string_id};
}