From bed8ba6d6cbcb0c8b33528bed6d49709d1ef6282 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 1 Feb 2010 14:23:01 +0100 Subject: [PATCH] Locale-Objekte pro Sprache cachen Damit braucht die FastCGI-basierte Variante locale/de/all nicht bei jedem Aufruf neu einzulesen. --- SL/Locale.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SL/Locale.pm b/SL/Locale.pm index 9e74902ca..172155e46 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -47,6 +47,8 @@ use SL::Inifile; use strict; +my %locales_by_country; + sub new { $main::lxdebug->enter_sub(); @@ -56,14 +58,18 @@ sub new { $country =~ s|.*/||; $country =~ s|\.||g; - my $self = {}; - bless $self, $type; + if (!$locales_by_country{$country}) { + my $self = {}; + bless $self, $type; + + $self->_init($country); - $self->_init($country); + $locales_by_country{$country} = $self; + } $main::lxdebug->leave_sub(); - return $self; + return $locales_by_country{$country} } sub _init { -- 2.20.1