Commit b168081
perf(core): optimize rebuild() to avoid O(N^2) complexity
Temporarily disable detector during rebuild loop to prevent repeated
cycle checks on each addLink call. Perform a single check at the end.
This reduces rebuild() complexity from O(N^2) to O(N) when detector is enabled.
- Save original detector before rebuild
- Set detector to null during addLink loop
- Restore detector and perform single check after loop
- Properly restore detector in exception handler
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>1 parent 4ecff15 commit b168081
File tree
1 file changed
+23
-3
lines changed- src/main/java/org/casbin/jcasbin/rbac
1 file changed
+23
-3
lines changedLines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
101 | 121 | | |
102 | 122 | | |
103 | 123 | | |
| |||
0 commit comments