• Josh Bleecher Snyder's avatar
    cmd/compile: use a map to track const switch cases · e2649915
    Josh Bleecher Snyder authored
    This is simpler than the sorting technique.
    It also allows us to simplify or eliminate
    some of the sorting decisions.
    
    Most important, sorting will not work when case clauses
    represent ranges of integers: There is no correct
    sort order that allows overlap detection by comparing
    neighbors. Using a map allows of a cheap, simple
    approach to ranges, namely to insert every int
    in the map. The equivalent approach for sorting
    means juggling temporary Nodes for every int,
    which is a lot more expensive.
    
    Change-Id: I84df3cb805992a1b04d14e0e4b2334f943e0ce05
    Reviewed-on: https://go-review.googlesource.com/26766
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    e2649915
const.go 33.1 KB