hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

Regarding hs_multi_compile and hs_scan functionality

Open ChiragSharma1 opened this issue 1 year ago • 1 comments

I am having doubt regarding multiple regex scan. Let say I have 30 different regex patterns to scan on a single buffer and I compile all of them using hs_multi_compile in single database, then used that database in hs_scan, so will hyperscan scan buffer separately for each pattern , or will it scan complete buffer single time for all pattern. (ps. - Point is how many times buffer will be scanned.)

Also if it scan's separately , then how it will be more effective or efficient than compiling all pattern's separately using hs_compile and then calling hs_scan separately for each pattern.

ChiragSharma1 avatar Sep 05 '23 13:09 ChiragSharma1

As I know, Hyperscan searches for all patterns simultaneously. It compiles them into a kind of automata. So, if you need to search for multiple patterns in a buffer, you should use hs_multi_compile to compile them into one pattern database and then scan the buffer by hs_scan: one scan for one buffer.

Markoborodov avatar Sep 06 '23 14:09 Markoborodov