Actions
Bug #3855
closedString#rindex extremely slow on long UTF8 strings
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-09-21 trunk 29308) [i686-linux]
Backport:
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
Actions
Like0
Like0