remove Option.ifNone

deepcrayonfish^2
Thibault Duplessis 2021-11-29 11:39:28 +01:00
parent 06e1261dab
commit 9a7e6bf716
2 changed files with 2 additions and 5 deletions

View File

@ -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 ifNone(n: => Unit): Unit = if (self.isEmpty) n
def has(a: A) = self contains a
}

View File

@ -47,11 +47,10 @@ final private class Captcher(gameRepo: GameRepo)(implicit ec: scala.concurrent.E
private val capacity = 256
private var challenges = NonEmptyList.one(Captcha.default)
private def add(c: Captcha): Unit = {
find(c.gameId) ifNone {
private def add(c: Captcha): Unit =
if (find(c.gameId).isEmpty) {
challenges = NonEmptyList(c, challenges.toList take capacity)
}
}
private def find(id: String): Option[Captcha] =
challenges.find(_.gameId == id)