Update compare methods everywhere

The static comparison helpers provided by java are
significantly faster, replace compare functions
everywhere with them.
pull/5168/head
Isaac Levy 2019-06-04 06:18:11 -04:00
parent fd42b54e16
commit 29314f7ab0
6 changed files with 7 additions and 7 deletions

View File

@ -113,7 +113,7 @@ object Store {
private implicit val InfoReader = Macros.reader[Info]
case class Dated[V](value: V, date: DateTime) extends Ordered[Dated[V]] {
def compare(other: Dated[V]) = other.date.getMillis compare date.getMillis
def compare(other: Dated[V]) = other.date compareTo date
}
def chronoInfoByUser(userId: User.ID): Fu[List[Info]] =

View File

@ -2,7 +2,7 @@ package lila.simul
private[simul] sealed abstract class SimulStatus(val id: Int) extends Ordered[SimulStatus] {
def compare(other: SimulStatus) = id compare other.id
def compare(other: SimulStatus) = Integer.compare(id, other.id)
def name = toString

View File

@ -79,7 +79,7 @@ object Schedule {
val name = toString.toLowerCase
def compare(other: Freq) = importance compare other.importance
def compare(other: Freq) = Integer.compare(importance, other.importance)
def isDaily = this == Schedule.Freq.Daily
def isDailyOrBetter = this >= Schedule.Freq.Daily

View File

@ -2,7 +2,7 @@ package lila.tournament
private[tournament] sealed abstract class Status(val id: Int) extends Ordered[Status] {
def compare(other: Status) = id compare other.id
def compare(other: Status) = Integer.compare(id, other.id)
def name = toString

View File

@ -12,8 +12,8 @@ case class Trophy(
def timestamp = date.getMillis
def compare(other: Trophy) =
if (kind.order == other.kind.order) timestamp compare other.timestamp
else kind.order compare other.kind.order
if (kind.order == other.kind.order) date compareTo other.date
else Integer.compare(kind.order, other.kind.order)
}
object Trophy {

View File

@ -46,7 +46,7 @@ case class User(
def langs = ("en" :: lang.toList).distinct.sorted
def compare(other: User) = id compare other.id
def compare(other: User) = id compareTo other.id
def noTroll = !troll