summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2025-10-14 17:30:52 -0700
committergit <svn-admin@ruby-lang.org>2025-10-15 02:05:45 +0000
commit8d438678023aa453717954bb519308b5c3eec0fe (patch)
tree765118257b44ee3f0f924097b3ea84740bcb7b97
parentdf5d63cfa2af8902526d83775bec8192e29fcd1b (diff)
[rubygems/rubygems] remove some memoization
I don't think these methods are hotspots, and since gem specifications are sometimes serialized to yaml / marshal, I think we should remove as many instance variables as possible https://github.com/rubygems/rubygems/commit/40490d918b
-rw-r--r--lib/rubygems/specification.rb26
1 files changed, 2 insertions, 24 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 1d351f8aff..ea7b58f20e 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -488,8 +488,6 @@ class Gem::Specification < Gem::BasicSpecification
end
@platform = @new_platform.to_s
-
- invalidate_memoized_attributes
end
##
@@ -1620,14 +1618,14 @@ class Gem::Specification < Gem::BasicSpecification
# spec's cached gem.
def cache_dir
- @cache_dir ||= File.join base_dir, "cache"
+ File.join base_dir, "cache"
end
##
# Returns the full path to the cached gem for this spec.
def cache_file
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
+ File.join cache_dir, "#{full_name}.gem"
end
##
@@ -1903,10 +1901,6 @@ class Gem::Specification < Gem::BasicSpecification
spec
end
- def full_name
- @full_name ||= super
- end
-
##
# Work around old bundler versions removing my methods
# Can be removed once RubyGems can no longer install Bundler 2.5
@@ -2044,17 +2038,6 @@ class Gem::Specification < Gem::BasicSpecification
end
end
- ##
- # Expire memoized instance variables that can incorrectly generate, replace
- # or miss files due changes in certain attributes used to compute them.
-
- def invalidate_memoized_attributes
- @full_name = nil
- @cache_file = nil
- end
-
- private :invalidate_memoized_attributes
-
def inspect # :nodoc:
if $DEBUG
super
@@ -2093,8 +2076,6 @@ class Gem::Specification < Gem::BasicSpecification
def internal_init # :nodoc:
super
@bin_dir = nil
- @cache_dir = nil
- @cache_file = nil
@doc_dir = nil
@ri_dir = nil
@spec_dir = nil
@@ -2606,9 +2587,6 @@ class Gem::Specification < Gem::BasicSpecification
def version=(version)
@version = Gem::Version.create(version)
- return if @version.nil?
-
- invalidate_memoized_attributes
end
def stubbed?