http://qs321.pair.com?node_id=11122330


in reply to Re: substrings that consist of repeating characters
in thread substrings that consist of repeating characters

Edit: I thought I had a better version but no. I ran the same benchmark again and the results were not the same at all (actually the three solutions had very similar performances). Something went wrong with my first attempt

You can get even better results if you remove the use of captures and backreferences:

sub v6 { %subs = (); $subs{$&}++ while $string =~ m{A{2,}|C{2,}|G{2,}|T{2,}}g; } # v6
Rate v4 v5 v6 v4 55470/s -- -9% -39% v5 60734/s 9% -- -34% v6 91365/s 65% 50% --

Edit: now that's a bad choice of delimiter 😂

I'm actually consistantly getting result that are worse without backreferences which which I don't understand...