mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Slight optimizations based on @dkubb's suggestions
This commit is contained in:
parent
c00ff91b02
commit
3fadc3c742
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue