remove Option.ifNone
parent
06e1261dab
commit
9a7e6bf716
|
@ -24,8 +24,6 @@ final class PimpedOption[A](private val self: Option[A]) extends AnyVal {
|
||||||
|
|
||||||
def err(message: => String): A = self.getOrElse(sys.error(message))
|
def err(message: => String): A = self.getOrElse(sys.error(message))
|
||||||
|
|
||||||
def ifNone(n: => Unit): Unit = if (self.isEmpty) n
|
|
||||||
|
|
||||||
def has(a: A) = self contains a
|
def has(a: A) = self contains a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,10 @@ final private class Captcher(gameRepo: GameRepo)(implicit ec: scala.concurrent.E
|
||||||
private val capacity = 256
|
private val capacity = 256
|
||||||
private var challenges = NonEmptyList.one(Captcha.default)
|
private var challenges = NonEmptyList.one(Captcha.default)
|
||||||
|
|
||||||
private def add(c: Captcha): Unit = {
|
private def add(c: Captcha): Unit =
|
||||||
find(c.gameId) ifNone {
|
if (find(c.gameId).isEmpty) {
|
||||||
challenges = NonEmptyList(c, challenges.toList take capacity)
|
challenges = NonEmptyList(c, challenges.toList take capacity)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private def find(id: String): Option[Captcha] =
|
private def find(id: String): Option[Captcha] =
|
||||||
challenges.find(_.gameId == id)
|
challenges.find(_.gameId == id)
|
||||||
|
|
Loading…
Reference in New Issue