]> Cypherpunks repositories - gostls13.git/commitdiff
index/suffixarray: use built-in clear to simplify code
authorapocelipes <seve3r@outlook.com>
Mon, 18 Mar 2024 08:56:03 +0000 (08:56 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 18 Mar 2024 23:57:18 +0000 (23:57 +0000)
"sais2.go" is regenerated by the command "go generate ./...".

Change-Id: I4307e9fa1f20ea59e3a0d4841dbb22e9cffefa5a
GitHub-Last-Rev: d285183e654fe412a3470e475fa1ea29e5973b78
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>

src/index/suffixarray/sais.go
src/index/suffixarray/sais2.go

index b53700be35006f551a32aa4931d37ca3992ccdbf..4204ba3882e03ec63e7de7146835fc8f946491f2 100644 (file)
@@ -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)
 }
 
index 32b89728011ffdcc2d0512efed82b58e54d846bc..080c909540a3105f2df9899c0ad2be06de89b83b 100644 (file)
@@ -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)
 }