diff --git a/lib/haml/util.rb b/lib/haml/util.rb index 7b8ae8c4..2a7b0774 100755 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -21,6 +21,8 @@ module Haml # @api public RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby" + @@version_comparison_cache = {} + # Returns the path of a file relative to the Haml root directory. # # @param file [String] The filename relative to the Haml root @@ -266,9 +268,8 @@ module Haml # @param v2 [String] Another version string. # @return [Boolean] def version_geq(v1, v2) - @@version_comparison_cache ||= {} k = "#{v1}#{v2}" - return @@version_comparison_cache[k] unless @@version_comparison_cache[k].nil? + return @@version_comparison_cache.fetch(k) if @@version_comparison_cache.key?(k) @@version_comparison_cache[k] = ( version_gt(v1, v2) || !version_gt(v2, v1) ) end