Skip to content

Delay DidYouMean until NotFoundError#message is called#1039

Merged
hsbt merged 1 commit intoruby:masterfrom
tompng:delay_notfounderror_didyoumean
Oct 17, 2023
Merged

Delay DidYouMean until NotFoundError#message is called#1039
hsbt merged 1 commit intoruby:masterfrom
tompng:delay_notfounderror_didyoumean

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
@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

Projects

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