From 4fa3cd3a6231ac90fee8c1a869445b8de11a320e Mon Sep 17 00:00:00 2001 From: Francois Buys Date: Thu, 10 Apr 2025 21:25:23 +0200 Subject: [PATCH 1/2] BUG-149: Fix compatibilities performance bug Use fetcher instead of new when we use Gem::SpecFetcher Fixes: https://github.com/fastruby/next_rails/issues/149 --- lib/next_rails/gem_info.rb | 2 +- spec/next_rails/gem_info_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/next_rails/gem_info.rb b/lib/next_rails/gem_info.rb index d6060f9..1f9897f 100644 --- a/lib/next_rails/gem_info.rb +++ b/lib/next_rails/gem_info.rb @@ -109,7 +109,7 @@ def unsatisfied_rails_dependencies(rails_version: nil) def find_latest_compatible(rails_version: nil) dependency = Gem::Dependency.new(@name) - fetcher = Gem::SpecFetcher.new + fetcher = Gem::SpecFetcher.fetcher # Use fetcher instead of ::new to reduce object allocation. # list all available data for released gems list, errors = fetcher.available_specs(:released) diff --git a/spec/next_rails/gem_info_spec.rb b/spec/next_rails/gem_info_spec.rb index 043a741..98a7191 100644 --- a/spec/next_rails/gem_info_spec.rb +++ b/spec/next_rails/gem_info_spec.rb @@ -83,7 +83,7 @@ # Set up a mock SpecFetcher to return an empty list fetcher_double = double("spec_fetcher") allow(fetcher_double).to receive(:available_specs).and_return([[],[]]) - allow(Gem::SpecFetcher).to receive(:new).and_return(fetcher_double) + allow(Gem::SpecFetcher).to receive(:fetcher).and_return(fetcher_double) gem_info = NextRails::GemInfo.new(gem) gem_info.find_latest_compatible From f1df7f667aa8537e64113df9b845e2e1e2638915 Mon Sep 17 00:00:00 2001 From: Francois Buys Date: Thu, 10 Apr 2025 21:35:21 +0200 Subject: [PATCH 2/2] BUG-149: Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4796bf0..62b4b45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Your changes/patches go here. +- [BUFIX: Fix compatibilities performance bug](https://github.com/fastruby/next_rails/pull/150) + # v1.4.5 / 2025-03-07 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.4...v1.4.5) - [Move rails_version compatibility to its own class](https://github.com/fastruby/next_rails/pull/137)