diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-17 16:22:45 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-17 16:22:45 +0000 |
commit | 67fb9ef2668d4cb23cd39f43d2c128c89881f274 (patch) | |
tree | 7d0194261e82397e51002d1178edd65aac2da290 /app/models/repository.rb | |
parent | 53d9f78043b9743e45cf170baca21d56d92af052 (diff) | |
parent | bbd3d2c39d2068411f8d8067655d6b139a8a4201 (diff) | |
download | gitlab-ce-67fb9ef2668d4cb23cd39f43d2c128c89881f274.tar.gz |
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/repository.rb')
-rw-r--r-- | app/models/repository.rb | 11 |
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, |