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