Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't keep dep path set around

  • Loading branch information...
commit 17ab38768a3fbb8c61a8d83fc4d5bd1a56407709 1 parent b0013a4
@josh josh authored
Showing with 14 additions and 8 deletions.
  1. +2 −2 lib/sprockets/asset.rb
  2. +12 −6 lib/sprockets/processed_asset.rb
View
4 lib/sprockets/asset.rb
@@ -42,14 +42,14 @@ def initialize(environment, logical_path, pathname)
@length = environment.stat(pathname).size
@digest = environment.file_digest(pathname).hexdigest
- @dependency_paths = Set.new
+ @dependency_paths = []
end
# Initialize `Asset` from serialized `Hash`.
def init_with(environment, coder)
@root = environment.root
- @dependency_paths = Set.new
+ @dependency_paths = []
@logical_path = coder['logical_path']
@content_type = coder['content_type']
View
18 lib/sprockets/processed_asset.rb
@@ -35,17 +35,23 @@ def initialize(environment, logical_path, pathname)
required_assets_cache.clear
required_assets_cache = nil
+ dependency_paths = {}
context._dependency_paths.each do |path|
- @dependency_paths << DependencyFile.new(path, environment.stat(path).mtime, environment.file_digest(path).hexdigest)
+ dep = DependencyFile.new(path, environment.stat(path).mtime, environment.file_digest(path).hexdigest)
+ dependency_paths[dep] = true
end
context._dependency_assets.each do |path|
if path == self.pathname.to_s
- @dependency_paths << DependencyFile.new(pathname, mtime, digest)
+ dep = DependencyFile.new(pathname, mtime, digest)
+ dependency_paths[dep] = true
elsif asset = environment.find_asset(path, :bundle => false)
- @dependency_paths.merge(asset.dependency_paths)
+ asset.dependency_paths.each do |d|
+ dependency_paths[d] = true
+ end
end
end
+ @dependency_paths = dependency_paths.keys
elapsed_time = ((Time.now.to_f - start_time) * 1000).to_i
environment.logger.info "Compiled #{logical_path} (#{elapsed_time}ms) (pid #{Process.pid})"
@@ -62,9 +68,9 @@ def init_with(environment, coder)
p = expand_root_path(p)
p == pathname.to_s ? self : environment.find_asset(p, :bundle => false)
}
- @dependency_paths = Set.new(coder['dependency_paths'].map { |h|
+ @dependency_paths = coder['dependency_paths'].map { |h|
DependencyFile.new(expand_root_path(h['path']), h['mtime'], h['digest'])
- })
+ }
end
# Serialize custom attributes in `BundledAsset`.
@@ -75,7 +81,7 @@ def encode_with(coder)
coder['required_paths'] = required_assets.map { |a|
relativize_root_path(a.pathname).to_s
}
- coder['dependency_paths'] = @dependency_paths.map { |d|
+ coder['dependency_paths'] = dependency_paths.map { |d|
{ 'path' => relativize_root_path(d.pathname).to_s,
'mtime' => d.mtime.iso8601,
'digest' => d.digest }
Please sign in to comment.
Something went wrong with that request. Please try again.