From cf4596859762f242aa0b5266ce831ef88505985d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 27 Jan 2014 17:27:57 +0100 Subject: [PATCH] =?utf8?q?SL::DB::Unit:=20convertible=5Funits=20die=20Einh?= =?utf8?q?eitenliste=20=C3=BCbergeben=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …damit nicht jeder Aufruf von convertible_units an die DB geht. --- SL/DB/Unit.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index 927e31b2e..b133d8f13 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -27,10 +27,12 @@ sub unit_class { sub convertible_units { my $self = shift; + my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : \@_; + $all_units = SL::DB::Manager::Unit->get_all if !@{ $all_units }; return [ sort { $a->sortkey <=> $b->sortkey } grep { $_->unit_class->name eq $self->unit_class->name } - @{ SL::DB::Manager::Unit->get_all } + @{ $all_units } ]; } -- 2.20.1