Skip to content

Commit

Permalink
Update ResultSet to only add new records to list if they don't alread…
Browse files Browse the repository at this point in the history
…y exist (#304)
  • Loading branch information
kkajla12 authored Mar 5, 2024
1 parent 6030794 commit a735b9c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/authz/query/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func (rs *ResultSet) Add(objectType string, objectId string, warrant warrant.War
next: nil,
}

if existingRes, exists := rs.m[key(objectType, objectId)]; !exists || (existingRes.IsImplicit && !isImplicit) {
existingRes, exists := rs.m[key(objectType, objectId)]
if !exists {
// Add warrant to list
if rs.head == nil {
rs.head = newNode
Expand All @@ -67,7 +68,9 @@ func (rs *ResultSet) Add(objectType string, objectId string, warrant warrant.War
}

rs.tail = newNode
}

if !exists || (existingRes.IsImplicit && !isImplicit) {
// Add result node to map for O(1) lookups
rs.m[key(objectType, objectId)] = newNode
}
Expand Down

0 comments on commit a735b9c

Please sign in to comment.