Skip to content

Commit 9f07d27

Browse files
authored
Merge pull request #150 from fbuys/bug/compatibilities
BUG-149: Fix compatibilities performance bug
2 parents af01649 + f1df7f6 commit 9f07d27

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Your changes/patches go here.
66

7+
- [BUFIX: Fix compatibilities performance bug](https://github.com/fastruby/next_rails/pull/150)
8+
79
# v1.4.5 / 2025-03-07 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.4...v1.4.5)
810

911
- [Move rails_version compatibility to its own class](https://github.com/fastruby/next_rails/pull/137)

lib/next_rails/gem_info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def unsatisfied_rails_dependencies(rails_version: nil)
109109

110110
def find_latest_compatible(rails_version: nil)
111111
dependency = Gem::Dependency.new(@name)
112-
fetcher = Gem::SpecFetcher.new
112+
fetcher = Gem::SpecFetcher.fetcher # Use fetcher instead of ::new to reduce object allocation.
113113

114114
# list all available data for released gems
115115
list, errors = fetcher.available_specs(:released)

spec/next_rails/gem_info_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
# Set up a mock SpecFetcher to return an empty list
8484
fetcher_double = double("spec_fetcher")
8585
allow(fetcher_double).to receive(:available_specs).and_return([[],[]])
86-
allow(Gem::SpecFetcher).to receive(:new).and_return(fetcher_double)
86+
allow(Gem::SpecFetcher).to receive(:fetcher).and_return(fetcher_double)
8787

8888
gem_info = NextRails::GemInfo.new(gem)
8989
gem_info.find_latest_compatible

0 commit comments

Comments
 (0)