Skip to content

Commit

Permalink
Backport #331 - Asset lookup 4x Faster
Browse files Browse the repository at this point in the history
With this patch using the benchmark script https://github.com/schneems/sprockets-3.x-performance-regressions:

```
1500 lookups of the same asset took 2.900005
1500 lookups of 1500 different assets took 2.746331
```

Without this patch using the benchmark script:

```
1500 lookups of the same asset took 12.361615
1500 lookups of 1500 different assets took 12.627099
```

Which is a 4x speed bump.
  • Loading branch information
schneems committed Jul 1, 2016
1 parent 697269c commit 4955eff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/sprockets/resolve.rb
Expand Up @@ -178,6 +178,7 @@ def dirname_matches(dirname, basename)
candidates = []
entries = self.entries(dirname)
entries.each do |entry|
next unless File.basename(entry).start_with?(basename)
name, type, _, _ = parse_path_extnames(entry)
if basename == name
candidates << [File.join(dirname, entry), type]
Expand Down

0 comments on commit 4955eff

Please sign in to comment.