compiler: implement operations on nil hashmaps

* comparing a map against nil
  * getting the length of a nil map
This commit is contained in:
Ayke van Laethem
2018-10-27 00:54:13 +02:00
parent c84fc6a670
commit 436901dc49
4 changed files with 31 additions and 7 deletions
+9
View File
@@ -71,6 +71,15 @@ func hashmapMake(keySize, valueSize uint8) *hashmap {
}
}
// Return the number of entries in this hashmap, called from the len builtin.
// A nil hashmap is defined as having length 0.
func hashmapLen(m *hashmap) int {
if m == nil {
return 0
}
return int(m.count)
}
// Set a specified key to a given value. Grow the map if necessary.
//go:nobounds
func hashmapSet(m *hashmap, key unsafe.Pointer, value unsafe.Pointer, hash uint32, keyEqual func(x, y unsafe.Pointer, n uintptr) bool) {