mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
Move hashmap creation to runtime
This commit is contained in:
@@ -42,6 +42,18 @@ func stringhash(s *string) uint32 {
|
||||
return result
|
||||
}
|
||||
|
||||
// Create a new hashmap with the given keySize and valueSize.
|
||||
func hashmapMake(keySize, valueSize uint8) *hashmap {
|
||||
bucketBufSize := unsafe.Sizeof(hashmapBucket{}) + uintptr(keySize)*8 + uintptr(valueSize)*8
|
||||
bucket := alloc(bucketBufSize)
|
||||
return &hashmap{
|
||||
buckets: bucket,
|
||||
keySize: keySize,
|
||||
valueSize: valueSize,
|
||||
bucketBits: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Set a specified key to a given value. Grow the map if necessary.
|
||||
func hashmapSet(m *hashmap, key string, value unsafe.Pointer) {
|
||||
hash := stringhash(&key)
|
||||
|
||||
Reference in New Issue
Block a user