File tree Expand file tree Collapse file tree 2 files changed +21
-225
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +21
-225
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ package tasty
66import TastyFormat ._
77import collection .mutable
88import TastyBuffer ._
9- import util .CityHash
109import core .Symbols .Symbol
1110import ast .tpd
1211import Decorators ._
@@ -26,8 +25,8 @@ class TastyPickler {
2625 buf.length + natSize(buf.length)
2726 }
2827
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 )(_ ^ _)
3130
3231 val headerBuffer = {
3332 val buf = new TastyBuffer (header.length + 24 )
@@ -72,4 +71,23 @@ class TastyPickler {
7271 var addrOfSym : Symbol => Option [Addr ] = (_ => None )
7372
7473 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+ var i = 0
83+ while (i < data.length) {
84+ h = (h << 4 ) + data(i)
85+ high = h & 0xF0000000L
86+ if (high != 0 )
87+ h ^= high >> 24
88+ h &= ~ high
89+ i += 1
90+ }
91+ h
92+ }
7593}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments