Speed up cask search
Add new method to get all cask names without using Cask.all which is slow in this case.
This commit is contained in:
parent
ed3789a0bb
commit
363df2a648
@ -38,6 +38,16 @@ module Cask
|
|||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.full_names
|
||||||
|
Tap.flat_map do |tap|
|
||||||
|
next tap.cask_tokens.blank?
|
||||||
|
next tap.cask_tokens if tap.user == "Homebrew"
|
||||||
|
|
||||||
|
name = tap.name
|
||||||
|
tap.cask_tokens.map { |tok| "#{name}/#{tok}" }
|
||||||
|
end.flatten
|
||||||
|
end
|
||||||
|
|
||||||
def tap
|
def tap
|
||||||
return super if block_given? # Object#tap
|
return super if block_given? # Object#tap
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ module Homebrew
|
|||||||
results = cask_tokens.extend(Searchable)
|
results = cask_tokens.extend(Searchable)
|
||||||
.search(string_or_regex)
|
.search(string_or_regex)
|
||||||
|
|
||||||
cask_names = Cask::Cask.all.map(&:full_name)
|
cask_names = Cask::Cask.full_names
|
||||||
results += DidYouMean::SpellChecker.new(dictionary: cask_names)
|
results += DidYouMean::SpellChecker.new(dictionary: cask_names)
|
||||||
.correct(string_or_regex)
|
.correct(string_or_regex)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user