diff options
author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
commit | 3743fa38e180c74c51aae84eda082067e8e12523 (patch) | |
tree | 274d1d9bf832b7834ab60c65acdf945576271d14 /test/bench/regex-dna.go | |
parent | 13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (diff) | |
download | golang-3743fa38e180c74c51aae84eda082067e8e12523.tar.gz |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
5th and last set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180050
Diffstat (limited to 'test/bench/regex-dna.go')
-rw-r--r-- | test/bench/regex-dna.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/test/bench/regex-dna.go b/test/bench/regex-dna.go index 2e1ab8edb..9d56830b3 100644 --- a/test/bench/regex-dna.go +++ b/test/bench/regex-dna.go @@ -36,11 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. package main import ( - "fmt"; - "io/ioutil"; - "os"; - "regexp"; - "strings"; + "fmt" + "io/ioutil" + "os" + "regexp" + "strings" ) var variants = []string{ @@ -56,7 +56,7 @@ var variants = []string{ } type Subst struct { - pat, repl string; + pat, repl string } var substs = []Subst{ @@ -74,34 +74,34 @@ var substs = []Subst{ } func countMatches(pat string, bytes []byte) int { - re := regexp.MustCompile(pat); - n := 0; + re := regexp.MustCompile(pat) + n := 0 for { - e := re.Execute(bytes); + e := re.Execute(bytes) if len(e) == 0 { break } - n++; - bytes = bytes[e[1]:]; + n++ + bytes = bytes[e[1]:] } - return n; + return n } func main() { - bytes, err := ioutil.ReadFile("/dev/stdin"); + bytes, err := ioutil.ReadFile("/dev/stdin") if err != nil { - fmt.Fprintf(os.Stderr, "can't read input: %s\n", err); - os.Exit(2); + fmt.Fprintf(os.Stderr, "can't read input: %s\n", err) + os.Exit(2) } - ilen := len(bytes); + ilen := len(bytes) // Delete the comment lines and newlines - bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}); - clen := len(bytes); + bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}) + clen := len(bytes) for _, s := range variants { fmt.Printf("%s %d\n", s, countMatches(s, bytes)) } for _, sub := range substs { bytes = regexp.MustCompile(sub.pat).ReplaceAll(bytes, strings.Bytes(sub.repl)) } - fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes)); + fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes)) } |