summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2009-03-12 13:38:43 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2009-03-12 13:38:43 +0000
commit5af0e1461b7562798c3d7c3fcdce346107f5af0b (patch)
tree537a2b5d7f493e7d5fa71e1a1e320a62511edfa8 /src/library
parentf2dfc4a54a562bfbbf9753a3430c4186917c9788 (diff)
downloadscala-5af0e1461b7562798c3d7c3fcdce346107f5af0b.tar.gz
scala-5af0e1461b7562798c3d7c3fcdce346107f5af0b.tar.bz2
scala-5af0e1461b7562798c3d7c3fcdce346107f5af0b.zip
Bytecode generated for structural calls is impr...
Bytecode generated for structural calls is improved slightly. A test shows an improvement of roughly 5% for structural methods' call times.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/runtime/MethodCache.scala22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/library/scala/runtime/MethodCache.scala b/src/library/scala/runtime/MethodCache.scala
index a763329bc4..1c41c7db11 100644
--- a/src/library/scala/runtime/MethodCache.scala
+++ b/src/library/scala/runtime/MethodCache.scala
@@ -42,7 +42,10 @@ final class EmptyMethodCache extends MethodCache {
}
-final class MegaMethodCache(forName: String, forParameterTypes: Array[JClass[_]]) extends MethodCache {
+final class MegaMethodCache(
+ private[this] val forName: String,
+ private[this] val forParameterTypes: Array[JClass[_]]
+) extends MethodCache {
def find(forReceiver: JClass[_]): JMethod =
forReceiver.getMethod(forName, forParameterTypes:_*)
@@ -51,18 +54,23 @@ final class MegaMethodCache(forName: String, forParameterTypes: Array[JClass[_]]
}
-final class PolyMethodCache(next: MethodCache, receiver: JClass[_], method: JMethod, complexity: Int) extends MethodCache {
+final class PolyMethodCache(
+ private[this] val next: MethodCache,
+ private[this] val receiver: JClass[_],
+ private[this] val method: JMethod,
+ private[this] val complexity: Int
+) extends MethodCache {
def find(forReceiver: JClass[_]): JMethod =
- if (forReceiver == receiver)
- method
+ if (forReceiver eq receiver)
+ return method
else
- next.find(forReceiver) // tail call is optimised, confirm with -Ylog:tailcalls
+ return next.find(forReceiver) // tail call is optimised, confirm with -Ylog:tailcalls
def add(forReceiver: JClass[_], forMethod: JMethod): MethodCache =
if (complexity < 160) // TODO: come up with a more realistic number
- new PolyMethodCache(this, forReceiver, forMethod, complexity + 1)
+ return new PolyMethodCache(this, forReceiver, forMethod, complexity + 1)
else
- new MegaMethodCache(forMethod.getName, forMethod.getParameterTypes)
+ return new MegaMethodCache(forMethod.getName, forMethod.getParameterTypes)
}