3 ms·
A bad words list is a regex. ;-) But note: for the most part this isn't using regexs, and to the extent it does, it seems largely intended to make the maintain
by cbsmith 5y ago
A bad words list is a regex. ;-)
But note: for the most part this isn't using regexs, and to the extent it does, it seems largely intended to make the maintainers' lives easier by avoiding having to represent (and maintain) all the permutations they are trying to match for.
What's sad though is that they're doing many, many passes through the pattern matcher, rather than just building a single big DFA from the whole list of patterns they want to match, which gets traversed in one pass.
- sa46 5y agoCould Postgres convert the function into a DFA using the JIT optimizer (based on LLVM)? That might delve into sufficiently smart compiler territory but recognizing a bunch of OR'ed string matches seems on the easier end of optimization passes.
- cbsmith 5y agoYup, that's definitely sufficiently smart compiler territory. If you want to write an optimization pass that handles that, go for it, but you won't find one already there.
- jakear 5y agoRegEx => DFA conversation can lead to exponential growth in number of states... don't know how big it'd be in this case.