Sidebar runs 2 queries for rendering labels instead of 1
In the view
app/views/shared/issuable/_sidebar.html.haml starting at line 124 there's the following code:
- if issuable.labels.any? - issuable.labels.each do |label| = link_to_label(label, type: issuable.to_ability_name) - else .light None
issuable.labels.each will run a query. I believe if one were to use
labels.empty? instead it will load the labels and use
Array#empty?. Should there be no labels this won't really have any impact on memory usage and in case there are labels the data is already loaded into memory anyway. In both cases however this would (unless I'm mistaken) result in only a single query being needed, instead of 2.