File tree 2 files changed +19
-225
lines changed
compiler/src/dotty/tools/dotc 2 files changed +19
-225
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ package tasty
6
6
import TastyFormat ._
7
7
import collection .mutable
8
8
import TastyBuffer ._
9
- import util .CityHash
10
9
import core .Symbols .Symbol
11
10
import ast .tpd
12
11
import Decorators ._
@@ -26,8 +25,8 @@ class TastyPickler {
26
25
buf.length + natSize(buf.length)
27
26
}
28
27
29
- val uuidLow : Long = CityHash .bytesHash (nameBuffer.bytes)
30
- val uuidHi : Long = sections.iterator.map(x => CityHash .bytesHash (x._2.bytes)).fold(0L )(_ ^ _)
28
+ val uuidLow : Long = pjwHash64 (nameBuffer.bytes)
29
+ val uuidHi : Long = sections.iterator.map(x => pjwHash64 (x._2.bytes)).fold(0L )(_ ^ _)
31
30
32
31
val headerBuffer = {
33
32
val buf = new TastyBuffer (header.length + 24 )
@@ -72,4 +71,21 @@ class TastyPickler {
72
71
var addrOfSym : Symbol => Option [Addr ] = (_ => None )
73
72
74
73
val treePkl = new TreePickler (this )
74
+
75
+ /** Returns a non-cryptographic 64-bit hash of the array.
76
+ *
77
+ * from https://en.wikipedia.org/wiki/PJW_hash_function#Implementation
78
+ */
79
+ private def pjwHash64 (data : Array [Byte ]): Long = {
80
+ var h = 0L
81
+ var high = 0L
82
+ for (b <- data) {
83
+ h = (h << 4 ) + b
84
+ high = h & 0xF0000000L
85
+ if (high != 0 )
86
+ h ^= high >> 24
87
+ h &= ~ high
88
+ }
89
+ h
90
+ }
75
91
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments