summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2005-05-11 07:39:46 +0000
committerschinz <schinz@epfl.ch>2005-05-11 07:39:46 +0000
commit540fe94ec01a85ef76da15e8b5efd889ace9769e (patch)
treead7f5c88b0db3d652acaf4ef0478a4489948b3b2 /sources
parent171b8ec35104af9dce81e22756d5e8bb0ac1f2f2 (diff)
downloadscala-540fe94ec01a85ef76da15e8b5efd889ace9769e.tar.gz
scala-540fe94ec01a85ef76da15e8b5efd889ace9769e.tar.bz2
scala-540fe94ec01a85ef76da15e8b5efd889ace9769e.zip
- added function in FNV_Hash to add an integer ...
- added function in FNV_Hash to add an integer to a hash, to be able to remove PearsonHash, - removed PearsonHash and all uses thereof, - removed isStronglyTrivial from TypeConstructor, as no constructor exists for strongly trivial types anymore
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/Type.java3
-rw-r--r--sources/scala/runtime/FNV_Hash.java13
-rw-r--r--sources/scala/runtime/types/ScalaClassType.java8
-rw-r--r--sources/scala/runtime/types/TypeConstructor.java5
4 files changed, 14 insertions, 15 deletions
diff --git a/sources/scala/Type.java b/sources/scala/Type.java
index 389ee5701a..288bb634f5 100644
--- a/sources/scala/Type.java
+++ b/sources/scala/Type.java
@@ -29,7 +29,6 @@ import scala.runtime.types.TypeAnyVal;
import scala.runtime.types.Statistics;
import scala.runtime.FNV_Hash;
-import scala.runtime.PearsonHash;
/**
* Run-time types for Scala.
@@ -148,7 +147,7 @@ abstract public class Type implements java.io.Serializable {
int h = FNV_Hash.INIT;
for (int i = 0; i < len; ++i)
- h = FNV_Hash.hashStep(h, PearsonHash.hash8(types[i].hashCode()));
+ h = FNV_Hash.hashStep32(h, types[i].hashCode());
return h;
}
diff --git a/sources/scala/runtime/FNV_Hash.java b/sources/scala/runtime/FNV_Hash.java
index 5d1ab003f4..6259c33efb 100644
--- a/sources/scala/runtime/FNV_Hash.java
+++ b/sources/scala/runtime/FNV_Hash.java
@@ -20,8 +20,15 @@ package scala.runtime;
public class FNV_Hash {
public static final int INIT = -2128831035;
- public static int hashStep(int current, int newByte) {
- return (current * 16777619) ^ newByte;
+ public static int hashStep8(int current, int newInt8) {
+ return (current * 16777619) ^ newInt8;
+ }
+
+ public static int hashStep32(int current, int newInt32) {
+ final int v1 = hashStep8(current, newInt32 >> 24);
+ final int v2 = hashStep8(v1, (newInt32 >> 16) & 0xFF);
+ final int v3 = hashStep8(v2, (newInt32 >> 8) & 0xFF);
+ return hashStep8(v3, newInt32 & 0xFF);
}
public static int hash32(byte[] bytes) {
@@ -29,7 +36,7 @@ public class FNV_Hash {
int h = INIT;
for (int i = 0; i < len; ++i)
- h = hashStep(h, bytes[i]);
+ h = hashStep8(h, bytes[i]);
return h;
}
diff --git a/sources/scala/runtime/types/ScalaClassType.java b/sources/scala/runtime/types/ScalaClassType.java
index d5380ad646..929dd4a654 100644
--- a/sources/scala/runtime/types/ScalaClassType.java
+++ b/sources/scala/runtime/types/ScalaClassType.java
@@ -15,7 +15,6 @@ import scala.Array;
import scala.ScalaObject;
import scala.runtime.RunTime;
import scala.runtime.FNV_Hash;
-import scala.runtime.PearsonHash;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -51,15 +50,12 @@ public class ScalaClassType extends ClassType {
this.constr = constr;
this.inst = inst;
- int hash = FNV_Hash.hashStep(FNV_Hash.INIT,
- PearsonHash.hash8(constr.hashCode()));
+ int hash = FNV_Hash.hashStep32(FNV_Hash.INIT, constr.hashCode());
for (int i = 0; i < inst.length; ++i) {
- hash = FNV_Hash.hashStep(hash,
- PearsonHash.hash8(inst[i].hashCode()));
+ hash = FNV_Hash.hashStep32(hash, inst[i].hashCode());
}
this.hashCode = hash;
this.parents = parents;
- this.ancestors = constr.isStronglyTrivial ? EMPTY_ANCESTORS : null;
}
public boolean isInstance(Object o) {
diff --git a/sources/scala/runtime/types/TypeConstructor.java b/sources/scala/runtime/types/TypeConstructor.java
index 6973050105..bdf5199487 100644
--- a/sources/scala/runtime/types/TypeConstructor.java
+++ b/sources/scala/runtime/types/TypeConstructor.java
@@ -46,11 +46,9 @@ public class TypeConstructor implements java.io.Serializable {
/**
* Indication of triviality: a constructor is trivial iff it has
- * no enclosing class, and no type arguments. It is strongly
- * trivial if all its ancestors, itself included, are trivial.
+ * no enclosing class, and no type arguments.
*/
public final boolean isTrivial;
- public final boolean isStronglyTrivial;
public final int ancestorCacheDepth;
/**
@@ -99,7 +97,6 @@ public class TypeConstructor implements java.io.Serializable {
(ancestorCode == null ? EMPTY_ANCESTOR_CODE : ancestorCode);
this.isTrivial = (outer == null) && (zCount + pCount + mCount == 0);
- this.isStronglyTrivial = (ancestorCacheDepth == 0);
try {
this.clazz = Class.forName(fullName, false, loader);