diff options
| author | Kyle Consalus <consalus@gmail.com> | 2010-12-01 11:59:13 -0800 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2010-12-01 11:59:13 -0800 |
| commit | 009aebdba8f35fb8609635520c58f76742e46996 (patch) | |
| tree | d7eaa78e28e41ba52ca5e3a7f2d8924565e265b5 /src/pkg/bytes/bytes.go | |
| parent | 1f90447e3148d05dd093dbf4d36d919269d50390 (diff) | |
| download | go-009aebdba8f35fb8609635520c58f76742e46996.tar.xz | |
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
https://golang.org/cl/3302042
Diffstat (limited to 'src/pkg/bytes/bytes.go')
| -rw-r--r-- | src/pkg/bytes/bytes.go | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go index d0749870eb..c0937ca300 100644 --- a/src/pkg/bytes/bytes.go +++ b/src/pkg/bytes/bytes.go @@ -552,48 +552,6 @@ func TrimSpace(s []byte) []byte { return TrimFunc(s, unicode.IsSpace) } -// How big to make a byte array when growing. -// Heuristic: Scale by 50% to give n log n time. -func resize(n int) int { - if n < 16 { - n = 16 - } - return n + n/2 -} - -// Add appends the contents of t to the end of s and returns the result. -// If s has enough capacity, it is extended in place; otherwise a -// new array is allocated and returned. -func Add(s, t []byte) []byte { // TODO - lens := len(s) - lent := len(t) - if lens+lent <= cap(s) { - s = s[0 : lens+lent] - } else { - news := make([]byte, lens+lent, resize(lens+lent)) - copy(news, s) - s = news - } - copy(s[lens:lens+lent], t) - return s -} - -// AddByte appends byte t to the end of s and returns the result. -// If s has enough capacity, it is extended in place; otherwise a -// new array is allocated and returned. -func AddByte(s []byte, t byte) []byte { // TODO - lens := len(s) - if lens+1 <= cap(s) { - s = s[0 : lens+1] - } else { - news := make([]byte, lens+1, resize(lens+1)) - copy(news, s) - s = news - } - s[lens] = t - return s -} - // Runes returns a slice of runes (Unicode code points) equivalent to s. func Runes(s []byte) []int { t := make([]int, utf8.RuneCount(s)) |
