Skip to content

Commit

Permalink
Memoize _sorted_requirements and _tilde_requirements which can be use…
Browse files Browse the repository at this point in the history
…d multiple times during same comparison
  • Loading branch information
toy committed Sep 3, 2020
1 parent e241b74 commit a1b8dac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubygems/requirement.rb
Expand Up @@ -283,11 +283,11 @@ def ==(other) # :nodoc:
protected

def _sorted_requirements
requirements.sort_by(&:to_s)
@_sorted_requirements ||= requirements.sort_by(&:to_s)
end

def _tilde_requirements
_sorted_requirements.select {|r| r.first == "~>" }
@_tilde_requirements ||= _sorted_requirements.select {|r| r.first == "~>" }
end

private
Expand Down

0 comments on commit a1b8dac

Please sign in to comment.