add @tailrec wherever possible

pull/7125/head
Thibault Duplessis 2020-08-16 14:45:58 +02:00
parent d25ef1ff63
commit 5bbb970fb5
5 changed files with 5 additions and 0 deletions

View File

@ -12,6 +12,7 @@ object Levenshtein {
val i = j - dd
((i - (threshold - 1)) max 0) until (1 + ((i + t) min a.length))
}
@scala.annotation.tailrec
def loop(j: Int, prev: Array[Int], prevr: Range, next: Array[Int]): Int = {
if (j > b.length) prev.last
else {

View File

@ -160,6 +160,7 @@ final private class LobbyTrouper(
private def findCompatible(hook: Hook): Option[Hook] =
findCompatibleIn(hook, HookRepo findCompatible hook)
@scala.annotation.tailrec
private def findCompatibleIn(hook: Hook, in: Vector[Hook]): Option[Hook] =
in match {
case Vector() => none

View File

@ -11,6 +11,7 @@ case class Retry(move: String) extends Line
object Line {
def minDepth(lines: Lines): Int = {
@scala.annotation.tailrec
def walk(subs: Vector[(Lines, Int)]): Option[Int] =
subs match {
case Vector() => none

View File

@ -168,6 +168,7 @@ final private class ChapterMaker(
s"""$escapedDomain/(\\w{8,12})"""
}.r.unanchored
@scala.annotation.tailrec
private def parseGame(str: String): Fu[Option[Game]] =
str match {
case s if s.length == Game.gameIdSize => gameRepo game s

View File

@ -113,6 +113,7 @@ object Sheet {
scores.headOption.exists(_.res == ResWin) &&
scores.lift(1).exists(_.res == ResWin)
@scala.annotation.tailrec
private def isDrawStreak(scores: List[Score]): Boolean =
scores match {
case Nil => false