gitlabhq/gitlabhq — pull request #1627 by tsigo (2012-10-03 23:48:17+00:00)
Title: Tree performance improvements

After speeding up the Commits page a bit, I started on the Tree page.

Surprisingly, the single biggest bottleneck was the `tree_icon` helper. I simplified it, but at the cost of only having two icons: one for folders, one for not-folders. I think it's a worthy tradeoff.

Benchmark code

```ruby
# Run tree_icon on GitLab's tree 10 times

require 'benchmark'
require_relative 'config/environment'

p = Project.find_by_code('gitlabhq')
t = p.repo.tree.contents

include TreeHelper

def image_tag(*args)
end

Benchmark.bm do |x|
x.report { 10.times { t.each { |v| tree_icon(v) } } }
end
```

Results:

```
master	1.590000 24.690000 26.280000 ( 26.290603)
performance	0.000000 0.000000 0.000000 ( 0.000202)
```

Crazy, right?

The rest of the PR is just some refactoring of the tree views. Removes a bunch of logic from them that either wasn't necessary or better fit in a helper.

Finally, I updated Grit to the 2.5.0 official gem (I did it looking for any performance improvements, but we might as well switch to it anyway).