Commit bbd3d2c3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Avoid copy of strings in memory for parsing git grep result

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ff3b68ac
...@@ -442,8 +442,7 @@ class Repository ...@@ -442,8 +442,7 @@ class Repository
filename = nil filename = nil
startline = 0 startline = 0
lines = result.lines result.each_line.each_with_index do |line, index|
lines.each_with_index do |line, index|
if line =~ /^.*:.*:\d+:/ if line =~ /^.*:.*:\d+:/
ref, filename, startline = line.split(':') ref, filename, startline = line.split(':')
startline = startline.to_i - index startline = startline.to_i - index
...@@ -451,11 +450,11 @@ class Repository ...@@ -451,11 +450,11 @@ class Repository
end end
end end
data = lines.map do |line| data = ""
line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
end
data = data.join("") result.each_line do |line|
data << line.sub(ref, '').sub(filename, '').sub(/^:-\d+-/, '').sub(/^::\d+:/, '')
end
OpenStruct.new( OpenStruct.new(
filename: filename, filename: filename,
......
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