github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/compiler/natives/src/golang.org/x/crypto/internal/subtle/aliasing.go (about) 1 //go:build js 2 // +build js 3 4 package subtle 5 6 // This file duplicated is these two locations: 7 // - src/crypto/internal/subtle/aliasing.go 8 // - src/golang.org/x/crypto/internal/subtle/aliasing.go 9 // - src/golang.org/x/crypto/internal/alias/alias.go 10 11 import "github.com/gopherjs/gopherjs/js" 12 13 // AnyOverlap reports whether x and y share memory at any (not necessarily 14 // corresponding) index. The memory beyond the slice length is ignored. 15 func AnyOverlap(x, y []byte) bool { 16 // GopherJS: We can't rely on pointer arithmetic, so use GopherJS slice internals. 17 return len(x) > 0 && len(y) > 0 && 18 js.InternalObject(x).Get("$array") == js.InternalObject(y).Get("$array") && 19 js.InternalObject(x).Get("$offset").Int() <= js.InternalObject(y).Get("$offset").Int()+len(y)-1 && 20 js.InternalObject(y).Get("$offset").Int() <= js.InternalObject(x).Get("$offset").Int()+len(x)-1 21 }