mudge / re2

Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python".
http://mudge.name/re2/
BSD 3-Clause "New" or "Revised" License
130 stars 13 forks source link

Add bindings for RE2::Set #56

Closed pritambaral closed 2 years ago

pritambaral commented 2 years ago

RE2::Set allows for matching multiple patterns against a string. It scans the string only once and simultaneously checks for regexp matches against all patterns added to it. It is thus significantly faster than matching each pattern individually, which would require scanning the string once for every pattern.

mudge commented 2 years ago

Thanks for this, @pritambaral. I’m currently on parental leave so can’t promise to thoroughly review this just yet but it sounds like a useful addition.

Please feel free to ignore some of Hound CI’s automatic comments as they are not correct (e.g. the Hash syntax changes it proposes would break compatibility with older Ruby versions).

Has re2/set been available since the earliest versions or do we need to detect support at compile time?

pritambaral commented 2 years ago

Has re2/set been available since the earliest versions or do we need to detect support at compile time?

Yes, it has been available since the earliest tag I could find on GitHub (2015-05-21), although that version is not API compatible with this PR. The last API breaking change happened in 2017, so I'm confident that the versions currently supported should work.

mudge commented 2 years ago

I've now removed the Hound webhook so it should no longer add noise to the review.

mudge commented 2 years ago

I've cleaned up the history and rolled these changes into 1.5.0 which should now be available from RubyGems.

Thank you for your contribution and extraordinary patience.