Skip to content

Commit

Permalink
Merge pull request #141 from Sagilio/master
Browse files Browse the repository at this point in the history
perf: Improve performance in GetImplicitUsersForPermission
  • Loading branch information
hsluoyz authored Mar 19, 2021
2 parents c7ec287 + 4fd5287 commit 87dbe83
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions NetCasbin/Enforcer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,11 @@ public IEnumerable<string> GetImplicitUsersForPermission(params string[] permiss

public IEnumerable<string> GetImplicitUsersForPermission(IEnumerable<string> permissions)
{
var policySubjects = GetAllSubjects();
var groupInherit = model.GetValuesForFieldInPolicyAllTypes("g", 1);
var groupSubjects = model.GetValuesForFieldInPolicyAllTypes("g", 0);
return policySubjects.Concat(groupSubjects).Distinct()
.Where(subject => Enforce(new[]{ subject }.Concat(permissions).Cast<object>().ToArray()))
.Except(groupInherit);
List<string> policySubjects = GetAllSubjects();
List<string> groupInherit = model.GetValuesForFieldInPolicyAllTypes("g", 1);
List<string> groupSubjects = model.GetValuesForFieldInPolicyAllTypes("g", 0);
return policySubjects.Concat(groupSubjects).Distinct().Except(groupInherit)
.Where(subject => Enforce(new[]{ subject }.Concat(permissions).Cast<object>().ToArray()));
}

#endregion
Expand Down

0 comments on commit 87dbe83

Please sign in to comment.