Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-17 19:22:45 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-17 19:22:45 +0300
commit67fb9ef2668d4cb23cd39f43d2c128c89881f274 (patch)
tree7d0194261e82397e51002d1178edd65aac2da290 /app/models
parent53d9f78043b9743e45cf170baca21d56d92af052 (diff)
parentbbd3d2c39d2068411f8d8067655d6b139a8a4201 (diff)
Merge branch 'even-faster-search' into 'master'
Avoid copy of strings in memory for parsing git grep result Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !967
Diffstat (limited to 'app/models')
-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 2985619fd2e..1d208aa71c4 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -449,8 +449,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
@@ -458,11 +457,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,