@@ -2,6 +2,7 @@ package subjectmappingbuiltin
2
2
3
3
import (
4
4
"fmt"
5
+ "maps"
5
6
"slices"
6
7
"strings"
7
8
@@ -19,7 +20,7 @@ func EvaluateSubjectMappingMultipleEntitiesWithActions(
19
20
attributeMappings map [string ]* attributes.GetAttributeValuesByFqnsResponse_AttributeAndValue ,
20
21
entityRepresentations []* entityresolutionV2.EntityRepresentation ,
21
22
) (EntityIDsToEntitlements , error ) {
22
- results := make (map [string ]AttributeValueFQNsToActions )
23
+ results := make (map [string ]AttributeValueFQNsToActions , len ( entityRepresentations ) )
23
24
for _ , er := range entityRepresentations {
24
25
entitlements , err := EvaluateSubjectMappingsWithActions (attributeMappings , er )
25
26
if err != nil {
@@ -71,13 +72,12 @@ func EvaluateSubjectMappingsWithActions(
71
72
actions := subjectMapping .GetActions ()
72
73
73
74
// Cache each action by name to deduplicate
75
+ m := make (map [string ]* policy.Action , len (actions ))
74
76
for _ , action := range actions {
75
- if ! slices .ContainsFunc (entitlementsSet [valueFQN ], func (a * policy.Action ) bool {
76
- return strings .EqualFold (a .GetName (), action .GetName ())
77
- }) {
78
- entitlementsSet [valueFQN ] = append (entitlementsSet [valueFQN ], action )
79
- }
77
+ m [strings .ToLower (action .GetName ())] = action
78
+
80
79
}
80
+ entitlementsSet [valueFQN ] = append (entitlementsSet [valueFQN ], slices .Collect (maps .Values (m ))... )
81
81
}
82
82
}
83
83
}
0 commit comments