Skip to content

Commit

Permalink
Merge pull request #789 from RubenVerborgh/fix-memoize-checksum-calcu…
Browse files Browse the repository at this point in the history
…lation

Avoid double calculation of checksum
  • Loading branch information
denisdefreyne committed Dec 31, 2015
2 parents a1ad64d + 5198aea commit 56c927d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/nanoc/base/compilation/outdatedness_checker.rb
Expand Up @@ -172,12 +172,20 @@ def rule_memory_differs_for(obj)
end
memoize :rule_memory_differs_for

# @param obj The object to create a checksum for
#
# @return [String] The digest
def calc_checksum(obj)
Nanoc::Int::Checksummer.calc(obj)
end
memoize :calc_checksum

# @param obj
#
# @return [Boolean] false if either the new or the old checksum for the
# given object is not available, true if both checksums are available
def checksums_available?(obj)
checksum_store[obj] && Nanoc::Int::Checksummer.calc(obj)
checksum_store[obj] && calc_checksum(obj)
end
memoize :checksums_available?

Expand All @@ -186,7 +194,7 @@ def checksums_available?(obj)
# @return [Boolean] false if the old and new checksums for the given
# object differ, true if they are identical
def checksums_identical?(obj)
checksum_store[obj] == Nanoc::Int::Checksummer.calc(obj)
checksum_store[obj] == calc_checksum(obj)
end
memoize :checksums_identical?

Expand Down

0 comments on commit 56c927d

Please sign in to comment.