Skip to content

Commit a735b9c

Browse files
authored
Update ResultSet to only add new records to list if they don't already exist (#304)
1 parent 6030794 commit a735b9c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/authz/query/resultset.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ func (rs *ResultSet) Add(objectType string, objectId string, warrant warrant.War
5656
next: nil,
5757
}
5858

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

6970
rs.tail = newNode
71+
}
7072

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

0 commit comments

Comments
 (0)