]> Cypherpunks repositories - gostls13.git/commitdiff
container/vector: removed some uses of container/vector in other pkgs
authorJohn Asmuth <jasmuth@gmail.com>
Wed, 27 Jul 2011 22:23:42 +0000 (15:23 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 27 Jul 2011 22:23:42 +0000 (15:23 -0700)
R=gri
CC=golang-dev
https://golang.org/cl/4823054

src/pkg/crypto/x509/x509.go
src/pkg/http/request.go
src/pkg/json/decode.go
src/pkg/net/dict/dict.go
src/pkg/net/textproto/reader.go
src/pkg/websocket/client.go

index 348727a26e6e43eceb158f97535b0becdae5cf78..0add9e3c9d5799cb6f4b02447b39d40fc1b6c66f 100644 (file)
@@ -9,7 +9,6 @@ import (
        "asn1"
        "big"
        "bytes"
-       "container/vector"
        "crypto"
        "crypto/dsa"
        "crypto/rsa"
@@ -794,7 +793,7 @@ func ParseCertificate(asn1Data []byte) (*Certificate, os.Error) {
 // ParseCertificates parses one or more certificates from the given ASN.1 DER
 // data. The certificates must be concatenated with no intermediate padding.
 func ParseCertificates(asn1Data []byte) ([]*Certificate, os.Error) {
-       v := new(vector.Vector)
+       var v []interface{}
 
        for len(asn1Data) > 0 {
                cert := new(certificate)
@@ -803,12 +802,12 @@ func ParseCertificates(asn1Data []byte) ([]*Certificate, os.Error) {
                if err != nil {
                        return nil, err
                }
-               v.Push(cert)
+               v = append(v, cert)
        }
 
-       ret := make([]*Certificate, v.Len())
-       for i := 0; i < v.Len(); i++ {
-               cert, err := parseCertificate(v.At(i).(*certificate))
+       ret := make([]*Certificate, len(v))
+       for i := 0; i < len(v); i++ {
+               cert, err := parseCertificate(v[i].(*certificate))
                if err != nil {
                        return nil, err
                }
index 2917cc1e6e18d37d2f8b6eafabb9fd56dadab2f0..a1c98a1f8facf5983aeaac936c0f41be1cd5e438 100644 (file)
@@ -12,7 +12,6 @@ import (
        "bufio"
        "bytes"
        "crypto/tls"
-       "container/vector"
        "encoding/base64"
        "fmt"
        "io"
@@ -674,9 +673,7 @@ func parseQuery(m Values, query string) (err os.Error) {
                        err = e
                        continue
                }
-               vec := vector.StringVector(m[key])
-               vec.Push(value)
-               m[key] = vec
+               m[key] = append(m[key], value)
        }
        return err
 }
index 2edbbdafeeaf7708aa61b76217b1e4fd8c6e2d33..7d474fa7b9327044c76caa6c5285860ecf854e24 100644 (file)
@@ -8,7 +8,6 @@
 package json
 
 import (
-       "container/vector"
        "encoding/base64"
        "os"
        "reflect"
@@ -669,7 +668,7 @@ func (d *decodeState) valueInterface() interface{} {
 
 // arrayInterface is like array but returns []interface{}.
 func (d *decodeState) arrayInterface() []interface{} {
-       var v vector.Vector
+       var v []interface{}
        for {
                // Look ahead for ] - can only happen on first iteration.
                op := d.scanWhile(scanSkipSpace)
@@ -681,7 +680,7 @@ func (d *decodeState) arrayInterface() []interface{} {
                d.off--
                d.scan.undo(op)
 
-               v.Push(d.valueInterface())
+               v = append(v, d.valueInterface())
 
                // Next token must be , or ].
                op = d.scanWhile(scanSkipSpace)
index 42f6553ad33a383a6465c02a6fae1dfef3b5dfe7..b146ea2123c1982abe57b3a3356dfce3c148a0a2 100644 (file)
@@ -7,7 +7,6 @@
 package dict
 
 import (
-       "container/vector"
        "net/textproto"
        "os"
        "strconv"
@@ -144,7 +143,7 @@ func (c *Client) Define(dict, word string) ([]*Defn, os.Error) {
 // Fields are space separated unquoted words
 // or quoted with single or double quote.
 func fields(s string) ([]string, os.Error) {
-       var v vector.StringVector
+       var v []string
        i := 0
        for {
                for i < len(s) && (s[i] == ' ' || s[i] == '\t') {
@@ -170,7 +169,7 @@ func fields(s string) ([]string, os.Error) {
                                        break
                                }
                        }
-                       v.Push(unquote(s[i+1 : j-1]))
+                       v = append(v, unquote(s[i+1:j-1]))
                        i = j
                } else {
                        // atom
@@ -180,7 +179,7 @@ func fields(s string) ([]string, os.Error) {
                                        break
                                }
                        }
-                       v.Push(s[i:j])
+                       v = append(v, s[i:j])
                        i = j
                }
                if i < len(s) {
index 6031baa3bb2642b58afa990474f4e0f6d81223c6..ce0ddc73f8403a2583d7a5cc50b52904c6d0f2d4 100644 (file)
@@ -7,7 +7,6 @@ package textproto
 import (
        "bufio"
        "bytes"
-       "container/vector"
        "io"
        "io/ioutil"
        "os"
@@ -400,7 +399,7 @@ func (r *Reader) ReadDotLines() ([]string, os.Error) {
        // We could use ReadDotBytes and then Split it,
        // but reading a line at a time avoids needing a
        // large contiguous block of memory and is simpler.
-       var v vector.StringVector
+       var v []string
        var err os.Error
        for {
                var line string
@@ -419,7 +418,7 @@ func (r *Reader) ReadDotLines() ([]string, os.Error) {
                        }
                        line = line[1:]
                }
-               v.Push(line)
+               v = append(v, line)
        }
        return v, err
 }
@@ -466,9 +465,7 @@ func (r *Reader) ReadMIMEHeader() (MIMEHeader, os.Error) {
                }
                value := string(kv[i:])
 
-               v := vector.StringVector(m[key])
-               v.Push(value)
-               m[key] = v
+               m[key] = append(m[key], value)
 
                if err != nil {
                        return m, err
index f066a183205a3992c609fc3e1ba6c5c74e62a57f..f24c463608c191e2374e0f0d47e3a1cf04caaf5b 100644 (file)
@@ -7,7 +7,6 @@ package websocket
 import (
        "bufio"
        "bytes"
-       "container/vector"
        "crypto/tls"
        "fmt"
        "http"
@@ -201,21 +200,21 @@ func handshake(resourceName, host, origin, location, protocol string, br *bufio.
        bw.WriteString("GET " + resourceName + " HTTP/1.1\r\n")
 
        // Step 6-14. push request headers in fields.
-       var fields vector.StringVector
-       fields.Push("Upgrade: WebSocket\r\n")
-       fields.Push("Connection: Upgrade\r\n")
-       fields.Push("Host: " + host + "\r\n")
-       fields.Push("Origin: " + origin + "\r\n")
+       var fields []string
+       fields = append(fields, "Upgrade: WebSocket\r\n")
+       fields = append(fields, "Connection: Upgrade\r\n")
+       fields = append(fields, "Host: "+host+"\r\n")
+       fields = append(fields, "Origin: "+origin+"\r\n")
        if protocol != "" {
-               fields.Push("Sec-WebSocket-Protocol: " + protocol + "\r\n")
+               fields = append(fields, "Sec-WebSocket-Protocol: "+protocol+"\r\n")
        }
        // TODO(ukai): Step 15. send cookie if any.
 
        // Step 16-23. generate keys and push Sec-WebSocket-Key<n> in fields.
        key1, number1 := generateKeyNumber()
        key2, number2 := generateKeyNumber()
-       fields.Push("Sec-WebSocket-Key1: " + key1 + "\r\n")
-       fields.Push("Sec-WebSocket-Key2: " + key2 + "\r\n")
+       fields = append(fields, "Sec-WebSocket-Key1: "+key1+"\r\n")
+       fields = append(fields, "Sec-WebSocket-Key2: "+key2+"\r\n")
 
        // Step 24. shuffle fields and send them out.
        for i := 1; i < len(fields); i++ {