Allows mapclear optimization to trigger in more cases, including
some generic instantiations.
Fixes #51699
Change-Id: Ic54f7686e5fcb8fbcad640aa77ed326d7338b938
Reviewed-on: https://go-review.googlesource.com/c/go/+/393434
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
// lvalue expression is for OSLICE and OAPPEND optimizations, and it
// is correct in those settings.
func SameSafeExpr(l Node, r Node) bool {
+ for l.Op() == OCONVNOP {
+ l = l.(*ConvExpr).X
+ }
+ for r.Op() == OCONVNOP {
+ r = r.(*ConvExpr).X
+ }
if l.Op() != r.Op() || !types.Identical(l.Type(), r.Type()) {
return false
}
r := r.(*UnaryExpr)
return SameSafeExpr(l.X, r.X)
- case OCONVNOP:
- l := l.(*ConvExpr)
- r := r.(*ConvExpr)
- return SameSafeExpr(l.X, r.X)
-
case OCONV:
l := l.(*ConvExpr)
r := r.(*ConvExpr)