Skip to content

Commit

Permalink
forbid golang.org/x/exp/maps.Keys/Values, because they have nondeterm…
Browse files Browse the repository at this point in the history
…inistic results
  • Loading branch information
turbolent committed May 29, 2023
1 parent 326312c commit c09c6d7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ linters:
- goimports
- unconvert
- nilerr
- forbidigo
- bidichk
- asciicheck

issues:
exclude-rules:
Expand All @@ -38,6 +41,10 @@ linters-settings:
- exitAfterDefer
goimports:
local-prefixes: github.com/onflow/cadence
forbidigo:
forbid:
- '^maps.Keys.*(# has indeterminate order\.)?$'
- '^maps.Values.*(# has indeterminate order\.)?$'
custom:
maprange:
path: tools/maprange/maprange.so
Expand Down
2 changes: 1 addition & 1 deletion runtime/cmd/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func main() {
}

type benchResult struct {
// N is the the number of iterations
// N is the number of iterations
Iterations int `json:"iterations"`
// T is the total time taken
Time time.Duration `json:"time"`
Expand Down
2 changes: 1 addition & 1 deletion runtime/cmd/parse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func main() {
}

type benchResult struct {
// N is the the number of iterations
// N is the number of iterations
Iterations int `json:"iterations"`
// T is the total time taken
Time time.Duration `json:"time"`
Expand Down
4 changes: 2 additions & 2 deletions runtime/stdlib/rlp/rlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ func ReadSize(inp []byte, startIndex int) (isString bool, dataStartIndex, dataSi
var bytesToReadForLen uint
// long string mode (55+ long strings)
// firstByte minus the end range of short string, returns the number of bytes to read
// for calculating the the len of data. bytesToReadForlen is at least 1 and at most 8.
// for calculating the len of data. bytesToReadForlen is at least 1 and at most 8.
if firstByte >= LongStringRangeStart && firstByte <= LongStringRangeEnd {
bytesToReadForLen = uint(firstByte - ShortStringRangeEnd)
isString = true
}

// long list mode
// firstByte minus the end range of short list, returns the number of bytes to read
// for calculating the the len of data. bytesToReadForlen is at least 1 and at most 8.
// for calculating the len of data. bytesToReadForlen is at least 1 and at most 8.
if firstByte >= LongListRangeStart {
bytesToReadForLen = uint(firstByte - ShortListRangeEnd)
isString = false
Expand Down

0 comments on commit c09c6d7

Please sign in to comment.