PERF: Memoize PostRevisor#diff_size (#8939)
Although this method is usually called twice, its execution can take about 1s.
This commit is contained in:
parent
9c96511ec4
commit
82c84c5141
|
@ -287,8 +287,10 @@ class PostRevisor
|
|||
end
|
||||
|
||||
def diff_size(before, after)
|
||||
ONPDiff.new(before, after).short_diff.sum do |str, type|
|
||||
type == :common ? 0 : str.size
|
||||
@diff_size ||= begin
|
||||
ONPDiff.new(before, after).short_diff.sum do |str, type|
|
||||
type == :common ? 0 : str.size
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue