mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
chore: run modernize
This commit is contained in:
@@ -121,5 +121,5 @@ type HInt int
|
||||
|
||||
// Hash is a method that returns the hash of the integer.
|
||||
func (h HInt) Hash() string {
|
||||
return fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprintf("%d", h))))
|
||||
return fmt.Sprintf("%x", sha256.Sum256(fmt.Appendf(nil, "%d", h)))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -17,8 +18,8 @@ const (
|
||||
type cacheAction struct {
|
||||
actionType actionType
|
||||
key HString
|
||||
value interface{}
|
||||
expectedValue interface{}
|
||||
value any
|
||||
expectedValue any
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
@@ -121,7 +122,7 @@ func TestCache(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cache := NewMemoCache[HString, interface{}](tt.capacity)
|
||||
cache := NewMemoCache[HString, any](tt.capacity)
|
||||
for _, action := range tt.actions {
|
||||
switch action.actionType {
|
||||
case set:
|
||||
@@ -174,7 +175,7 @@ func FuzzCache(f *testing.F) {
|
||||
// If the key is already in accessOrder, we remove it and append it again later
|
||||
for index, accessedKey := range accessOrder {
|
||||
if accessedKey == key {
|
||||
accessOrder = append(accessOrder[:index], accessOrder[index+1:]...)
|
||||
accessOrder = slices.Delete(accessOrder, index, index+1)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -206,7 +207,7 @@ func FuzzCache(f *testing.F) {
|
||||
// If the key was accessed, move it to the end of the accessOrder to represent recent use
|
||||
for index, accessedKey := range accessOrder {
|
||||
if accessedKey == key {
|
||||
accessOrder = append(accessOrder[:index], accessOrder[index+1:]...)
|
||||
accessOrder = slices.Delete(accessOrder, index, index+1)
|
||||
accessOrder = append(accessOrder, key)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *sanitizer) Sanitize(runes []rune) []rune {
|
||||
// is smaller or equal to the input.
|
||||
copied := false
|
||||
|
||||
for src := 0; src < len(runes); src++ {
|
||||
for src := range runes {
|
||||
r := runes[src]
|
||||
switch {
|
||||
case r == utf8.RuneError:
|
||||
|
||||
Reference in New Issue
Block a user