Skip to content

Commit 5ab850b

Browse files
committed
Improve entropy of low bits of the Tasty UUID
1 parent 05ab4cf commit 5ab850b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ class TastyPickler(val rootCls: ClassSymbol) {
2626
nameBuffer.assemble()
2727
sections.foreach(_._2.assemble())
2828

29-
val uuidLow: Long = pjwHash64(nameBuffer.bytes)
30-
val uuidHi: Long = sections.iterator.map(x => pjwHash64(x._2.bytes)).fold(0L)(_ ^ _)
29+
val sectionHashes = sections.iterator.map(x => pjwHash64(x._2.bytes))
30+
// Hash of name table and tree
31+
val uuidLow: Long = pjwHash64(nameBuffer.bytes) ^ sectionHashes.next()
32+
// Hash of positions, comments and any additional section
33+
val uuidHi: Long = sectionHashes.fold(0L)(_ ^ _)
3134

3235
val headerBuffer = {
3336
val buf = new TastyBuffer(header.length + 24)

0 commit comments

Comments
 (0)