File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,20 @@ export function dfaToRegex(dfa: DFA): RE.StdRegex {
181181}
182182
183183// TODO: can this round-trip through DFA construction be avoided?
184+ // QUESTION: Could also independently transform intersection/complement
185+ // sub-expressions. Would that be more or less efficient? Yield larger or
186+ // smaller output expressions?
184187export function toStdRegex ( inputRegex : RE . ExtRegex ) : RE . StdRegex {
188+ // Could check here in O(1) if `inputRegex` is already a `StdRegex` and
189+ // skip the expensive computation:
190+ //
191+ // if (RE.isStdRegex(inputRegex))
192+ // return inputRegex
193+ //
194+ // But that makes the benchmark "toStdRegex_output_length" and the
195+ // "toStdRegex" tests trivial. `RegexBuilder.getStdRegex` has this
196+ // check though.
197+
185198 const dfa = regexToDFA ( inputRegex )
186199 // printTrans(dfa)
187200 const outputRegex = dfaToRegex ( dfa )
You can’t perform that action at this time.
0 commit comments