search --desc: cache the query regexp

Closes Homebrew/homebrew#40795.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-06-16 23:08:00 +02:00
parent 72cb403a56
commit 4648aa54c0

View File

@ -23,8 +23,9 @@ module Homebrew
exec_browser "http://packages.ubuntu.com/search?keywords=#{ARGV.next}&searchon=names&suite=all&section=all"
elsif ARGV.include? '--desc'
query = ARGV.next
rx = query_regexp(query)
Formula.each do |formula|
if formula.desc =~ query_regexp(query)
if formula.desc =~ rx
puts "#{formula.full_name}: #{formula.desc}"
end
end