summaryrefslogtreecommitdiff
path: root/src/actors
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-19 21:31:55 +0000
committerPaul Phillips <paulp@improving.org>2011-10-19 21:31:55 +0000
commit5fb68614da51c601e354d13ae123820b355594d0 (patch)
tree62366806e8678628d1cedede056cf8c3719fb62a /src/actors
parent8337964e312849e5a904b3cfbfa1def0cf180a05 (diff)
downloadscala-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/actors')
-rw-r--r--src/actors/scala/actors/Actor.scala2
-rw-r--r--src/actors/scala/actors/Future.scala2
-rw-r--r--src/actors/scala/actors/Reactor.scala3
3 files changed, 3 insertions, 4 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index ba4d90f0b3..b2cd69e914 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -246,7 +246,7 @@ object Actor extends Combinators {
rawSelf.react(new RecursiveProxyHandler(rawSelf, f))
private class RecursiveProxyHandler(a: ReplyReactor, f: PartialFunction[Any, Unit])
- extends PartialFunction[Any, Unit] {
+ extends scala.runtime.AbstractPartialFunction[Any, Unit] {
def isDefinedAt(m: Any): Boolean =
true // events are immediately removed from the mailbox
def apply(m: Any) {
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index 735c13190b..4de73507fb 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -200,7 +200,7 @@ object Futures {
Actor.timer.schedule(timerTask, timeout)
def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
- val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
+ val reaction: PartialFunction[Any, Unit] = new scala.runtime.AbstractPartialFunction[Any, Unit] {
def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
case _ => partFuns exists (_ isDefinedAt msg)
diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala
index 507c18d04e..8f0492f149 100644
--- a/src/actors/scala/actors/Reactor.scala
+++ b/src/actors/scala/actors/Reactor.scala
@@ -38,11 +38,10 @@ private[actors] object Reactor {
}
}
- val waitingForNone = new PartialFunction[Any, Unit] {
+ val waitingForNone: PartialFunction[Any, Unit] = new scala.runtime.AbstractPartialFunction[Any, Unit] {
def isDefinedAt(x: Any) = false
def apply(x: Any) {}
}
-
}
/**