Commit 476150f4 authored by Kyle Consalus's avatar Kyle Consalus Committed by Robert Griesemer

crypto/x509, go/scanner, index/suffixarray: Removed []interface{}/vector uses.

Changed some []interface{} uses to slices of the concrete types; removed use of IntVector.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/4810085
parent 5987a4ad
...@@ -793,7 +793,7 @@ func ParseCertificate(asn1Data []byte) (*Certificate, os.Error) { ...@@ -793,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) {
var v []interface{} var v []*certificate
for len(asn1Data) > 0 { for len(asn1Data) > 0 {
cert := new(certificate) cert := new(certificate)
...@@ -806,8 +806,8 @@ func ParseCertificates(asn1Data []byte) ([]*Certificate, os.Error) { ...@@ -806,8 +806,8 @@ func ParseCertificates(asn1Data []byte) ([]*Certificate, os.Error) {
} }
ret := make([]*Certificate, len(v)) ret := make([]*Certificate, len(v))
for i := 0; i < len(v); i++ { for i, ci := range v {
cert, err := parseCertificate(v[i].(*certificate)) cert, err := parseCertificate(ci)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -31,18 +31,14 @@ type ErrorHandler interface { ...@@ -31,18 +31,14 @@ type ErrorHandler interface {
// error handling is obtained. // error handling is obtained.
// //
type ErrorVector struct { type ErrorVector struct {
errors []interface{} errors []*Error
} }
// Reset resets an ErrorVector to no errors. // Reset resets an ErrorVector to no errors.
func (h *ErrorVector) Reset() { func (h *ErrorVector) Reset() { h.errors = h.errors[:0] }
h.errors = h.errors[:0]
}
// ErrorCount returns the number of errors collected. // ErrorCount returns the number of errors collected.
func (h *ErrorVector) ErrorCount() int { func (h *ErrorVector) ErrorCount() int { return len(h.errors) }
return len(h.errors)
}
// Within ErrorVector, an error is represented by an Error node. The // Within ErrorVector, an error is represented by an Error node. The
// position Pos, if valid, points to the beginning of the offending // position Pos, if valid, points to the beginning of the offending
...@@ -118,9 +114,7 @@ func (h *ErrorVector) GetErrorList(mode int) ErrorList { ...@@ -118,9 +114,7 @@ func (h *ErrorVector) GetErrorList(mode int) ErrorList {
} }
list := make(ErrorList, len(h.errors)) list := make(ErrorList, len(h.errors))
for i := 0; i < len(h.errors); i++ { copy(list, h.errors)
list[i] = h.errors[i].(*Error)
}
if mode >= Sorted { if mode >= Sorted {
sort.Sort(list) sort.Sort(list)
......
...@@ -6,7 +6,6 @@ package suffixarray ...@@ -6,7 +6,6 @@ package suffixarray
import ( import (
"bytes" "bytes"
"container/vector"
"regexp" "regexp"
"sort" "sort"
"strings" "strings"
...@@ -107,7 +106,7 @@ var testCases = []testCase{ ...@@ -107,7 +106,7 @@ var testCases = []testCase{
// find all occurrences of s in source; report at most n occurrences // find all occurrences of s in source; report at most n occurrences
func find(src, s string, n int) []int { func find(src, s string, n int) []int {
var res vector.IntVector var res []int
if s != "" && n != 0 { if s != "" && n != 0 {
// find at most n occurrences of s in src // find at most n occurrences of s in src
for i := -1; n < 0 || len(res) < n; { for i := -1; n < 0 || len(res) < n; {
...@@ -116,7 +115,7 @@ func find(src, s string, n int) []int { ...@@ -116,7 +115,7 @@ func find(src, s string, n int) []int {
break break
} }
i += j + 1 i += j + 1
res.Push(i) res = append(res, i)
} }
} }
return res return res
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment