Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`rindex` performance improvement #1170

Merged
merged 1 commit into from Oct 27, 2013

Conversation

@shepmaster
Copy link
Contributor

@shepmaster shepmaster commented Oct 26, 2013

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 #1140
@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Oct 27, 2013

Could you provide a benchmark, please?

@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Oct 27, 2013

Oh, I see #1140 (comment)

enebo added a commit that referenced this pull request Oct 27, 2013
`rindex` performance improvement
@enebo enebo merged commit 1faa15f into jruby:jruby-1_7 Oct 27, 2013
1 check passed
1 check passed
default The Travis CI build passed
Details
@shepmaster shepmaster deleted the shepmaster:rindex-perf-improvement branch Oct 27, 2013
@shepmaster
Copy link
Contributor Author

@shepmaster shepmaster commented Oct 27, 2013

Thanks! ❤️ 💚 💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.