]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 730877: Improve _get_string_from_file() performances by caching loaded files
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Feb 2012 14:18:38 +0000 (15:18 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Feb 2012 14:18:38 +0000 (15:18 +0100)
r=glob a=LpSolit

Bugzilla/Install/Util.pm

index 4b6e22e90ad3d9eccad17de150d49732c0bc1502..ed23d0093429a5393ef902d48d309b8dcde258fe 100644 (file)
@@ -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};
 }