Skip to content

Commit 62d310a

Browse files
authored
Switch to xxhash for tsbuildinfo hashing (#1511)
1 parent d9b8f4c commit 62d310a

27 files changed

+1002
-995
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ require (
77
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2
88
github.com/google/go-cmp v0.7.0
99
github.com/peter-evans/patience v0.3.0
10+
github.com/zeebo/xxh3 v1.0.2
1011
golang.org/x/sync v0.16.0
1112
golang.org/x/sys v0.34.0
1213
golang.org/x/text v0.27.0
1314
gotest.tools/v3 v3.5.2
1415
)
1516

1617
require (
18+
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
1719
github.com/matryer/moq v0.5.3 // indirect
1820
golang.org/x/mod v0.25.0 // indirect
1921
golang.org/x/tools v0.34.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7
66
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
77
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
88
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
9+
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
10+
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
911
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1012
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1113
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -18,6 +20,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1820
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1921
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
2022
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
23+
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
24+
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
25+
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
26+
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
2127
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
2228
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
2329
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=

internal/incremental/snapshot.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/hex"
66
"fmt"
7-
"hash/fnv"
87
"maps"
98
"strings"
109
"sync"
@@ -17,6 +16,7 @@ import (
1716
"github.com/microsoft/typescript-go/internal/diagnostics"
1817
"github.com/microsoft/typescript-go/internal/tsoptions"
1918
"github.com/microsoft/typescript-go/internal/tspath"
19+
"github.com/zeebo/xxh3"
2020
)
2121

2222
type fileInfo struct {
@@ -307,9 +307,8 @@ func diagnosticToStringBuilder(diagnostic *ast.Diagnostic, file *ast.SourceFile,
307307
}
308308

309309
func (s *snapshot) computeHash(text string) string {
310-
hasher := fnv.New128a()
311-
hasher.Write([]byte(text))
312-
hash := hex.EncodeToString(hasher.Sum(nil))
310+
hashBytes := xxh3.Hash128([]byte(text)).Bytes()
311+
hash := hex.EncodeToString(hashBytes[:])
313312
if s.hashWithText {
314313
hash += "-" + text
315314
}

testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field.js

Lines changed: 32 additions & 32 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/const-enums-aliased-in-different-file.js

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/const-enums-aliased.js

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

testdata/baselines/reference/tsc/incremental/const-enums.js

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)