36760ca9fd
The concurrent model for delivering tokens was fine for pedagogy, but has caused a few problems as the package has evolved (that is, got more complicated). It's easy to eliminate it, simplifying or removing some of the hacks used to work around these prolems. The old lexer would deliver tokens over a channel to the parsing goroutine, and continue running until EOF. In this rewrite, we instead run the machine until a token is ready, and shut it down until the next token is needed. The mechanism is just to return nil as the state function, which requires a bit more threading of return values through the state functions but is not difficult. The change is modest. A couple of error messages change, but otherwise the change has no external effect. This is just an internal cleanup, long overdue. benchmark old ns/op new ns/op delta BenchmarkParseLarge-20 12222729 6769966 -44.61% BenchmarkVariableString-20 73.5 73.4 -0.16% BenchmarkListString-20 1827 1841 +0.77% benchmark old allocs new allocs delta BenchmarkVariableString-20 3 3 +0.00% BenchmarkListString-20 31 31 +0.00% benchmark old bytes new bytes delta BenchmarkVariableString-20 72 72 +0.00% BenchmarkListString-20 1473 1473 +0.00% Fixes #53261 Change-Id: I4133bed2f8df16d398b707fb9509230325765c57 Reviewed-on: https://go-review.googlesource.com/c/go/+/421883 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Russ Cox <rsc@golang.org> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
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 3.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.