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

Delay DidYouMean until NotFoundError#message is called #1039

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

tompng
Copy link
Member

@tompng tompng commented Sep 11, 2023

expand_class is slow for long class name that has no document.

irb(main):001> driver = RDoc::RI::Driver.new
=> 
#<RDoc::RI::Driver:0x0000000105c03180
...
irb(main):002> measure
TIME is added.
=> nil
irb(main):003> driver.expand_class('MyFooBarApp::FooBarController::FooBar') rescue nil
processing time: 0.227079s

It's because did_you_mean is slow and always calculated before raising NotFoundError.

This pull request delays calculation of DidYouMean until NotFoundError#message is called.
Processing time reduces 0.227079s → 0.006436s

Background

This will fix ruby/irb#709

@MatheusRich
Copy link
Contributor

Looks good to me. TY

@hsbt hsbt merged commit b59ca2f into ruby:master Oct 17, 2023
21 checks passed
@tompng tompng deleted the delay_notfounderror_didyoumean branch October 17, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Tab complete is slow when class name is long and undocumented
4 participants