mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
all: use unsafe.Add instead of unsafe.Pointer(uintptr(...) + ...)
We have an optimization for this specific pattern, but it's really just a hack. With the addition of unsafe.Add in Go 1.17 we can directly specify the intent instead and eventually remove this special case. The code is also easier to read.
This commit is contained in:
committed by
Ron Evans
parent
d98c0afbab
commit
4ec1e58aa6
@@ -57,8 +57,8 @@ func malloc(size uintptr) unsafe.Pointer
|
||||
// Compare two same-size buffers for equality.
|
||||
func memequal(x, y unsafe.Pointer, n uintptr) bool {
|
||||
for i := uintptr(0); i < n; i++ {
|
||||
cx := *(*uint8)(unsafe.Pointer(uintptr(x) + i))
|
||||
cy := *(*uint8)(unsafe.Pointer(uintptr(y) + i))
|
||||
cx := *(*uint8)(unsafe.Add(x, i))
|
||||
cy := *(*uint8)(unsafe.Add(y, i))
|
||||
if cx != cy {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user