index/suffixarray: revert change from int -> int32
CL 5040041 (https://golang.org/cl/5040041)
changed the use of []int to []int32 internally so
that encoding/binary could be used. This is no
longer needed (gobs can encode ints), and using
[]int is more in sync w/ the semantics of the data
structure (the index elements are indices which are
ints). Changing it back.
R=r
CC=golang-dev
https://golang.org/cl/5141049
diff --git a/src/pkg/index/suffixarray/suffixarray.go b/src/pkg/index/suffixarray/suffixarray.go
index 4747ba9..05b06c6 100644
--- a/src/pkg/index/suffixarray/suffixarray.go
+++ b/src/pkg/index/suffixarray/suffixarray.go
@@ -28,7 +28,7 @@
// Index implements a suffix array for fast substring search.
type Index struct {
data []byte
- sa []int32 // suffix array for data; len(sa) == len(data)
+ sa []int // suffix array for data; len(sa) == len(data)
}
// New creates a new Index for data.
@@ -52,7 +52,7 @@
// new data is significantly smaller or larger then
// existing buffers - allocate new ones
x.data = make([]byte, n)
- x.sa = make([]int32, n)
+ x.sa = make([]int, n)
} else {
// re-use existing buffers
x.data = x.data[0:n]
@@ -120,7 +120,7 @@
// lookupAll returns a slice into the matching region of the index.
// The runtime is O(log(N)*len(s)).
-func (x *Index) lookupAll(s []byte) []int32 {
+func (x *Index) lookupAll(s []byte) []int {
// find matching suffix index range [i:j]
// find the first index where s would be the prefix
i := sort.Search(len(x.sa), func(i int) bool { return bytes.Compare(x.at(i), s) >= 0 })
@@ -144,9 +144,7 @@
// 0 <= n <= len(matches)
if n > 0 {
result = make([]int, n)
- for i, x := range matches[0:n] {
- result[i] = int(x)
- }
+ copy(result, matches)
}
}
return