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
This commit is contained in:
jjhua 2013-06-27 01:25:45 +00:00
parent 69b2b419d6
commit c448c7f09a

View File

@ -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;
}