small optimization when sorting based on count and same count entries requires sorting based on term

This commit is contained in:
Shay Banon 2011-08-09 19:45:15 +03:00
parent ee015f5829
commit 1c555679a1
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ public interface TermsFacet extends Facet, Iterable<TermsFacet.Entry> {
@Override public int compare(Entry o1, Entry o2) { @Override public int compare(Entry o1, Entry o2) {
int i = o2.count() - o1.count(); int i = o2.count() - o1.count();
if (i == 0) { if (i == 0) {
i = o2.term().compareTo(o1.term()); i = o2.compareTo(o1);
if (i == 0) { if (i == 0) {
i = System.identityHashCode(o2) - System.identityHashCode(o1); i = System.identityHashCode(o2) - System.identityHashCode(o1);
} }

View File

@ -69,7 +69,7 @@ public interface TermsStatsFacet extends Facet, Iterable<TermsStatsFacet.Entry>
} }
int i = (o2.count() < o1.count() ? -1 : (o1.count() == o2.count() ? 0 : 1)); int i = (o2.count() < o1.count() ? -1 : (o1.count() == o2.count() ? 0 : 1));
if (i == 0) { if (i == 0) {
i = o2.term().compareTo(o1.term()); i = o2.compareTo(o1);
if (i == 0) { if (i == 0) {
i = System.identityHashCode(o2) - System.identityHashCode(o1); i = System.identityHashCode(o2) - System.identityHashCode(o1);
} }