diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-18 17:48:27 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-18 17:48:27 +0200 |
commit | 19300a1a3dff8974a3e653d71dcc9d528436efd8 (patch) | |
tree | c8e281ddae7fe430e521a339d5992a4b46bb82fc /lib | |
parent | 3032a0ca891808c9aa1ba69d540bf97e40a84670 (diff) | |
parent | 146e0cbc4dfb857e0eb44777c40da5df56f376e0 (diff) | |
download | gitlab-ce-19300a1a3dff8974a3e653d71dcc9d528436efd8.tar.gz |
Merge remote-tracking branch 'origin/master' into 22191-delete-dynamic-envs-mr22191-delete-dynamic-envs-mr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/file.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/diff/file_collection/merge_request_diff.rb | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index e47df508ca2..ce85e5e0123 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -125,6 +125,10 @@ module Gitlab repository.blob_at(commit.id, file_path) end + + def cache_key + "#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}" + end end end end diff --git a/lib/gitlab/diff/file_collection/merge_request_diff.rb b/lib/gitlab/diff/file_collection/merge_request_diff.rb index 36348b33943..dc4d47c878b 100644 --- a/lib/gitlab/diff/file_collection/merge_request_diff.rb +++ b/lib/gitlab/diff/file_collection/merge_request_diff.rb @@ -35,16 +35,16 @@ module Gitlab # for the highlighted ones, so we just skip their execution. # If the highlighted diff files lines are not cached we calculate and cache them. # - # The content of the cache is a Hash where the key correspond to the file_path and the values are Arrays of + # The content of the cache is a Hash where the key identifies the file and the values are Arrays of # hashes that represent serialized diff lines. # def cache_highlight!(diff_file) - file_path = diff_file.file_path + item_key = diff_file.cache_key - if highlight_cache[file_path] - highlight_diff_file_from_cache!(diff_file, highlight_cache[file_path]) + if highlight_cache[item_key] + highlight_diff_file_from_cache!(diff_file, highlight_cache[item_key]) else - highlight_cache[file_path] = diff_file.highlighted_diff_lines.map(&:to_hash) + highlight_cache[item_key] = diff_file.highlighted_diff_lines.map(&:to_hash) end end |