Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starlark: update go.mod to drop go1.18 support #529

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x]
go-version: [1.19.x, 1.20.x, 1.21.x, 1.22.x]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.starlark.net

go 1.18
go 1.19

require (
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
Expand Down
12 changes: 5 additions & 7 deletions starlark/hashtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package starlark

import (
"fmt"
"hash/maphash"
"math/big"
_ "unsafe" // for go:linkname hack
)

// hashtable is used to represent Starlark dict and set values.
Expand Down Expand Up @@ -416,21 +416,19 @@ func (it *keyIterator) Done() {
}
}

// TODO(adonovan): use go1.19's maphash.String.
var seed = maphash.MakeSeed()

// hashString computes the hash of s.
func hashString(s string) uint32 {
if len(s) >= 12 {
// Call the Go runtime's optimized hash implementation,
// which uses the AESENC instruction on amd64 machines.
return uint32(goStringHash(s, 0))
// which uses the AES instructions on amd64 and arm64 machines.
h := maphash.String(seed, s)
return uint32(h>>32) | uint32(h)
}
return softHashString(s)
}

//go:linkname goStringHash runtime.stringHash
func goStringHash(s string, seed uintptr) uintptr

// softHashString computes the 32-bit FNV-1a hash of s in software.
func softHashString(s string) uint32 {
var h uint32 = 2166136261
Expand Down
Loading