diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-19 21:31:55 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-19 21:31:55 +0000 |
commit | 5fb68614da51c601e354d13ae123820b355594d0 (patch) | |
tree | 62366806e8678628d1cedede056cf8c3719fb62a /src/compiler/scala/tools/cmd/FromString.scala | |
parent | 8337964e312849e5a904b3cfbfa1def0cf180a05 (diff) | |
download | scala-5fb68614da51c601e354d13ae123820b355594d0.tar.gz scala-5fb68614da51c601e354d13ae123820b355594d0.tar.bz2 scala-5fb68614da51c601e354d13ae123820b355594d0.zip |
AbstractPartialFunction.
Contributed by Todd Vierling with minor mods by extempore. This is an
obvious extension of AbstractFunctionN which I had some issue making
work at the time. Sounds kind of pitiful given that the compiler patch
is about two lines, but let's all agree to believe it was a different
world then.
This example program is impacted as follows:
class A {
def f: PartialFunction[Any, Int] = { case x: String => 1 }
def g: PartialFunction[Any, Int] = f orElse { case x: List[_] => 2 }
def h: PartialFunction[Any, Int] = g orElse { case x: Set[_] => 3 }
}
Before: 34943 bytes of bytecode
After: 4217 bytes of bytecode
A mere 88% reduction in size. "'Tis but a trifle!" Closes SI-5096,
SI-5097.
Diffstat (limited to 'src/compiler/scala/tools/cmd/FromString.scala')
-rw-r--r-- | src/compiler/scala/tools/cmd/FromString.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala index 3792c26c34..992530c767 100644 --- a/src/compiler/scala/tools/cmd/FromString.scala +++ b/src/compiler/scala/tools/cmd/FromString.scala @@ -14,7 +14,7 @@ import scala.reflect.OptManifest * example instances are in the companion object, but in general * either IntFromString will suffice or you'll want custom transformers. */ -abstract class FromString[+T](implicit m: OptManifest[T]) extends PartialFunction[String, T] { +abstract class FromString[+T](implicit m: OptManifest[T]) extends scala.runtime.AbstractPartialFunction[String, T] { def apply(s: String): T def isDefinedAt(s: String): Boolean = true def zero: T = apply("") |