Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: constant indexing into map literals should be folded #10848
This code from internal/syscall/unix/getrandom_linux.go:
currently compiles into non-trivial chunk of code. However, gc could instead recognize that runtime.GOARCH and all of the map literal keys are constants and that all of the value expressions are side-effect free, and fold to just the corresponding value expression.
It looks like changing the code to:
produces simpler code by taking advantage of the existing switch constant folding logic, but still needs a dynamic initializer.
Alternatively, we could just create 4 extra files and use +build rules. (This is my preference if no one's opposed.)
added a commit
Nov 5, 2015
pushed a commit
Mar 21, 2016
Indeed. That map thing is a terrible idiom and should not be encouraged.
On Mon, Mar 21, 2016 at 4:01 AM GopherBot email@example.com wrote: