Commit 3aa0c9d
committed
[OptionResolver] fix splitOutsideParenthesis to handle arbitrary nesting levels
Replace the limited 2-level nesting regex with a recursive pattern
using (?(DEFINE) to support union types with unlimited depth.
The previous regex pattern could only handle 2 levels of nested
parentheses like string|(int|(bool|float)) but would incorrectly
split deeply nested types like string|(int|(bool|(float|null))).
The new implementation uses PCRE's (?(DEFINE) syntax to create a
named subroutine (?<balanced>) that recursively matches balanced
parentheses at any depth.
This approach provides 5.9x performance improvement over the original implementation1 parent cd41ba6 commit 3aa0c9d
1 file changed
+16
-11
lines changedLines changed: 16 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1217 | 1217 | | |
1218 | 1218 | | |
1219 | 1219 | | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1230 | 1235 | | |
1231 | 1236 | | |
1232 | 1237 | | |
1233 | | - | |
| 1238 | + | |
1234 | 1239 | | |
1235 | 1240 | | |
1236 | 1241 | | |
| |||
0 commit comments