diff options
| author | Josh Hagins | 2016-10-12 03:42:22 -0400 |
|---|---|---|
| committer | GitHub | 2016-10-12 03:42:22 -0400 |
| commit | af78b64d5c88f4a2df32c043f8e8cffd50fd3067 (patch) | |
| tree | 0fa06873b3eba126240f3b326684014dfb123635 /Library | |
| parent | 7a3ba923240f7b9246abc2bb4d651ebe16a549df (diff) | |
| parent | d8a6863283048cd2cc1f7fb78178b2fc19420e0c (diff) | |
| download | brew-af78b64d5c88f4a2df32c043f8e8cffd50fd3067.tar.bz2 | |
Merge pull request #1258 from jawshooah/perf/keg-batch-text-files
keg_relocate: run /usr/bin/file in batches
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/keg_relocate.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 3f0f4c8ed..dcf592ae4 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -72,13 +72,14 @@ class Keg # file with that fix is only available in macOS Sierra. # http://bugs.gw.com/view.php?id=292 with_custom_locale("C") do - path.find do |pn| - next if pn.symlink? || pn.directory? - next if Metafiles::EXTENSIONS.include? pn.extname - if Utils.popen_read("/usr/bin/file", "--brief", pn).include?("text") || - pn.text_executable? - text_files << pn - end + files = path.find.reject { |pn| + pn.symlink? || pn.directory? || Metafiles::EXTENSIONS.include?(pn.extname) + } + output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --brief", + stdin_data: files.join("\0")) + output.each_line.with_index do |line, i| + next unless line.include?("text") + text_files << files[i] end end |
