Skip to content

Commit 1d77393

Browse files
committed
docs: add some comments
1 parent ec4c788 commit 1d77393

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/dfa.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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?
184187
export 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)

0 commit comments

Comments
 (0)