Skip to content

Commit

Permalink
Merge pull request #668 from CocoaPods/amorde/performance-improvements
Browse files Browse the repository at this point in the history
Minor performance improvements
  • Loading branch information
amorde authored Jan 9, 2021
2 parents 8da8c70 + 8792761 commit 9584a94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
19 changes: 12 additions & 7 deletions lib/cocoapods-core/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ def initialize(name = nil, *requirements)
# one or more version restrictions).
#
def requirement
if specific_version
Requirement.new(Version.new(specific_version.version))
else
@requirement
end
@specific_requirement || @requirement
end

# @param [Version] version the specific version to point to
#
def specific_version=(version)
@specific_version = version
@specific_requirement = if version
Requirement.new(Version.new(version.version))
end
end

# @return [Bool] whether the dependency points to a subspec.
Expand Down Expand Up @@ -196,9 +201,9 @@ def compatible?(other)
def ==(other)
self.class == other.class &&
name == other.name &&
requirement == other.requirement &&
external_source == other.external_source &&
podspec_repo == other.podspec_repo
podspec_repo == other.podspec_repo &&
requirement == other.requirement
end
alias_method :eql?, :==

Expand Down
9 changes: 8 additions & 1 deletion lib/cocoapods-core/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ def versions(name)
pod_dir = pod_path(name)
return unless pod_dir.exist?
@versions_by_name[name] ||= pod_dir.children.map do |v|
next nil unless v.directory?
basename = v.basename.to_s
next unless basename[0, 1] != '.'
begin
Version.new(basename) if v.directory? && basename[0, 1] != '.'
Version.new(basename)
rescue ArgumentError
raise Informative, 'An unexpected version directory ' \
"`#{basename}` was encountered for the " \
Expand Down Expand Up @@ -266,6 +268,11 @@ def search(query)
query = query.root_name
end

if (versions = @versions_by_name[query]) && !versions.empty?
set = set(query)
return set if set.specification_name == query
end

found = []
Pathname.glob(pod_path(query)) do |path|
next unless Dir.foreach(path).any? { |child| child != '.' && child != '..' }
Expand Down

0 comments on commit 9584a94

Please sign in to comment.