Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform regexp escape on individual words before joining them #10

Merged
merged 3 commits into from Oct 25, 2015

Conversation

manuyavuz
Copy link
Member

To complete changes discussed in #8, we need to change Regexp escaping a little.

Specifically, current implementation performs escape after joining all query argument into a string. For example, while running pod search --full network library command, a string like "network\ library" will be generated (they joined with space character, then whole string is escaped). This cause a problem inside SourcesManager. Because it needs to search for each query word individually and then return an intersection of individual results, it needs to split given query string to get individual words.

Proposed implementation performs regexp escape on individual query arguments first, then joins escaped strings with space character.

@@ -73,8 +73,9 @@ def web_search
end

def local_search
query_regex = @query.join(' ').strip
query_regex = Regexp.escape(query_regex) unless @use_regex
query_regex = @query.reduce('') { |result, q|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too you could use an Array.new, and result << (@use_regex ? q : Regexp.escape(q)), then join before stripping.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -16,7 +16,7 @@ class Search < Command
def self.options
[
['--regex', 'Interpret the `QUERY` as a regular expression'],
['--full', 'Search by name, summary, and description'],
['--full', 'Search by name, summary, description and authors'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Oxford comma

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked this fact :)

@segiddins
Copy link
Member

👍🏻 with specs and CHANGELOG

@floere
Copy link
Member

floere commented Oct 25, 2015

Good to go from me 🚀

segiddins added a commit that referenced this pull request Oct 25, 2015
Perform regexp escape on individual words before joining them
@segiddins segiddins merged commit 4e7de92 into CocoaPods:master Oct 25, 2015
@manuyavuz manuyavuz deleted the imp/searchPerformance branch October 26, 2015 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants