From 9a7e6bf716bdcc38a68ae1ce5d5f981f176c5b66 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Mon, 29 Nov 2021 11:39:28 +0100 Subject: [PATCH] remove Option.ifNone --- modules/common/src/main/base/PimpedUtils.scala | 2 -- modules/game/src/main/Captcher.scala | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/common/src/main/base/PimpedUtils.scala b/modules/common/src/main/base/PimpedUtils.scala index 7a86a93ad5..d42bb5d286 100644 --- a/modules/common/src/main/base/PimpedUtils.scala +++ b/modules/common/src/main/base/PimpedUtils.scala @@ -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 } diff --git a/modules/game/src/main/Captcher.scala b/modules/game/src/main/Captcher.scala index 86c7c90d43..c3d56c9e81 100644 --- a/modules/game/src/main/Captcher.scala +++ b/modules/game/src/main/Captcher.scala @@ -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)