Skip to content

Commit

Permalink
Use lo.Uniq function
Browse files Browse the repository at this point in the history
  • Loading branch information
bradengroom committed Oct 4, 2023
1 parent ea861b2 commit fe18f67
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 62 deletions.
3 changes: 2 additions & 1 deletion internal/graph/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/samber/lo"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/authzed/spicedb/internal/dispatch"
Expand Down Expand Up @@ -155,7 +156,7 @@ func (cc *ConcurrentChecker) checkInternal(ctx context.Context, req ValidatedChe
}

// Deduplicate any incoming resource IDs.
resourceIds := slicez.Unique(req.ResourceIds)
resourceIds := lo.Uniq(req.ResourceIds)

// Filter the incoming resource IDs for any which match the subject directly. For example, if we receive
// a check for resource `user:{tom, fred, sarah}#...` and a subject of `user:sarah#...`, then we know
Expand Down
16 changes: 0 additions & 16 deletions pkg/genutil/slicez/unique.go

This file was deleted.

42 changes: 0 additions & 42 deletions pkg/genutil/slicez/unique_test.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/tuple/onrbytypeset.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tuple

import (
"github.com/authzed/spicedb/pkg/genutil/slicez"
core "github.com/authzed/spicedb/pkg/proto/core/v1"
"github.com/samber/lo"
)

// ONRByTypeSet is a set of ObjectAndRelation's, grouped by namespace+relation.
Expand Down Expand Up @@ -35,7 +35,7 @@ func (s *ONRByTypeSet) ForEachType(handler func(rr *core.RelationReference, obje
handler(&core.RelationReference{
Namespace: ns,
Relation: rel,
}, slicez.Unique(objectIds))
}, lo.Uniq(objectIds))
}
}

Expand All @@ -55,7 +55,7 @@ func (s *ONRByTypeSet) Map(mapper func(rr *core.RelationReference) (*core.Relati
if updatedType == nil {
continue
}
mapped.byType[JoinRelRef(updatedType.Namespace, updatedType.Relation)] = slicez.Unique(objectIds)
mapped.byType[JoinRelRef(updatedType.Namespace, updatedType.Relation)] = lo.Uniq(objectIds)
}
return mapped, nil
}
Expand Down

0 comments on commit fe18f67

Please sign in to comment.