From 79cd91dfe4fbfae27c62f776f32e234ec8c0122f Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 9 Jan 2009 15:42:27 -0600 Subject: [PATCH] Basic reformat of section in Search.pm In for loops, replace all-inclusive conditional blocks like: for (@foo) { if (test) { block; } } with conditional use of "next": for (@foo) { test or next; block; } This reduces the number of unnecessarily nested blocks, and the overall number of lines. Signed-off-by: Henri-Damien LAURENT --- C4/Search.pm | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index a3e1bfb32a..80b5106a2a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -496,34 +496,20 @@ sub getRecords { #warn $servers[$i-1]."\n".$record; #.$facet_record->title(); if ($facet_record) { for ( my $k = 0 ; $k <= @$facets ; $k++ ) { - - if ( $facets->[$k] ) { - my @fields; - for my $tag ( @{ $facets->[$k]->{'tags'} } ) - { - push @fields, - $facet_record->field($tag); - } - for my $field (@fields) { - my @subfields = $field->subfields(); - for my $subfield (@subfields) { - my ( $code, $data ) = @$subfield; - if ( $code eq - $facets->[$k]->{'subfield'} ) - { - $facets_counter->{ $facets->[$k] - ->{'link_value'} } - ->{$data}++; - } - } + ($facets->[$k]) or next; + my @fields = map {$facet_record->field($_)} @{$facets->[$k]->{'tags'}} ; + for my $field (@fields) { + my @subfields = $field->subfields(); + for my $subfield (@subfields) { + my ( $code, $data ) = @$subfield; + ($code eq $facets->[$k]->{'subfield'}) or next; + $facets_counter->{ $facets->[$k]->{'link_value'} }->{$data}++; } - $facets_info->{ $facets->[$k] - ->{'link_value'} }->{'label_value'} = - $facets->[$k]->{'label_value'}; - $facets_info->{ $facets->[$k] - ->{'link_value'} }->{'expanded'} = - $facets->[$k]->{'expanded'}; } + $facets_info->{ $facets->[$k]->{'link_value'} }->{'label_value'} = + $facets->[$k]->{'label_value'}; + $facets_info->{ $facets->[$k]->{'link_value'} }->{'expanded'} = + $facets->[$k]->{'expanded'}; } } } -- 2.39.5