Make more Regex loops atomic automatically (#31738)
* Change more Regex loops inside of atomic nodes to be atomic * Allow Regex loops that end other loops to be made atomic For example, given an expression like "(abcd*)*e", the inner d* loop will now be converted to be atomic, e.g. "(abc(?>d*))*e)". We're careful not to convert an expression like "(abca*)*e)", where the inner loop has no overlap with what comes immediately after the loop but does with the start of the loop. I also fixed what appears to be a long-standing bug in how character classes are canonicalized. An attempt was made to avoid running the canonlicalization routine, but we almost always need to do it, and we were not doing it in some cases, resulting in character classes that were correct but not as optimized as they should have been, e.g. two abutting ranges when one would suffice, leading to poorer code gen. It's part of this PR because I caught when changing the reduction tests to validate the full code tree including strings rather than just the codes list. * Address PR feedback And add more comments, more code coverage, more runtime asserts, etc. I also noticed we weren't reducing Setloopatomic and Setlazy into {Not}oneloopatomic and [Not}onelazy, so I fixed that. And I changed ReduceAtomic to actually remove unnecessary intermediate atomic nodes.
Showing
此差异已折叠。
想要评论请 注册 或 登录