From 23f55ee753f1133527a4ee36ff3e305854c8e6e4 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 11 Jan 2012 19:11:10 -0600 Subject: [PATCH] /f list sorting method performance boost --- src/com/massivecraft/factions/cmd/CmdList.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdList.java b/src/com/massivecraft/factions/cmd/CmdList.java index 5d595614..fd120708 100644 --- a/src/com/massivecraft/factions/cmd/CmdList.java +++ b/src/com/massivecraft/factions/cmd/CmdList.java @@ -48,9 +48,11 @@ public class CmdList extends FCommand Collections.sort(factionList, new Comparator(){ @Override 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; - else if (f1.getFPlayers().size() > f2.getFPlayers().size()) + else if (f1Size > f2Size) return -1; return 0; } @@ -60,9 +62,11 @@ public class CmdList extends FCommand Collections.sort(factionList, new Comparator(){ @Override 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; - else if (f1.getFPlayersWhereOnline(true).size() > f2.getFPlayersWhereOnline(true).size()) + else if (f1Size > f2Size) return -1; return 0; }