-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Use a cache when figuring out if a pod target is test only #6787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d87678f
to
73d8be7
Compare
lib/cocoapods/installer/analyzer.rb
Outdated
if @analyzer_cache.key?(key) | ||
return @analyzer_cache[key] | ||
end | ||
source = pod_targets.any? { |pt| pt.dependent_targets.map(&:name).include?(name) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts welcome on how to combine this perhaps and make it faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 fixing
lib/cocoapods/installer/analyzer.rb
Outdated
@@ -46,6 +46,7 @@ def initialize(sandbox, podfile, lockfile = nil) | |||
@update = false | |||
@allow_pre_downloads = true | |||
@has_dependencies = true | |||
@analyzer_cache = {} | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name this after what it is caching
lib/cocoapods/installer/analyzer.rb
Outdated
test = pod_targets.any? { |pt| pt.test_dependent_targets.map(&:name).include?(pod_target.name) } | ||
!source && test | ||
name = pod_target.name | ||
key = [name, pod_targets] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how often this is hit, it might be worth using a struct as the key instead of an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Will attempt it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-->@segiddins done! Still works :)
Fixed the naming problem and rubocop. Looking intro struct way but I think it might be OK anyway. |
✅ |
As of CP 1.3.0.beta.1 this method would add 7-10 seconds to out pod install time.
This adds a cache to the result but also prevents a number of calls to this method if they are not needed by short circuiting earlier.
There are no tests for this PR because the logic is the same. I hot patched CocoaPods for us and the
pod install
now remains the same.