diff options
author | Kyle Consalus <consalus@gmail.com> | 2010-12-01 11:59:13 -0800 |
---|---|---|
committer | Kyle Consalus <consalus@gmail.com> | 2010-12-01 11:59:13 -0800 |
commit | b9d484c56197af603a6b1d373765bfaf10fb283d (patch) | |
tree | 662d594dcc577ae6827ae3a7e3551f36b54e28cd /test/bench | |
parent | c4dc344e0b1af1a5e4e6ce42698c016cc672d7c8 (diff) | |
download | go-b9d484c56197af603a6b1d373765bfaf10fb283d.tar.gz |
Removed bytes.Add and bytes.AddByte; we now have 'append'.
Changed all uses of bytes.Add (aside from those testing bytes.Add) to append(a, b...).
Also ran "gofmt -s" and made use of copy([]byte, string) in the fasta benchmark.
R=golang-dev, r, r2
CC=golang-dev
http://codereview.appspot.com/3302042
Committer: Rob Pike <r@golang.org>
Diffstat (limited to 'test/bench')
-rw-r--r-- | test/bench/fasta.go | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/test/bench/fasta.go b/test/bench/fasta.go index 470bdb328..d13edd5dc 100644 --- a/test/bench/fasta.go +++ b/test/bench/fasta.go @@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE. package main import ( - "bytes" "flag" "os" ) @@ -49,7 +48,7 @@ var n = flag.Int("n", 1000, "length of result") const Line = 60 func Repeat(alu []byte, n int) { - buf := bytes.Add(alu, alu) + buf := append(alu, alu...) off := 0 for n > 0 { m := n @@ -138,28 +137,28 @@ func main() { flag.Parse() iub := []Acid{ - Acid{prob: 0.27, sym: 'a'}, - Acid{prob: 0.12, sym: 'c'}, - Acid{prob: 0.12, sym: 'g'}, - Acid{prob: 0.27, sym: 't'}, - Acid{prob: 0.02, sym: 'B'}, - Acid{prob: 0.02, sym: 'D'}, - Acid{prob: 0.02, sym: 'H'}, - Acid{prob: 0.02, sym: 'K'}, - Acid{prob: 0.02, sym: 'M'}, - Acid{prob: 0.02, sym: 'N'}, - Acid{prob: 0.02, sym: 'R'}, - Acid{prob: 0.02, sym: 'S'}, - Acid{prob: 0.02, sym: 'V'}, - Acid{prob: 0.02, sym: 'W'}, - Acid{prob: 0.02, sym: 'Y'}, + {prob: 0.27, sym: 'a'}, + {prob: 0.12, sym: 'c'}, + {prob: 0.12, sym: 'g'}, + {prob: 0.27, sym: 't'}, + {prob: 0.02, sym: 'B'}, + {prob: 0.02, sym: 'D'}, + {prob: 0.02, sym: 'H'}, + {prob: 0.02, sym: 'K'}, + {prob: 0.02, sym: 'M'}, + {prob: 0.02, sym: 'N'}, + {prob: 0.02, sym: 'R'}, + {prob: 0.02, sym: 'S'}, + {prob: 0.02, sym: 'V'}, + {prob: 0.02, sym: 'W'}, + {prob: 0.02, sym: 'Y'}, } homosapiens := []Acid{ - Acid{prob: 0.3029549426680, sym: 'a'}, - Acid{prob: 0.1979883004921, sym: 'c'}, - Acid{prob: 0.1975473066391, sym: 'g'}, - Acid{prob: 0.3015094502008, sym: 't'}, + {prob: 0.3029549426680, sym: 'a'}, + {prob: 0.1979883004921, sym: 'c'}, + {prob: 0.1975473066391, sym: 'g'}, + {prob: 0.3015094502008, sym: 't'}, } alu := []byte( @@ -192,9 +191,7 @@ func (b *buffer) Flush() { func (b *buffer) WriteString(s string) { p := b.NextWrite(len(s)) - for i := 0; i < len(s); i++ { - p[i] = s[i] - } + copy(p, s) } func (b *buffer) NextWrite(n int) []byte { @@ -204,6 +201,6 @@ func (b *buffer) NextWrite(n int) []byte { p = *b } out := p[len(p) : len(p)+n] - *b = p[0 : len(p)+n] + *b = p[:len(p)+n] return out } |