diff options
| author | chanxuehong <chanxuehong@gmail.com> | 2022-02-21 08:51:05 +0000 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2022-03-02 11:28:40 +0000 |
| commit | bebe9aa42322f951fc3972c263648297bf9e04d4 (patch) | |
| tree | 658e3742ed9c6cb4e654f0fadaec96953cbdd5b3 /src/encoding/binary/binary.go | |
| parent | 9f1239b90a7a48c5dc68a7eee08d8e1fba56db80 (diff) | |
| download | go-bebe9aa42322f951fc3972c263648297bf9e04d4.tar.xz | |
go/token: slight performance improvement for IsIdentifier
If name is empty or a keyword, we can skip the loop entirely.
Otherwise, we do the same amount of work as before.
Here is the benchmark result for go/parser:
name old time/op new time/op delta
Parse-12 2.53ms ± 2% 2.47ms ± 1% -2.38% (p=0.000 n=9+10)
ParseOnly-12 1.97ms ± 1% 1.93ms ± 2% -1.80% (p=0.000 n=10+10)
Resolve-12 560µs ± 1% 558µs ± 1% ~ (p=0.200 n=9+8)
name old speed new speed delta
Parse-12 26.1MB/s ± 2% 26.8MB/s ± 1% +2.44% (p=0.000 n=9+10)
ParseOnly-12 33.6MB/s ± 1% 34.3MB/s ± 2% +1.82% (p=0.000 n=10+10)
Resolve-12 118MB/s ± 2% 119MB/s ± 1% ~ (p=0.116 n=10+8)
Change-Id: I87ac9c2637a6c0e697382b74245ac88ef523bba7
GitHub-Last-Rev: 036bc38d837c095dd5a8d97ece83e1596d875d3e
GitHub-Pull-Request: golang/go#48534
Reviewed-on: https://go-review.googlesource.com/c/go/+/351389
Trust: David Chase <drchase@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/encoding/binary/binary.go')
0 files changed, 0 insertions, 0 deletions
