summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-02-15 12:10:50 -0600
committerJesse Luehrs <doy@tozt.net>2013-02-15 12:10:50 -0600
commit575ef538743cb2c1929b5df54c99ce7800f7e3b3 (patch)
tree87f09884a4cb8bd19350fbfdd95124d8f1a67f61 /src
parentd365b7e335534a2161ce429220f1bc98e973c83b (diff)
downloadscala-path-router-575ef538743cb2c1929b5df54c99ce7800f7e3b3.tar.gz
scala-path-router-575ef538743cb2c1929b5df54c99ce7800f7e3b3.zip
avoid some unnecessary conversions
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/router.scala16
1 files changed, 8 insertions, 8 deletions
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))
}
}