sstephenson/sprockets — pull request #466 by schneems (2013-08-14 03:00:36+00:00)
Title: Refactor redundant code

In `environment.rb` we check to see if an asset is in the cache and if it is fresh:

```ruby
(asset = @assets[cache_key_for(path, options)]) && asset.fresh?(self)
```

If the asset exists but is not fresh it hits `index.find_asset(path, options)`. Inside of `Index#find_asset` we return a cached asset if it exists:

```ruby
if asset = @assets[cache_key_for(path, options)]
asset
```

So if the asset is cached (at all, regardless of freshness) it will be returned. Otherwise it will hit the edge case inside of `Index#find_asset`

This code is identical in behavior to the previous code, but only incurs 1 cache check instead of 2 in worst case scenario and we never have to check for `fresh?`.

ATP