Commit 33627d2c authored by Robert May's avatar Robert May Committed by Rémy Coutable

Minor performance improvement for ref finder

Branch names are probably lowercase so using downcase is faster
most of the time. Also prevents re-downcasing the term every
iteration.
parent beba9e68
...@@ -33,15 +33,21 @@ class GitRefsFinder ...@@ -33,15 +33,21 @@ class GitRefsFinder
end end
def filter_refs_with_prefix(refs, prefix) def filter_refs_with_prefix(refs, prefix)
refs.select { |ref| ref.name.upcase.starts_with?(prefix.upcase) } prefix = prefix.downcase
refs.select { |ref| ref.name.downcase.starts_with?(prefix) }
end end
def filter_refs_with_suffix(refs, suffix) def filter_refs_with_suffix(refs, suffix)
refs.select { |ref| ref.name.upcase.ends_with?(suffix.upcase) } suffix = suffix.downcase
refs.select { |ref| ref.name.downcase.ends_with?(suffix) }
end end
def filter_refs_by_name(refs, term) def filter_refs_by_name(refs, term)
refs.select { |ref| ref.name.upcase.include?(term.upcase) } term = term.downcase
refs.select { |ref| ref.name.downcase.include?(term) }
end end
def set_exact_match_as_first_result(matches, term) def set_exact_match_as_first_result(matches, term)
......
---
title: Minor performance improvement for ref finder
merge_request: 58099
author:
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment