From: Moritz Bunkus Date: Mon, 1 Feb 2010 13:23:01 +0000 (+0100) Subject: Locale-Objekte pro Sprache cachen X-Git-Tag: release-2.6.2beta1~250 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bed8ba6d6cbcb0c8b33528bed6d49709d1ef6282;p=kivitendo-erp.git Locale-Objekte pro Sprache cachen Damit braucht die FastCGI-basierte Variante locale/de/all nicht bei jedem Aufruf neu einzulesen. --- 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 {