diff --git a/lib/puppet/catalog-diff/comparer.rb b/lib/puppet/catalog-diff/comparer.rb index 1ce6318..7bf8b3e 100644 --- a/lib/puppet/catalog-diff/comparer.rb +++ b/lib/puppet/catalog-diff/comparer.rb @@ -1,4 +1,5 @@ require 'puppet/util/diff' +require 'digest' module Puppet::CatalogDiff module Comparer # Creates an array of just the resource titles @@ -109,7 +110,7 @@ def return_resource_diffs(r1, r2) differences end - def str_diff(str1, str2) + def do_str_diff(str1, str2) paths = [str1,str2].collect do |s| tempfile = Tempfile.new("puppet-diffing") tempfile.open @@ -121,5 +122,12 @@ def str_diff(str1, str2) paths.each { |f| f.delete } diff end + + def str_diff(str1, str2) + @@cached_str_diffs ||= {} + sum1 = Digest::MD5.hexdigest str1 + sum2 = Digest::MD5.hexdigest str2 + @@cached_str_diffs["#{sum1}/#{sum2}"] ||= do_str_diff(str1, str2) + end end end