| 1 | package utilsscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/ |
| 2 | |
| 3 | import ( |
| 4 | "math/randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 7 | |
| 8 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 9 | ) |
| 10 | |
| 11 | // Scalar references the SWAR implementations are checked against. |
| 12 | |
| 13 | // Tight scalar loops mirroring what fiber's byte-at-a-time call sites do |
| 14 | // today — the honest baseline for the SWAR versions. |
| 15 | func refIndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny2().(s string, a, b byte) int { |
| 16 | for i := 0; i < len(s); i++ { |
| 17 | if s[i] == a || s[i] == b { |
| 18 | return i |
| 19 | } |
| 20 | } |
| 21 | return -1 |
| 22 | } |
| 23 | |
| 24 | func refIndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny3().(s string, a, b, c byte) int { |
| 25 | for i := 0; i < len(s); i++ { |
| 26 | if s[i] == a || s[i] == b || s[i] == c { |
| 27 | return i |
| 28 | } |
| 29 | } |
| 30 | return -1 |
| 31 | } |
| 32 | |
| 33 | func refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, needle string) int { |
| 34 | if len(needle) == 0 { |
| 35 | return 0 |
| 36 | } |
| 37 | fold := func(c byte) byte { |
| 38 | if c >= 'A' && c <= 'Z' { |
| 39 | return c + 'a' - 'A' |
| 40 | } |
| 41 | return c |
| 42 | } |
| 43 | for i := 0; i+len(needle) <= len(s); i++ { |
| 44 | ok := true |
| 45 | for j := 0; j < len(needle); j++ { |
| 46 | if fold(s[i+j]) != fold(needle[j]) { |
| 47 | ok = false |
| 48 | break |
| 49 | } |
| 50 | } |
| 51 | if ok { |
| 52 | return i |
| 53 | } |
| 54 | } |
| 55 | return -1 |
| 56 | } |
| 57 | |
| 58 | func refIndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexNonQuotable().(s string) int { |
| 59 | for i := 0; i < len(s); i++ { |
| 60 | if c := s[i]; c == '\\' || c == '"' || (c < 0x20 && c != '\t') || c == 0x7f { |
| 61 | return i |
| 62 | } |
| 63 | } |
| 64 | return -1 |
| 65 | } |
| 66 | |
| 67 | func Test_IndexAny_Fixedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_IndexAny_Fixed().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 68 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 69 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().("", ',', '"')) |
| 70 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(",", ',', '"')) |
| 71 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 3, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().([]byte("abc,def"), ',', '"')) |
| 72 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 5, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().("abcde\"fgh,ij", '"', ',')) |
| 73 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().("abcdefgh", ',', '"', '\\')) |
| 74 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 7, IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().("abcdefg\\", ',', '"', '\\')) |
| 75 | // Needle equal to 0x00 and >= 0x80 must work exactly. |
| 76 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 2, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().("ab\x00cd", 0x00, 0x01)) |
| 77 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 4, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().("abcd\xe9f", 0xE9, 0x01)) |
| 78 | } |
| 79 | |
| 80 | func Test_Search_Randomizedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_Search_Randomized().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 81 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 82 | rng := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(7)) //nolint:gosec // deterministic test data |
| 83 | |
| 84 | for range 30000 { |
| 85 | // Lengths 0..100 cover all %8 tails, the overlap reads, and 2+ |
| 86 | // iterations of IsASCII's 32-byte unrolled loop. |
| 87 | n := rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(101) |
| 88 | buf := make([]byte, n) |
| 89 | for i := range buf { |
| 90 | // Small alphabet so needles hit often, plus occasional raw bytes. |
| 91 | if rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(8) == 0 { |
| 92 | buf[i] = byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)) |
| 93 | } else { |
| 94 | buf[i] = "abcDEF,\"\\\x00\x7f\xe9\t :."[rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(15)] |
| 95 | } |
| 96 | } |
| 97 | s := string(buf) |
| 98 | |
| 99 | a, b, c := byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)), byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)), byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)) |
| 100 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny2().(s, a, b), IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(s, a, b), "IndexAny2 %q %q %q", s, a, b) |
| 101 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny2().(s, a, b), IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(buf, a, b)) |
| 102 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny3().(s, a, b, c), IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().(s, a, b, c), "IndexAny3 %q", s) |
| 103 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny3().(s, a, b, c), IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().(buf, a, b, c)) |
| 104 | |
| 105 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexNonQuotable().(s), IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().(s), "IndexNonQuotable %q", s) |
| 106 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexNonQuotable().(s), IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().(buf)) |
| 107 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, isASCIIRefscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/isASCIIRef().(s), IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(s), "IsASCII %q", s) |
| 108 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, isASCIIRefscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/isASCIIRef().(s), IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(buf)) |
| 109 | |
| 110 | // Needle: random slice of s (guaranteed present) or random bytes. |
| 111 | var needle string |
| 112 | if n > 0 && rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(2) == 0 { |
| 113 | start := rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(n) |
| 114 | end := start + rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(min(n-start, 12)+1) |
| 115 | needle = s[start:end] |
| 116 | if rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(2) == 0 { |
| 117 | // Random-case the needle: must still be found. |
| 118 | nb := []byte(needle) |
| 119 | for i := range nb { |
| 120 | if rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(2) == 0 { |
| 121 | if nb[i] >= 'a' && nb[i] <= 'z' { |
| 122 | nb[i] -= 'a' - 'A' |
| 123 | } else if nb[i] >= 'A' && nb[i] <= 'Z' { |
| 124 | nb[i] += 'a' - 'A' |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | needle = string(nb) |
| 129 | } |
| 130 | } else { |
| 131 | nb := make([]byte, rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(12)) |
| 132 | for i := range nb { |
| 133 | nb[i] = byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)) |
| 134 | } |
| 135 | needle = string(nb) |
| 136 | } |
| 137 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, needle), IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().(s, needle), "IndexFold %q %q", s, needle) |
| 138 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, needle), IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().(buf, needle)) |
| 139 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, needle) >= 0, ContainsFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/ContainsFold().(s, needle)) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func isASCIIRefscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/isASCIIRef().(s string) bool { |
| 144 | for i := 0; i < len(s); i++ { |
| 145 | if s[i] >= 0x80 { |
| 146 | return false |
| 147 | } |
| 148 | } |
| 149 | return true |
| 150 | } |
| 151 | |
| 152 | func Test_IndexFold_Fixedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_IndexFold_Fixed().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 153 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 154 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("", "")) |
| 155 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("abc", "")) |
| 156 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("", "a")) |
| 157 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("NO-CACHE", "no-cache")) |
| 158 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 10, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("max-age=0,No-Cache,private", "no-cache")) |
| 159 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 4, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().([]byte("xyz BeArEr token"), "bearer")) |
| 160 | // Fold must only touch A-Z/a-z lanes: CR|0x20 == '-' would falsely match |
| 161 | // with a blanket |0x20 fold. |
| 162 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("no\rcache", "no-cache")) |
| 163 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("NO\rCACHE", "no-cache")) |
| 164 | // Non-ASCII bytes must match exactly, never fold. |
| 165 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("\xc9abc", "\xc9ABC")) |
| 166 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("\xe9abc", "\xc9abc")) |
| 167 | // Needles longer than 8 bytes take the scalar path. |
| 168 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 2, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("__Proxy-Authorization: basic", "proxy-authorization")) |
| 169 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("__Proxy-Authorizatio", "proxy-authorization!")) |
| 170 | // Match at the very end, crossing the overlapping tail window. |
| 171 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 12, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("aaaaaaaaaaaaNO-CACHE", "no-cache")) |
| 172 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 5, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("aaaaaGZip", "gzip")) |
| 173 | // First-byte candidates that overrun the last valid start must not match. |
| 174 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("aaaaaaagz", "gzip")) |
| 175 | // Same folded word, different case mixes. |
| 176 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("gZiP, deflate", "GzIp")) |
| 177 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, ContainsFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/ContainsFold().("Cache-Control: NO-CACHE", "no-cache")) |
| 178 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, ContainsFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/ContainsFold().("Cache-Control: no\rcache", "no-cache")) |
| 179 | // Long needles (> 8 bytes) use the SWAR candidate scan with a word-wise |
| 180 | // fold-compare verify, including matches ending exactly at the tail. |
| 181 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 21, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("x-real-ip, x-req-id, Proxy-Authorization", "proxy-authorization")) |
| 182 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 7, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("cookie CONTENT-type: text", "content-type")) |
| 183 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("cookie CONTENT-typ: text.", "content-type")) |
| 184 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 12, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("abcdefghijklTRANSFER-ENCODING", "transfer-encoding")) |
| 185 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("authorizatioN", "authorization")) |
| 186 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("authorizatio", "authorization")) |
| 187 | // The first candidate appears only in the scalar remainder after the |
| 188 | // word loop, so the folded needle is built there. |
| 189 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 10, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("aaaaaaaaaaGZ", "gz")) |
| 190 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("aaaaaaaaaaGx", "gz")) |
| 191 | // Needle length an exact multiple of the word size: the fold-compare |
| 192 | // covers it with full words only, matching and mismatching. |
| 193 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 2, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("__proxy-authorizatXYZ", "PROXY-AUTHORIZAT")) |
| 194 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().("__proxy-authorizaQXYZ", "PROXY-AUTHORIZAT")) |
| 195 | } |
| 196 | |
| 197 | // refHasPrefixFold/refHasSuffixFold reduce to refIndexFold on the clipped |
| 198 | // window: with len(window) == len(needle) a 0 return means "equal folded". |
| 199 | func refHasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasPrefixFold().(s, prefix string) bool { |
| 200 | return len(s) >= len(prefix) && refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s[:len(prefix)], prefix) == 0 |
| 201 | } |
| 202 | |
| 203 | func refHasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasSuffixFold().(s, suffix string) bool { |
| 204 | return len(s) >= len(suffix) && refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s[len(s)-len(suffix):], suffix) == 0 |
| 205 | } |
| 206 | |
| 207 | func Test_HasPrefixFold_HasSuffixFold_Fixedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_HasPrefixFold_HasSuffixFold_Fixed().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 208 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 209 | // Empty needles match anything, oversized needles nothing. |
| 210 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("", "")) |
| 211 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("", "")) |
| 212 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("x", "")) |
| 213 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("x", "")) |
| 214 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("", "a")) |
| 215 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("", "a")) |
| 216 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("bear", "bearer ")) |
| 217 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("zip", "gzip")) |
| 218 | |
| 219 | // Scalar path (needle < 8 bytes), both hit and miss, string and []byte. |
| 220 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("Bearer abc.def", "bearer ")) |
| 221 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().([]byte("BEARER abc.def"), "bearer ")) |
| 222 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("Basic QWxhZGRpbg==", "bearer ")) |
| 223 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("application/vnd.api+JSON", "+json")) |
| 224 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().([]byte("deflate, GZIP"), "gzip")) |
| 225 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("deflate, GZIPx", "gzip")) |
| 226 | |
| 227 | // Word path (needle >= 8 bytes), including the overlapping tail compare. |
| 228 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("MULTIPART/FORM-DATA; boundary=X", "multipart/form-data")) |
| 229 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("multipart/form-datX; boundary=X", "multipart/form-data")) |
| 230 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("multipart/form-data", "multipart/form-data")) |
| 231 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("application/ATOM+XML", "atom+xml")) |
| 232 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("application/atomxxml", "atom+xml")) |
| 233 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("PROXY-AUTHORIZATION", "proxy-authorization")) |
| 234 | |
| 235 | // Exact-length inputs on the scalar path. |
| 236 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("GZip", "gzip")) |
| 237 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("GZip", "gzip")) |
| 238 | |
| 239 | // Only A-Z/a-z fold: CR|0x20 == '-' style false folds must not match, |
| 240 | // and non-ASCII bytes must match exactly. |
| 241 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("no\rcache", "no-cache")) |
| 242 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("xno\rcache", "no-cache")) |
| 243 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("\xc9abcdefgh", "\xc9ABCDEFGH")) |
| 244 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().("\xe9abcdefgh", "\xc9abcdefgh")) |
| 245 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("x\xc9abcdefg", "\xc9ABCDEFG")) |
| 246 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().("x\xe9abcdefg", "\xc9abcdefg")) |
| 247 | } |
| 248 | |
| 249 | func Test_PrefixSuffixFold_Randomizedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_PrefixSuffixFold_Randomized().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 250 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 251 | rng := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(13)) //nolint:gosec // deterministic test data |
| 252 | |
| 253 | for range 30000 { |
| 254 | n := rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(41) |
| 255 | buf := make([]byte, n) |
| 256 | for i := range buf { |
| 257 | if rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(8) == 0 { |
| 258 | buf[i] = byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)) |
| 259 | } else { |
| 260 | buf[i] = "abcDEF,\"\\\x00\x7f\xe9\t :."[rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(15)] |
| 261 | } |
| 262 | } |
| 263 | s := string(buf) |
| 264 | |
| 265 | // Needle: prefix/suffix of s (random-cased, guaranteed hit) or |
| 266 | // random bytes (usually a miss), lengths crossing the 8-byte split. |
| 267 | k := rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(min(n, 12) + 1) |
| 268 | var needle []byte |
| 269 | switch rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(3) { |
| 270 | case 0: |
| 271 | needle = []byte(s[:k]) |
| 272 | case 1: |
| 273 | needle = []byte(s[n-k:]) |
| 274 | default: |
| 275 | needle = make([]byte, rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(12)) |
| 276 | for i := range needle { |
| 277 | needle[i] = byte(rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(256)) |
| 278 | } |
| 279 | } |
| 280 | for i := range needle { |
| 281 | if rng.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(2) == 0 { |
| 282 | if needle[i] >= 'a' && needle[i] <= 'z' { |
| 283 | needle[i] -= 'a' - 'A' |
| 284 | } else if needle[i] >= 'A' && needle[i] <= 'Z' { |
| 285 | needle[i] += 'a' - 'A' |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | nd := string(needle) |
| 290 | |
| 291 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refHasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasPrefixFold().(s, nd), HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().(s, nd), "HasPrefixFold %q %q", s, nd) |
| 292 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refHasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasPrefixFold().(s, nd), HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().(buf, nd)) |
| 293 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refHasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasSuffixFold().(s, nd), HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().(s, nd), "HasSuffixFold %q %q", s, nd) |
| 294 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, refHasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refHasSuffixFold().(s, nd), HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().(buf, nd)) |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | func Test_IndexNonQuotable_Fixedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_IndexNonQuotable_Fixed().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 299 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 300 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("")) |
| 301 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("simple filename.txt")) |
| 302 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 4, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().(`name"quoted`)) |
| 303 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 4, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().(`name\quoted`)) |
| 304 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 0, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("\x1ftail")) |
| 305 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 7, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("abcdefg\x7f")) |
| 306 | // obs-text (>= 0x80) is quotable. |
| 307 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("caf\xc3\xa9 r\xc3\xa9sum\xc3\xa9.pdf")) |
| 308 | // HTAB is valid qdtext (RFC 9110) and must NOT be flagged, in the word |
| 309 | // path, the scalar path, and directly before a real control byte. |
| 310 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().([]byte("aaaaaaaaa\ttab"))) |
| 311 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, -1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("a\tb")) |
| 312 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 9, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("aaaaaaaa\t\x1f")) |
| 313 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 3, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("ab\t\x08cdefgh")) |
| 314 | // Borrow-stress shapes: obs-text lanes before a quote, and a quote |
| 315 | // directly ahead of a control byte. |
| 316 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 7, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("\xff\xff\xff\xff\xff\xff\xff\"")) |
| 317 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 1, IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().("a\"\x00defgh")) |
| 318 | } |
| 319 | |
| 320 | func Test_IsASCII_Fixedscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_IsASCII_Fixed().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 321 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 322 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().("")) |
| 323 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().("plain ascii filename.txt")) |
| 324 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().("caf\xc3\xa9")) |
| 325 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().([]byte{0x80})) |
| 326 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().([]byte{0x7f, 0x00, 'a'})) |
| 327 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().("aaaaaaaaaaaaaaa\xff")) // high byte only in the tail |
| 328 | } |
| 329 | |
| 330 | func Test_Search_NamedTypes_SIMDDispatchscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_Search_NamedTypes_SIMDDispatch().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 331 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 332 | // Named byteSeq instantiations at 32+ bytes take the amd64 simd dispatch, |
| 333 | // whose zero-copy []byte view assumes the header layouts named types |
| 334 | // share with plain string/[]byte. |
| 335 | type headerString string |
| 336 | type headerBytes []byte |
| 337 | long := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("x", 40) + "," |
| 338 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 40, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(headerString(long), ',', '"')) |
| 339 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 40, IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(headerBytes(long), ',', '"')) |
| 340 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 40, IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().(headerString(long), ',', '"', '\\')) |
| 341 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, 40, IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().(headerBytes(long), ',', '"', '\\')) |
| 342 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(headerString(long))) |
| 343 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/True().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(headerBytes(long))) |
| 344 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(headerString(long+"\xe9"))) |
| 345 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Falsescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/False().(t, IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(headerBytes(long+"\xe9"))) |
| 346 | } |
| 347 | |
| 348 | // --- Benchmarks: SWAR vs scalar reference at HTTP-typical sizes --- |
| 349 | |
| 350 | var benchSizesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchSizes. = []int{7, 8, 16, 32, 64, 512} |
| 351 | |
| 352 | func benchInputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchInput().(size, needleAt int, needle byte) string { |
| 353 | b := make([]byte, size) |
| 354 | for i := range b { |
| 355 | b[i] = 'a' + byte(i%23) |
| 356 | } |
| 357 | if needleAt >= 0 && needleAt < size { |
| 358 | b[needleAt] = needle |
| 359 | } |
| 360 | return string(b) |
| 361 | } |
| 362 | |
| 363 | func Benchmark_IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_IndexAny2().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 364 | for _, size := range benchSizesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchSizes. { |
| 365 | s := benchInputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchInput().(size, size-1, ',') // worst case: match at the very end |
| 366 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 367 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 368 | var r int |
| 369 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 370 | r = IndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny2().(s, ',', '"') |
| 371 | } |
| 372 | _ = r |
| 373 | }) |
| 374 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 375 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 376 | var r int |
| 377 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 378 | r = refIndexAny2scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny2().(s, ',', '"') |
| 379 | } |
| 380 | _ = r |
| 381 | }) |
| 382 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/stdlib-indexany", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 383 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 384 | var r int |
| 385 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 386 | r = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.IndexAnyscip-go gomod github.com/golang/go/src go1.25.0 strings/IndexAny().(s, ",\"") |
| 387 | } |
| 388 | _ = r |
| 389 | }) |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | func Benchmark_IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_IndexAny3().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 394 | for _, size := range benchSizesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchSizes. { |
| 395 | s := benchInputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchInput().(size, size-1, ';') |
| 396 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 397 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 398 | var r int |
| 399 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 400 | r = IndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexAny3().(s, ';', '"', '\\') |
| 401 | } |
| 402 | _ = r |
| 403 | }) |
| 404 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 405 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 406 | var r int |
| 407 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 408 | r = refIndexAny3scip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexAny3().(s, ';', '"', '\\') |
| 409 | } |
| 410 | _ = r |
| 411 | }) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | func Benchmark_IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_IndexFold().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 416 | headers := map[string]string{ |
| 417 | "miss-8B": "max-age=", |
| 418 | "miss-32B": "max-age=31536000, must-revalidat", |
| 419 | "hit-32B": "max-age=0, private, No-CaChE, mu", |
| 420 | "miss-64B": stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("max-age=31536000", 4), |
| 421 | "hit-tail": "max-age=31536000, immutable, private, stale-if-error, NO-CACHE", |
| 422 | "miss-512B": stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("max-age=31536000", 32), |
| 423 | } |
| 424 | longNeedle := map[string]string{ |
| 425 | "long-miss-64B": stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("max-age=31536000", 4), |
| 426 | "long-hit-64B": "max-age=31536000, immutable, Proxy-Authorization: basic aaaa", |
| 427 | } |
| 428 | for name, s := range headers { |
| 429 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(name+"/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 430 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(s))) |
| 431 | var r int |
| 432 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 433 | r = IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().(s, "no-cache") |
| 434 | } |
| 435 | _ = r |
| 436 | }) |
| 437 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(name+"/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 438 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(s))) |
| 439 | var r int |
| 440 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 441 | r = refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, "no-cache") |
| 442 | } |
| 443 | _ = r |
| 444 | }) |
| 445 | } |
| 446 | for name, s := range longNeedle { |
| 447 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(name+"/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 448 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(s))) |
| 449 | var r int |
| 450 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 451 | r = IndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexFold().(s, "proxy-authorization") |
| 452 | } |
| 453 | _ = r |
| 454 | }) |
| 455 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(name+"/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 456 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(s))) |
| 457 | var r int |
| 458 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 459 | r = refIndexFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexFold().(s, "proxy-authorization") |
| 460 | } |
| 461 | _ = r |
| 462 | }) |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | func Benchmark_HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_HasPrefixFold().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 467 | cases := []struct { |
| 468 | name string |
| 469 | s string |
| 470 | prefix string |
| 471 | }{ |
| 472 | {"bearer-hit", "Bearer abc.def.ghi.jkl.mno.pqr", "bearer "}, |
| 473 | {"bearer-miss", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", "bearer "}, |
| 474 | {"text-hit", "TEXT/HTML; charset=utf-8", "text/"}, |
| 475 | {"multipart-hit", "MULTIPART/FORM-DATA; boundary=X-BOUNDARY", "multipart/form-data"}, |
| 476 | {"multipart-miss", "application/x-www-form-urlencoded", "multipart/form-data"}, |
| 477 | } |
| 478 | for _, tc := range cases { |
| 479 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.name+"/fiber", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 480 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.prefix))) |
| 481 | var r bool |
| 482 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 483 | r = HasPrefixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasPrefixFold().(tc.s, tc.prefix) |
| 484 | } |
| 485 | _ = r |
| 486 | }) |
| 487 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.name+"/default", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 488 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.prefix))) |
| 489 | var r bool |
| 490 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 491 | r = len(tc.s) >= len(tc.prefix) && stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.EqualFoldscip-go gomod github.com/golang/go/src go1.25.0 strings/EqualFold().(tc.s[:len(tc.prefix)], tc.prefix) |
| 492 | } |
| 493 | _ = r |
| 494 | }) |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | func Benchmark_HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_HasSuffixFold().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 499 | cases := []struct { |
| 500 | name string |
| 501 | s string |
| 502 | suffix string |
| 503 | }{ |
| 504 | {"gzip-hit", "deflate, br, GZIP", "gzip"}, |
| 505 | {"gzip-miss", "deflate, br, zstd", "gzip"}, |
| 506 | {"json-hit", "application/vnd.api+JSON", "+json"}, |
| 507 | {"atomxml-hit", "application/ATOM+XML", "atom+xml"}, |
| 508 | {"charset-miss", "text/html; charset=utf-8", "charset=iso-8859-1"}, |
| 509 | } |
| 510 | for _, tc := range cases { |
| 511 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.name+"/fiber", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 512 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.suffix))) |
| 513 | var r bool |
| 514 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 515 | r = HasSuffixFoldscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/HasSuffixFold().(tc.s, tc.suffix) |
| 516 | } |
| 517 | _ = r |
| 518 | }) |
| 519 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.name+"/default", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 520 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.suffix))) |
| 521 | var r bool |
| 522 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 523 | r = len(tc.s) >= len(tc.suffix) && stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.EqualFoldscip-go gomod github.com/golang/go/src go1.25.0 strings/EqualFold().(tc.s[len(tc.s)-len(tc.suffix):], tc.suffix) |
| 524 | } |
| 525 | _ = r |
| 526 | }) |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | func Benchmark_IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_IsASCII().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 531 | for _, size := range benchSizesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchSizes. { |
| 532 | s := benchInputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchInput().(size, -1, 0) |
| 533 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 534 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 535 | var r bool |
| 536 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 537 | r = IsASCIIscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IsASCII().(s) |
| 538 | } |
| 539 | _ = r |
| 540 | }) |
| 541 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 542 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 543 | var r bool |
| 544 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 545 | r = isASCIIRefscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/isASCIIRef().(s) |
| 546 | } |
| 547 | _ = r |
| 548 | }) |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | func Benchmark_IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_IndexNonQuotable().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 553 | for _, size := range benchSizesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchSizes. { |
| 554 | s := benchInputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/benchInput().(size, -1, 0) // clean input: full scan |
| 555 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/swar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 556 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 557 | var r int |
| 558 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 559 | r = IndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/IndexNonQuotable().(s) |
| 560 | } |
| 561 | _ = r |
| 562 | }) |
| 563 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(FormatIntscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/FormatInt().(int64(size))+"B/scalar", func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 564 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(size)) |
| 565 | var r int |
| 566 | for b.Loopscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Loop().() { |
| 567 | r = refIndexNonQuotablescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/refIndexNonQuotable().(s) |
| 568 | } |
| 569 | _ = r |
| 570 | }) |
| 571 | } |
| 572 | } |