Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
2c8ce4f6
Commit
2c8ce4f6
authored
Apr 10, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SourcesManager] Improve search performance
parent
3fe56ec1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
sources_manager.rb
lib/cocoapods/sources_manager.rb
+11
-2
No files found.
lib/cocoapods/sources_manager.rb
View file @
2c8ce4f6
...
...
@@ -59,6 +59,7 @@ module Pod
# @return [Array<Set>] The sets that contain the search term.
#
def
search_by_name
(
query
,
full_text_search
=
false
)
if
full_text_search
set_names
=
[]
updated_search_index
.
each
do
|
name
,
set_data
|
text
=
name
.
dup
...
...
@@ -69,8 +70,10 @@ module Pod
end
set_names
<<
name
if
text
.
downcase
.
include?
(
query
.
downcase
)
end
sets
=
set_names
.
sort
.
map
{
|
name
|
aggregate
.
represenative_set
(
name
)
}
else
sets
=
aggregate
.
search_by_name
(
query
,
false
)
end
if
sets
.
empty?
extra
=
", author, summary, or description"
if
full_text_search
raise
Informative
,
"Unable to find a pod with name
#{
extra
}
matching `
#{
query
}
`"
...
...
@@ -86,9 +89,13 @@ module Pod
# - description
# - authors
#
# @note This operation is fairly expensive, because of the YAML
# conversion.
#
# @return [Hash{String => String}] The up to date search data.
#
def
updated_search_index
unless
@updated_search_index
if
search_index_path
.
exist?
stored_index
=
YAML
.
load
(
search_index_path
.
read
)
if
stored_index
&&
stored_index
.
is_a?
(
Hash
)
...
...
@@ -101,7 +108,9 @@ module Pod
end
File
.
open
(
search_index_path
,
'w'
)
{
|
f
|
f
.
write
(
search_index
.
to_yaml
)
}
search_index
@updated_search_index
=
search_index
end
@updated_search_index
end
# @return [Pathname] The path where the search index should be stored.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment