Skip to content

Commit 1e9875c

Browse files
apocelipesgopherbot
authored andcommitted
index/suffixarray: use built-in clear to simplify code
"sais2.go" is regenerated by the command "go generate ./...". Change-Id: I4307e9fa1f20ea59e3a0d4841dbb22e9cffefa5a GitHub-Last-Rev: d285183 GitHub-Pull-Request: #66376 Reviewed-on: https://go-review.googlesource.com/c/go/+/572198 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: David Chase <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]>
1 parent 190d0d3 commit 1e9875c

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

src/index/suffixarray/sais.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ func freq_8_32(text []byte, freq, bucket []int32) []int32 {
219219
}
220220

221221
freq = freq[:256] // eliminate bounds check for freq[c] below
222-
for i := range freq {
223-
freq[i] = 0
224-
}
222+
clear(freq)
225223
for _, c := range text {
226224
freq[c]++
227225
}
@@ -710,9 +708,7 @@ func recurse_32(sa, oldTmp []int32, numLMS, maxID int) {
710708
// sais_32 requires that the caller arrange to clear dst,
711709
// because in general the caller may know dst is
712710
// freshly-allocated and already cleared. But this one is not.
713-
for i := range dst {
714-
dst[i] = 0
715-
}
711+
clear(dst)
716712
sais_32(text, maxID, dst, tmp)
717713
}
718714

src/index/suffixarray/sais2.go

Lines changed: 7 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)