summaryrefslogtreecommitdiff
path: root/lib/diskio
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 22:43:58 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 22:43:58 -0700
commitd675f41242c043ddc4c6c1a1fb8aabcfd324aae2 (patch)
tree4f2afbce761eb377ad0b0ab2e4fb2f478ff844f5 /lib/diskio
parent9971e38110d5f90d15c7b78f396f2638b3952a96 (diff)
parent6e1a9fbb1e9a943e04902ed3a4958f6821e39456 (diff)
Merge branch 'lukeshu/lint'
Diffstat (limited to 'lib/diskio')
-rw-r--r--lib/diskio/kmp.go8
-rw-r--r--lib/diskio/kmp_test.go5
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/diskio/kmp.go b/lib/diskio/kmp.go
index 5f6e295..6949aa4 100644
--- a/lib/diskio/kmp.go
+++ b/lib/diskio/kmp.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -15,6 +15,7 @@ func kmpEq2[K ~int64, V comparable](aS Sequence[K, V], aI K, bS Sequence[K, V],
aV, aErr := aS.Get(aI)
bV, bErr := bS.Get(bI)
if aErr != nil {
+ //nolint:errorlint // The == is just a fast-path; we still fall back to errors.Is.
if aErr == ErrWildcard || errors.Is(aErr, ErrWildcard) {
aV = bV
aErr = nil
@@ -23,6 +24,7 @@ func kmpEq2[K ~int64, V comparable](aS Sequence[K, V], aI K, bS Sequence[K, V],
}
}
if bErr != nil {
+ //nolint:errorlint // The == is just a fast-path; we still fall back to errors.Is.
if bErr == ErrWildcard || errors.Is(bErr, ErrWildcard) {
bV = aV
bErr = nil
@@ -39,6 +41,7 @@ func kmpEq2[K ~int64, V comparable](aS Sequence[K, V], aI K, bS Sequence[K, V],
func kmpEq1[K ~int64, V comparable](aV V, bS Sequence[K, V], bI K) bool {
bV, bErr := bS.Get(bI)
if bErr != nil {
+ //nolint:errorlint // The == is just a fast-path; we still fall back to errors.Is.
if bErr == ErrWildcard || errors.Is(bErr, ErrWildcard) {
return true
}
@@ -53,6 +56,7 @@ func kmpEq1[K ~int64, V comparable](aV V, bS Sequence[K, V], bI K) bool {
func buildKMPTable[K ~int64, V comparable](substr Sequence[K, V]) ([]K, error) {
var substrLen K
for {
+ //nolint:errorlint // The == is just a fast-path; we still fall back to errors.Is.
if _, err := substr.Get(substrLen); err != nil && !(err == ErrWildcard || errors.Is(err, ErrWildcard)) {
if errors.Is(err, io.EOF) {
break
@@ -84,7 +88,7 @@ func buildKMPTable[K ~int64, V comparable](substr Sequence[K, V]) ([]K, error) {
}
// IndexAll returns the starting-position of all possibly-overlapping
-// occurances of 'substr' in the 'str' sequence.
+// occurrences of 'substr' in the 'str' sequence.
//
// Will hop around in 'substr', but will only get the natural sequence
// [0...) in order from 'str'. When hopping around in 'substr' it
diff --git a/lib/diskio/kmp_test.go b/lib/diskio/kmp_test.go
index 59b6224..4d4b3be 100644
--- a/lib/diskio/kmp_test.go
+++ b/lib/diskio/kmp_test.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -14,6 +14,7 @@ import (
)
func TestBuildKMPTable(t *testing.T) {
+ t.Parallel()
substr := SliceSequence[int64, byte]([]byte("ababaa"))
table, err := buildKMPTable[int64, byte](substr)
require.NoError(t, err)
@@ -81,6 +82,7 @@ func (re RESeq) Get(i int64) (byte, error) {
}
func TestKMPWildcard(t *testing.T) {
+ t.Parallel()
type testcase struct {
InStr string
InSubstr string
@@ -111,6 +113,7 @@ func TestKMPWildcard(t *testing.T) {
for tcName, tc := range testcases {
tc := tc
t.Run(tcName, func(t *testing.T) {
+ t.Parallel()
matches, err := IndexAll[int64, byte](
StringSequence[int64](tc.InStr),
RESeq(tc.InSubstr))