From c448c7f09acc61c72181fd593fc44524c507ad2b Mon Sep 17 00:00:00 2001 From: jjhua Date: Thu, 27 Jun 2013 01:25:45 +0000 Subject: [PATCH] accept Bruce's suggestion, not re-copy the hash every time. And it's really more efficient to have an inner foreach that just adds the keys to the hash git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16783 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/Postage.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index c3af718cb..cb25caeca 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -639,16 +639,17 @@ sub getsshbetweennodes if ($values) { my @gs = split(/,/, $values); %groups = map { $_ => 1 } @gs; - if( $groups{ALLGROUPS} !=1 || $groups{NOGROUPS} !=1 ) { + if( $groups{ALLGROUPS} !=1 && $groups{NOGROUPS} !=1 ) { my @m; foreach my $group (@gs) { my @ns=xCAT::Utils->list_nodes_in_nodegroups($group); - my %nodes = map { $_ => 1 } @ns; - %groups = (%groups, %nodes); + foreach my $n (@ns) { + $groups{$n}=1; + } } } - } + } return \%groups; } @@ -1430,8 +1431,9 @@ sub getNodesSetState my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates($nodes, $nsh); foreach my $state (keys %$nsh) { my $ns = $nsh->{$state}; - my %result = map {$_ => $state} @$ns; - %res = (%result, %res); + foreach my $n (@$ns) { + $res{$n}=$state; + } } return \%res; }