String#rindex extremely slow on long UTF8 strings
Not really a bug .....
I think this issue was raised a few months ago, but I have done a very simple patch to string.c to fix the problem.
ruby -e 'p String.new("XXX\u0639" + "X" * 100000).rindex("\u0639")'
takes approx 2.7 secs on my old AMD Athlon system, but only approx 0.02 sec with the patch below. The problem is worst when the search string is either not found or is near the beginning of the string.
The issue is the call to "str_nth()" which has to scan the string repeatedly on multibyte encodings just to locate where to start comparing.
I hope that you will consider applying the patch.