Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
450c0d90
Commit
450c0d90
authored
Nov 21, 2019
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract file_identifiers to avoid looping
parent
c3fd0190
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
lib/gitlab/diff/highlight_cache.rb
lib/gitlab/diff/highlight_cache.rb
+6
-3
No files found.
lib/gitlab/diff/highlight_cache.rb
View file @
450c0d90
...
...
@@ -12,7 +12,6 @@ module Gitlab
@backend
=
backend
@diff_collection
=
diff_collection
@redis_key
=
"highlighted-diff-files:
#{
diffable
.
cache_key
}
"
@file_identifiers
=
@diff_collection
.
diff_files
.
collect
(
&
:file_identifier
)
end
# - Reads from cache
...
...
@@ -81,6 +80,10 @@ module Gitlab
private
def
file_identifiers
@file_identifiers
||=
@diff_collection
.
diff_files
.
collect
(
&
:file_identifier
)
end
def
read_file
(
diff_file
)
cached_content
[
diff_file
.
file_identifier
]
end
...
...
@@ -93,14 +96,14 @@ module Gitlab
results
=
[]
Redis
::
Cache
.
with
do
|
redis
|
results
=
redis
.
hmget
(
@redis_key
,
@
file_identifiers
)
results
=
redis
.
hmget
(
@redis_key
,
file_identifiers
)
end
results
.
map!
do
|
result
|
JSON
.
parse
(
result
,
symbolize_names:
true
)
unless
result
.
nil?
end
@
file_identifiers
.
zip
(
results
).
to_h
file_identifiers
.
zip
(
results
).
to_h
end
def
cacheable?
(
diff_file
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment