1// +build js 2 3package subtle 4 5import "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. 9func 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} 16