mirror of
https://github.com/golang/go
synced 2024-09-28 19:24:29 -06:00
index/suffixarray: use built-in clear to simplify code
"sais2.go" is regenerated by the command "go generate ./...".
Change-Id: I4307e9fa1f20ea59e3a0d4841dbb22e9cffefa5a
GitHub-Last-Rev: d285183e65
GitHub-Pull-Request: golang/go#66376
Reviewed-on: https://go-review.googlesource.com/c/go/+/572198
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
190d0d3e69
commit
1e9875caee
@ -219,9 +219,7 @@ func freq_8_32(text []byte, freq, bucket []int32) []int32 {
|
||||
}
|
||||
|
||||
freq = freq[:256] // eliminate bounds check for freq[c] below
|
||||
for i := range freq {
|
||||
freq[i] = 0
|
||||
}
|
||||
clear(freq)
|
||||
for _, c := range text {
|
||||
freq[c]++
|
||||
}
|
||||
@ -710,9 +708,7 @@ func recurse_32(sa, oldTmp []int32, numLMS, maxID int) {
|
||||
// sais_32 requires that the caller arrange to clear dst,
|
||||
// because in general the caller may know dst is
|
||||
// freshly-allocated and already cleared. But this one is not.
|
||||
for i := range dst {
|
||||
dst[i] = 0
|
||||
}
|
||||
clear(dst)
|
||||
sais_32(text, maxID, dst, tmp)
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ func text_64(text []byte, sa []int64) {
|
||||
}
|
||||
|
||||
func sais_8_64(text []byte, textMax int, sa, tmp []int64) {
|
||||
if len(sa) != len(text) || len(tmp) < int(textMax) {
|
||||
if len(sa) != len(text) || len(tmp) < textMax {
|
||||
panic("suffixarray: misuse of sais_8_64")
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func sais_8_64(text []byte, textMax int, sa, tmp []int64) {
|
||||
}
|
||||
|
||||
func sais_32(text []int32, textMax int, sa, tmp []int32) {
|
||||
if len(sa) != len(text) || len(tmp) < int(textMax) {
|
||||
if len(sa) != len(text) || len(tmp) < textMax {
|
||||
panic("suffixarray: misuse of sais_32")
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ func sais_32(text []int32, textMax int, sa, tmp []int32) {
|
||||
}
|
||||
|
||||
func sais_64(text []int64, textMax int, sa, tmp []int64) {
|
||||
if len(sa) != len(text) || len(tmp) < int(textMax) {
|
||||
if len(sa) != len(text) || len(tmp) < textMax {
|
||||
panic("suffixarray: misuse of sais_64")
|
||||
}
|
||||
|
||||
@ -208,9 +208,7 @@ func freq_8_64(text []byte, freq, bucket []int64) []int64 {
|
||||
}
|
||||
|
||||
freq = freq[:256] // eliminate bounds check for freq[c] below
|
||||
for i := range freq {
|
||||
freq[i] = 0
|
||||
}
|
||||
clear(freq)
|
||||
for _, c := range text {
|
||||
freq[c]++
|
||||
}
|
||||
@ -225,9 +223,7 @@ func freq_32(text []int32, freq, bucket []int32) []int32 {
|
||||
freq = bucket
|
||||
}
|
||||
|
||||
for i := range freq {
|
||||
freq[i] = 0
|
||||
}
|
||||
clear(freq)
|
||||
for _, c := range text {
|
||||
freq[c]++
|
||||
}
|
||||
@ -242,9 +238,7 @@ func freq_64(text []int64, freq, bucket []int64) []int64 {
|
||||
freq = bucket
|
||||
}
|
||||
|
||||
for i := range freq {
|
||||
freq[i] = 0
|
||||
}
|
||||
clear(freq)
|
||||
for _, c := range text {
|
||||
freq[c]++
|
||||
}
|
||||
@ -1248,9 +1242,7 @@ func recurse_64(sa, oldTmp []int64, numLMS, maxID int) {
|
||||
// sais_64 requires that the caller arrange to clear dst,
|
||||
// because in general the caller may know dst is
|
||||
// freshly-allocated and already cleared. But this one is not.
|
||||
for i := range dst {
|
||||
dst[i] = 0
|
||||
}
|
||||
clear(dst)
|
||||
sais_64(text, maxID, dst, tmp)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user