Commit 78c6f0e6 authored by Boris Bügling's avatar Boris Bügling

Merge pull request #3699 from vincentisambart/vi-cache-paths_for_attribute

Cache globbing in PathList to speed up pod install
parents 4263c6ad 844e3003
...@@ -51,6 +51,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -51,6 +51,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Dieter Komendera](https://github.com/kommen) [Dieter Komendera](https://github.com/kommen)
[#2402](https://github.com/CocoaPods/CocoaPods/issues/2402) [#2402](https://github.com/CocoaPods/CocoaPods/issues/2402)
* Cache globbing in `PathList` to speed up `pod install`.
[Vincent Isambart](https://github.com/vincentisambart)
##### Bug Fixes ##### Bug Fixes
* Added recursive support to the public headers of vendored frameworks * Added recursive support to the public headers of vendored frameworks
......
...@@ -21,6 +21,7 @@ module Pod ...@@ -21,6 +21,7 @@ module Pod
# #
def initialize(root) def initialize(root)
@root = root @root = root
@glob_cache = {}
end end
# @return [Array<String>] The list of absolute the path of all the files # @return [Array<String>] The list of absolute the path of all the files
...@@ -55,6 +56,7 @@ module Pod ...@@ -55,6 +56,7 @@ module Pod
relative_paths = absolute_paths.map { |p| p[root_length..-1] } relative_paths = absolute_paths.map { |p| p[root_length..-1] }
@files = relative_paths - relative_dirs @files = relative_paths - relative_dirs
@dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/, '') }.reject { |d| d == '.' || d == '..' } .uniq @dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/, '') }.reject { |d| d == '.' || d == '..' } .uniq
@glob_cache = {}
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -101,6 +103,10 @@ module Pod ...@@ -101,6 +103,10 @@ module Pod
def relative_glob(patterns, options = {}) def relative_glob(patterns, options = {})
return [] if patterns.empty? return [] if patterns.empty?
cache_key = options.merge(:patterns => patterns)
cached_value = @glob_cache[cache_key]
return cached_value if cached_value
dir_pattern = options[:dir_pattern] dir_pattern = options[:dir_pattern]
exclude_patterns = options[:exclude_patterns] exclude_patterns = options[:exclude_patterns]
include_dirs = options[:include_dirs] include_dirs = options[:include_dirs]
...@@ -112,19 +118,15 @@ module Pod ...@@ -112,19 +118,15 @@ module Pod
end end
list = Array(patterns).map do |pattern| list = Array(patterns).map do |pattern|
if pattern.is_a?(String) if directory?(pattern) && dir_pattern
if directory?(pattern) && dir_pattern pattern += '/' unless pattern.end_with?('/')
pattern += '/' unless pattern.end_with?('/') pattern += dir_pattern
pattern += dir_pattern end
end expanded_patterns = dir_glob_equivalent_patterns(pattern)
expanded_patterns = dir_glob_equivalent_patterns(pattern) full_list.select do |path|
full_list.select do |path| expanded_patterns.any? do |p|
expanded_patterns.any? do |p| File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME)
File.fnmatch(p, path, File::FNM_CASEFOLD | File::FNM_PATHNAME)
end
end end
else
full_list.select { |path| path.match(pattern) }
end end
end.flatten end.flatten
...@@ -133,7 +135,7 @@ module Pod ...@@ -133,7 +135,7 @@ module Pod
exclude_options = { :dir_pattern => '**/*', :include_dirs => include_dirs } exclude_options = { :dir_pattern => '**/*', :include_dirs => include_dirs }
list -= relative_glob(exclude_patterns, exclude_options) list -= relative_glob(exclude_patterns, exclude_options)
end end
list @glob_cache[cache_key] = list
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment