diff options
author | Drew Blessing <drew@blessing.io> | 2018-10-17 20:03:15 -0400 |
---|---|---|
committer | Drew Blessing <drew@blessing.io> | 2018-10-31 15:50:30 -0500 |
commit | 409f2f4dd2888f88df2293466c37c768b94068e5 (patch) | |
tree | c8061f8135e6657d7a7185f0f56e5757b4c5f0a0 /spec/views | |
parent | 43463869c883c7972ecc03500ab35325eede7a01 (diff) | |
download | gitlab-ce-409f2f4dd2888f88df2293466c37c768b94068e5.tar.gz |
Improve performance of tree rendering in repositories with lots of items
Rails is slow to generate paths dynamically especially when called
hundreds/thousands of times. Also, rendering many partials hundreds
of times can be slower. This change reduces the number of partials
rendered and introduces two fast path methods to speed up path
generation.
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/tree/_tree_row.html.haml_spec.rb (renamed from spec/views/projects/tree/_blob_item.html.haml_spec.rb) | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/spec/views/projects/tree/_blob_item.html.haml_spec.rb b/spec/views/projects/tree/_tree_row.html.haml_spec.rb index 6a477c712ff..3353b7665e2 100644 --- a/spec/views/projects/tree/_blob_item.html.haml_spec.rb +++ b/spec/views/projects/tree/_tree_row.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/tree/_blob_item' do +describe 'projects/tree/_tree_row' do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first } @@ -31,10 +31,7 @@ describe 'projects/tree/_blob_item' do end end - def render_partial(blob_item) - render partial: 'projects/tree/blob_item', locals: { - blob_item: blob_item, - type: 'blob' - } + def render_partial(items) + render partial: 'projects/tree/tree_row', collection: [items].flatten end end |