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

Projects
None yet
3 participants
@shepmaster
Contributor

shepmaster commented Oct 26, 2013

No description provided.

Improve String#rindex performance for pathological cases
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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 27, 2013

Member

Could you provide a benchmark, please?

Member

BanzaiMan commented Oct 27, 2013

Could you provide a benchmark, please?

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan
Member

BanzaiMan commented Oct 27, 2013

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

1 check passed

default The Travis CI build passed
Details

@shepmaster shepmaster deleted the shepmaster:rindex-perf-improvement branch Oct 27, 2013

@shepmaster

This comment has been minimized.

Show comment
Hide comment
@shepmaster

shepmaster Oct 27, 2013

Contributor

Thanks! ❤️ 💚 💙

Contributor

shepmaster commented Oct 27, 2013

Thanks! ❤️ 💚 💙

esparta added a commit to esparta/jruby that referenced this pull request Feb 13, 2018

Added accessor of original line when parsing.
  [Feature #11865][ruby-core:72452][fix jrubyGH-1170]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Signed-off-by: Espartaco Palma <esparta@gmail.com>

esparta added a commit to esparta/jruby that referenced this pull request Feb 13, 2018

Added accessor of original line when parsing.
  [Feature #11865][ruby-core:72452][fix jrubyGH-1170]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Signed-off-by: Espartaco Palma <esparta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment