p-ranav / hypergrep

Recursively search directories for a regex pattern
MIT License
204 stars 7 forks source link

For print_only_filenames, use SINGLE_MATCH mode #16

Closed p-ranav closed 1 year ago

p-ranav commented 1 year ago

Single-match flag Tip Consider using the single-match flag to limit matches to one match per pattern only if possible.

If only one match per pattern is required, use the flag provided to indicate this (HS_FLAG_SINGLEMATCH). This flag can allow a number of optimizations to be applied, allowing both performance improvements and state space reductions when streaming.

However, there is some overhead associated with tracking whether each pattern in the pattern set has matched, and some applications with infrequent matches may see reduced performance when the single-match flag is used.