You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: optimize KeyMatch functions with fast path for wildcard replacement
This change introduces a fast path optimization for KeyMatch2, KeyMatch3, KeyMatch4, KeyMatch5 and their corresponding KeyGet functions.
Original code (unconditional replacement):
key2 = strings.Replace(key2, "/*", "/.*", -1)
Optimized code (conditional replacement):
if strings.Contains(key2, "/*") { //nolint:gosimple // optimization
key2 = strings.Replace(key2, "/*", "/.*", -1)
}
This avoids unnecessary allocations and processing when the key does not contain a wildcard, as verified by upstream benchmarks using test data like 'examples/performance/rbac_with_pattern_large_scale_policy.csv'.
0 commit comments