]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use a map to track const switch cases
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 6 Jun 2016 00:28:28 +0000 (17:28 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 23 Aug 2016 05:28:33 +0000 (05:28 +0000)
commite26499153e938b21850a7b6b33f27bb3d98e01cd
treea0bb353abe3d7d2f3f9e9103bf83e9e88c7131aa
parentb7ac426ee31cfe4464345754745e38bc0af02a66
cmd/compile: use a map to track const switch cases

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: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/swt.go
test/switch5.go