Skip to content

Commit

Permalink
Use Hamster::Set in checksummer for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Jul 1, 2016
1 parent 83c839c commit 89f76fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/nanoc/base/checksummer.rb
@@ -1,3 +1,5 @@
require 'hamster'

module Nanoc::Int
# Creates checksums for given objects.
#
Expand Down Expand Up @@ -46,14 +48,14 @@ def calc(obj, digest_class = CompactDigest)

private

def update(obj, digest, visited = Set.new)
def update(obj, digest, visited = Hamster::Set.new)
digest.update(obj.class.to_s)

if visited.include?(obj)
digest.update('<recur>')
else
digest.update('<')
behavior_for(obj).update(obj, digest) { |o| update(o, digest, visited + [obj]) }
behavior_for(obj).update(obj, digest) { |o| update(o, digest, visited.add(obj)) }
digest.update('>')
end
end
Expand Down
1 change: 1 addition & 0 deletions nanoc.gemspec
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.1.0'

s.add_runtime_dependency('cri', '~> 2.3')
s.add_runtime_dependency('hamster', '~> 3.0')

s.add_development_dependency('bundler', '>= 1.7.10', '< 2.0')
end

0 comments on commit 89f76fa

Please sign in to comment.