1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

irb: defer requiring rdoc to improve the start up time

This commit is contained in:
Nobuyoshi Nakada 2019-06-10 21:07:24 +09:00
parent 973fd18f11
commit 976c689ad4
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 10 additions and 7 deletions

View file

@ -9,17 +9,18 @@
#
#
require 'rdoc/ri/driver'
require_relative "nop"
# :stopdoc:
module IRB
module ExtendCommand
class Help < Nop
begin
Ri = RDoc::RI::Driver.new
rescue SystemExit
def execute(*names)
require 'rdoc/ri/driver'
IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new)
rescue LoadError, SystemExit
IRB::ExtendCommand::Help.remove_method(:execute)
# raise NoMethodError in ensure
else
def execute(*names)
if names.empty?
@ -35,6 +36,8 @@ module IRB
end
nil
end
ensure
execute(*names)
end
end
end

View file

@ -8,7 +8,7 @@
#
require "readline"
require "rdoc"
autoload :RDoc, "rdoc"
module IRB
module InputCompletor # :nodoc:
@ -267,8 +267,8 @@ module IRB
end
end
RDocRIDriver = RDoc::RI::Driver.new
PerfectMatchedProc = ->(matched) {
RDocRIDriver ||= RDoc::RI::Driver.new
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
RDocRIDriver.page do |io|