You need to sign in or sign up before continuing.
  • Matthew Dempsky's avatar
    cmd/compile: tweak OIF construction for binarySearch · 1b2c7948
    Matthew Dempsky authored
    When emitting base cases, previously we would emit:
    
        if c1 { s1 }
        if c2 { s2 }
        if c3 { s3 }
    
    With this CL, we instead emit:
    
        if c1 { s1 }
        else if c2 { s2 }
        else if c3 { s3 }
    
    Most of the time, this doesn't make a difference, because s1/s2/s3 are
    typically "goto" statements. But for type switches, we currently emit:
    
        if hash == 271 { if _, ok := iface.(T1); ok { goto t1case } }
        if hash == 314 { if _, ok := iface.(T2); ok { goto t2case } }
    
    That is, the if bodies can fallthrough, even though it's impossible
    for them to match any of the subsequent cases.
    
    Change-Id: I453d424d0b5e40060a703738bbb374523f1c403c
    Reviewed-on: https://go-review.googlesource.com/c/go/+/195339
    
    
    Run-TryBot: Matthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarKeith Randall <khr@golang.org>
    1b2c7948
swt.go 17.9 KB