Don't reload ActiveRecord objects when building note URLs
When we build a note URL, and we have the note loaded already, there are two cases: 1. The `noteable` is already loaded. In that case, this is faster as it doesn't build a new AR object from the query. 2. The `noteable` is not already loaded. In that case, this change is no worse than the previous code.
This commit is contained in:
parent
c17b1d5f56
commit
222a6b4680
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Improve issue rendering performance with lots of notes from other users
|
||||
merge_request:
|
||||
author:
|
|
@ -52,15 +52,13 @@ module Gitlab
|
|||
commit_url(id: object.commit_id, anchor: dom_id(object))
|
||||
|
||||
elsif object.for_issue?
|
||||
issue = Issue.find(object.noteable_id)
|
||||
issue_url(issue, anchor: dom_id(object))
|
||||
issue_url(object.noteable, anchor: dom_id(object))
|
||||
|
||||
elsif object.for_merge_request?
|
||||
merge_request = MergeRequest.find(object.noteable_id)
|
||||
merge_request_url(merge_request, anchor: dom_id(object))
|
||||
merge_request_url(object.noteable, anchor: dom_id(object))
|
||||
|
||||
elsif object.for_snippet?
|
||||
snippet = Snippet.find(object.noteable_id)
|
||||
snippet = object.noteable
|
||||
|
||||
if snippet.is_a?(PersonalSnippet)
|
||||
snippet_url(snippet, anchor: dom_id(object))
|
||||
|
|
Loading…
Reference in New Issue