/f list sorting method performance boost

This commit is contained in:
Brettflan 2012-01-11 19:11:10 -06:00
parent 78a62bc25c
commit 23f55ee753

View File

@ -48,9 +48,11 @@ public class CmdList extends FCommand
Collections.sort(factionList, new Comparator<Faction>(){ Collections.sort(factionList, new Comparator<Faction>(){
@Override @Override
public int compare(Faction f1, Faction f2) { public int compare(Faction f1, Faction f2) {
if (f1.getFPlayers().size() < f2.getFPlayers().size()) int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size)
return 1; return 1;
else if (f1.getFPlayers().size() > f2.getFPlayers().size()) else if (f1Size > f2Size)
return -1; return -1;
return 0; return 0;
} }
@ -60,9 +62,11 @@ public class CmdList extends FCommand
Collections.sort(factionList, new Comparator<Faction>(){ Collections.sort(factionList, new Comparator<Faction>(){
@Override @Override
public int compare(Faction f1, Faction f2) { public int compare(Faction f1, Faction f2) {
if (f1.getFPlayersWhereOnline(true).size() < f2.getFPlayersWhereOnline(true).size()) int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size)
return 1; return 1;
else if (f1.getFPlayersWhereOnline(true).size() > f2.getFPlayersWhereOnline(true).size()) else if (f1Size > f2Size)
return -1; return -1;
return 0; return 0;
} }