fix AppendUnique.

This commit is contained in:
fiatjaf
2026-04-02 03:22:47 -03:00
parent 2c30300756
commit 72a5be58d7
+9 -7
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"cmp"
"net/url"
"slices"
"unsafe"
"github.com/templexxx/xhex"
@@ -89,14 +88,17 @@ func CompareRelayEventReverse(b, a RelayEvent) int {
// AppendUnique adds items to an array only if they don't already exist in the array.
// Returns the modified array.
func AppendUnique[I comparable](arr []I, item ...I) []I {
for _, item := range item {
if slices.Contains(arr, item) {
return arr
func AppendUnique[I comparable](list []I, newEls ...I) []I {
ex:
for _, newEl := range newEls {
for _, el := range list {
if el == newEl {
continue ex
}
}
arr = append(arr, item)
list = append(list, newEl)
}
return arr
return list
}
func IsOlder(previous, next Event) bool {