Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(287)

Issue 5532076: code review 5532076: go/scanner: 17% faster scanning (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 9 months ago by gri
Modified:
13 years, 9 months ago
Reviewers:
CC:
golang-dev, rsc
Visibility:
Public.

Description

go/scanner: 17% faster scanning - Changed the Scan API semantics slightly: The token literal string is only returned if the token is a literal, comment, semicolon, or illegal character. In all other cases, the token literal value is determined by the token value. Clients that care about the token literal value when not present can always use the following piece of code: pos, tok, lit := scanner.Scan() if lit == "" { lit = tok.String() } - Changed token.Lookup API to use a string instead of a []byte argument. - Both these changes were long-standing TODOs. - Added BenchmarkScan. This change permits a faster implementation of Scan with much fewer string creations: benchmark old ns/op new ns/op delta scanner.BenchmarkScan 74404 61457 -17.40%

Patch Set 1 #

Patch Set 2 : diff -r e287fecf68dc https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r e287fecf68dc https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r e287fecf68dc https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r e287fecf68dc https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r e287fecf68dc https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+110 lines, -67 lines) Patch
M src/cmd/cgo/gcc.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/scanner/scanner.go View 1 2 3 16 chunks +72 lines, -53 lines 0 comments Download
M src/pkg/go/scanner/scanner_test.go View 1 2 3 chunks +32 lines, -6 lines 0 comments Download
M src/pkg/go/token/token.go View 1 2 chunks +5 lines, -7 lines 0 comments Download

Messages

Total messages: 3
gri
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 9 months ago (2012-01-11 22:10:42 UTC) #1
rsc
LGTM
13 years, 9 months ago (2012-01-11 22:14:59 UTC) #2
gri
13 years, 9 months ago (2012-01-11 22:20:37 UTC) #3
*** Submitted as http://code.google.com/p/go/source/detail?r=af2cb1911e0e ***

go/scanner: 17% faster scanning

- Changed the Scan API semantics slightly:
The token literal string is only returned
if the token is a literal, comment, semicolon,
or illegal character. In all other cases, the
token literal value is determined by the token
value.

Clients that care about the token literal value
when not present can always use the following
piece of code:

pos, tok, lit := scanner.Scan()
if lit == "" {
   lit = tok.String()
}

- Changed token.Lookup API to use a string instead
of a []byte argument.

- Both these changes were long-standing TODOs.

- Added BenchmarkScan.

This change permits a faster implementation of Scan
with much fewer string creations:

benchmark                old ns/op    new ns/op    delta
scanner.BenchmarkScan        74404        61457  -17.40%

R=golang-dev, rsc
CC=golang-dev
http://codereview.appspot.com/5532076
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b