Use slices package from the stdlib when possible (#5360)

* Use slices from the stdlib when possible

* Add some unit tests

* More small tweaks + add benchmark func
This commit is contained in:
its-josh4
2024-10-28 17:26:23 -07:00
committed by GitHub
parent 093de3bce2
commit c6bcdd89be
38 changed files with 200 additions and 110 deletions

View File

@@ -1,10 +1,9 @@
package dlna
import (
"slices"
"sync"
"time"
"github.com/stashapp/stash/pkg/sliceutil"
)
// only keep the 10 most recent IP addresses
@@ -30,7 +29,7 @@ func (m *ipWhitelistManager) addRecent(addr string) bool {
m.mutex.Lock()
defer m.mutex.Unlock()
i := sliceutil.Index(m.recentIPAddresses, addr)
i := slices.Index(m.recentIPAddresses, addr)
if i != -1 {
if i == 0 {
// don't do anything if it's already at the start