Bug #3855
closedString#rindex extremely slow on long UTF8 strings
Description
=begin
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.
Example:
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.
Mike
=end
Files
Updated by naruse (Yui NARUSE) about 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r29331.
Michael, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end