Skip to content

Commit d6898b9

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ 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 nameBufferHash = pjwHash64(nameBuffer.bytes)
30+
val treeSectionHash +: otherSectionHashes = sections.map(x => pjwHash64(x._2.bytes))
31+
32+
// Hash of name table and tree
33+
val uuidLow: Long = nameBufferHash ^ treeSectionHash
34+
// Hash of positions, comments and any additional section
35+
val uuidHi: Long = otherSectionHashes.fold(0L)(_ ^ _)
3136

3237
val headerBuffer = {
3338
val buf = new TastyBuffer(header.length + 24)

0 commit comments

Comments
 (0)