From 575ef538743cb2c1929b5df54c99ce7800f7e3b3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 15 Feb 2013 12:10:50 -0600 Subject: avoid some unnecessary conversions --- src/main/scala/router.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/scala/router.scala b/src/main/scala/router.scala index 5779256..3b15ca8 100644 --- a/src/main/scala/router.scala +++ b/src/main/scala/router.scala @@ -55,10 +55,10 @@ class Router[T] { } }) - possible.toList match { - case Nil => None - case (r, path) :: Nil => Some(path) - case rs => { + possible match { + case Seq() => None + case Seq((r, path)) => Some(path) + case _ => { // then try to disambiguate the remaining possibilities // - we want the route with the fewest number of "extra" items in the // mapping, after removing defaults and variable path components @@ -66,10 +66,10 @@ class Router[T] { (mapping.keys.toSet -- r.defaults.keys.toSet -- r.variables).size } } val found = possibleByRemainder(possibleByRemainder.keys.min) - found.toList match { - case Nil => None - case (r, path) :: Nil => Some(path) - case rs => + found match { + case Seq() => None + case Seq((r, path)) => Some(path) + case rs => throw new AmbiguousRouteMapping(mapping, rs.map(_._1.path)) } } -- cgit v1.2.3-54-g00ecf