Skip to content

rindex performance improvement#1170

Merged
enebo merged 1 commit intojruby:jruby-1_7from
shepmaster:rindex-perf-improvement
Oct 27, 2013
Merged

rindex performance improvement#1170
enebo merged 1 commit intojruby:jruby-1_7from
shepmaster:rindex-perf-improvement

Conversation

@shepmaster
Copy link
Contributor

No description provided.

When the haystack string contained a non-single-byte character, code
would previously call `StringSupport.nth` for every backwards
step. `nth` walks all the way through the string from the
beginning. The combination of these caused O(n^2) behavior.

Now `rindex` follows MRI's pattern of simply walking backward until we
find the previous character.

Fixes jruby#1140
@BanzaiMan
Copy link
Member

Could you provide a benchmark, please?

@BanzaiMan
Copy link
Member

Oh, I see #1140 (comment)

enebo added a commit that referenced this pull request Oct 27, 2013
@enebo enebo merged commit 1faa15f into jruby:jruby-1_7 Oct 27, 2013
@shepmaster shepmaster deleted the rindex-perf-improvement branch October 27, 2013 20:33
@shepmaster
Copy link
Contributor Author

Thanks! ❤️ 💚 💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants