c2b1463153
Currently ordering.Advance is one massive switch statement. This isn't amazing for readability because it's hard to see at a glance what happens before and after. Some of the state sharing is nice, but otherwise, it can get confusing quickly (especially where break is used, and where there are nested switches). This CL breaks up the switch statement into individual methods on ordering.Advance which are loaded and dispatched from a table. This CL uses a table instead of a switch statement because the arguments passed are all the same each time, and the table can provide a very precise mapping for each event; with a switch, we'd be tempted to group cases that call the same handler method together. It also prevents us from using defer in many cases, which may help clean up the code. (Each case in the switch is completely self-contained, yet we can't use a defer because it's function-scoped.) As an aside, this should also improve performance a bit. The Go compiler doesn't handle massive irregular functions very well, especially one with a lot of return points and (previously) a conditionally deferred call. Change-Id: I3ef2cf75301c795b6f23da1e058b0ac303fea8bd Reviewed-on: https://go-review.googlesource.com/c/go/+/566576 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
go.env | ||
LICENSE | ||
PATENTS | ||
README.md | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.