Skip to content

Commit 6123e14

Browse files
committed
Backport #331 - Asset lookup 4x Faster in large directories
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.
1 parent 697269c commit 6123e14

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/sprockets/resolve.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def dirname_matches(dirname, basename)
178178
candidates = []
179179
entries = self.entries(dirname)
180180
entries.each do |entry|
181+
next unless File.basename(entry).start_with?(basename)
181182
name, type, _, _ = parse_path_extnames(entry)
182183
if basename == name
183184
candidates << [File.join(dirname, entry), type]

0 commit comments

Comments
 (0)