From edeeefb7a544aadf2f788c8c6f88cb77bd941ac0 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 8 Jan 2008 10:49:19 +0000 Subject: [PATCH] Speed up Marshal load, fix bug with nested classes' methods git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rdoc/ri/driver.rb | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff29296ec0..79be39f964 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jan 8 19:48:15 2008 Eric Hodel + + * lib/rdoc/ri/driver.rb: Speed up Marshal.load. Fix bug with nested + classes' methods. + Tue Jan 8 19:17:29 2008 Eric Hodel * lib/rdoc/*: Clean up namespacing of RI's classes. diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index 9b1e3bea30..98e8a3dc2e 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -267,13 +267,13 @@ Options may also be set in the 'RI' environment variable. if File.exist? path and File.mtime(path) >= File.mtime(class_cache_file_path) then File.open path, 'rb' do |fp| - Marshal.load fp + Marshal.load fp.read end else class_cache = nil File.open class_cache_file_path, 'rb' do |fp| - class_cache = Marshal.load fp + class_cache = Marshal.load fp.read end klass = class_cache[klassname] @@ -354,7 +354,12 @@ Options may also be set in the 'RI' environment variable. if class_cache.key? name then display_class name else - klass, meth = name.split(/::|\#|\./) + meth = nil + + parts = name.split(/::|\#|\./) + meth = parts.pop unless parts.last =~ /^[A-Z]/ + klass = parts.join '::' + cache = load_cache_for klass # HACK Does not support F.n abort "Nothing known about #{name}" unless cache