summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-13 11:27:25 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-13 11:27:25 +0200
commitbbd3d2c39d2068411f8d8067655d6b139a8a4201 (patch)
treecb279d1acc3e98492a9678f05fb351b5ea525d79
parentff3b68ac93f3556a45679a928d86fb6fc81cb98b (diff)
downloadgitlab-ce-even-faster-search.tar.gz
Avoid copy of strings in memory for parsing git grep resulteven-faster-search
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/models/repository.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 6262b5c4c92..c0bc1829e82 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -442,8 +442,7 @@ class Repository
filename = nil
startline = 0
- lines = result.lines
- lines.each_with_index do |line, index|
+ result.each_line.each_with_index do |line, index|
if line =~ /^.*:.*:\d+:/
ref, filename, startline = line.split(':')
startline = startline.to_i - index
@@ -451,11 +450,11 @@ class Repository
end
end
- data = lines.map do |line|
- line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
- end
+ data = ""
- data = data.join("")
+ result.each_line do |line|
+ data << line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
+ end
OpenStruct.new(
filename: filename,