github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/compiler/natives/src/crypto/internal/subtle/aliasing.go (about) 1 // +build js 2 3 package subtle 4 5 import "github.com/gopherjs/gopherjs/js" 6 7 // AnyOverlap reports whether x and y share memory at any (not necessarily 8 // corresponding) index. The memory beyond the slice length is ignored. 9 func AnyOverlap(x, y []byte) bool { 10 // GopherJS: We can't rely on pointer arithmetic, so use GopherJS slice internals. 11 return len(x) > 0 && len(y) > 0 && 12 js.InternalObject(x).Get("$array") == js.InternalObject(y).Get("$array") && 13 js.InternalObject(x).Get("$offset").Int() <= js.InternalObject(y).Get("$offset").Int()+len(y)-1 && 14 js.InternalObject(y).Get("$offset").Int() <= js.InternalObject(x).Get("$offset").Int()+len(x)-1 15 }