/f list sorting method performance boost

This commit is contained in:
Brettflan 2012-01-11 19:11:31 -06:00
parent bf69f6fd01
commit 3e7d1d028b

View File

@ -46,9 +46,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;
} }
@ -58,9 +60,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;
} }