small cleanup

This commit is contained in:
pippellia-btc
2025-05-29 15:00:02 +02:00
parent d69aab0168
commit 3c61c77cad
3 changed files with 7 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
// The graph package defines the fundamental structures (e.g. [Node], [Delta])
// that are used across packages.
package graph
import (

View File

@@ -236,7 +236,7 @@ func (r RedisDB) ReplaceWalks(ctx context.Context, before, after []walks.Walk) e
prev := before[i]
next := after[i]
ID := string(after[i].ID)
ID := after[i].ID
pipe.HSet(ctx, KeyWalks, ID, formatWalk(next))
@@ -343,13 +343,13 @@ func (r RedisDB) validateWalks() error {
}
// unique returns a slice of unique elements of the input slice.
func unique[S ~[]E, E cmp.Ordered](slice S) S {
func unique[E cmp.Ordered](slice []E) []E {
if len(slice) == 0 {
return nil
}
slices.Sort(slice)
unique := make(S, 0, len(slice))
unique := make([]E, 0, len(slice))
unique = append(unique, slice[0])
for i := 1; i < len(slice); i++ {

View File

@@ -20,6 +20,8 @@ var (
// ID represent how walks are identified in the storage layer
type ID string
func (id ID) MarshalBinary() ([]byte, error) { return []byte(id), nil }
// Walk is an ordered list of node IDs
type Walk struct {
ID ID