Update compare methods everywhere
The static comparison helpers provided by java are significantly faster, replace compare functions everywhere with them.pull/5168/head
parent
fd42b54e16
commit
29314f7ab0
|
@ -113,7 +113,7 @@ object Store {
|
||||||
private implicit val InfoReader = Macros.reader[Info]
|
private implicit val InfoReader = Macros.reader[Info]
|
||||||
|
|
||||||
case class Dated[V](value: V, date: DateTime) extends Ordered[Dated[V]] {
|
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]] =
|
def chronoInfoByUser(userId: User.ID): Fu[List[Info]] =
|
||||||
|
|
|
@ -2,7 +2,7 @@ package lila.simul
|
||||||
|
|
||||||
private[simul] sealed abstract class SimulStatus(val id: Int) extends Ordered[SimulStatus] {
|
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
|
def name = toString
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ object Schedule {
|
||||||
|
|
||||||
val name = toString.toLowerCase
|
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 isDaily = this == Schedule.Freq.Daily
|
||||||
def isDailyOrBetter = this >= Schedule.Freq.Daily
|
def isDailyOrBetter = this >= Schedule.Freq.Daily
|
||||||
|
|
|
@ -2,7 +2,7 @@ package lila.tournament
|
||||||
|
|
||||||
private[tournament] sealed abstract class Status(val id: Int) extends Ordered[Status] {
|
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
|
def name = toString
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ case class Trophy(
|
||||||
def timestamp = date.getMillis
|
def timestamp = date.getMillis
|
||||||
|
|
||||||
def compare(other: Trophy) =
|
def compare(other: Trophy) =
|
||||||
if (kind.order == other.kind.order) timestamp compare other.timestamp
|
if (kind.order == other.kind.order) date compareTo other.date
|
||||||
else kind.order compare other.kind.order
|
else Integer.compare(kind.order, other.kind.order)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Trophy {
|
object Trophy {
|
||||||
|
|
|
@ -46,7 +46,7 @@ case class User(
|
||||||
|
|
||||||
def langs = ("en" :: lang.toList).distinct.sorted
|
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
|
def noTroll = !troll
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue