Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoided to call twice

  • Loading branch information...
commit 3b546afd049221fd4aa407d6b99f1c4de312c704 1 parent e848bca
Toshinori Kajihara kennyj authored
Showing with 5 additions and 8 deletions.
  1. +5 −8 activesupport/lib/active_support/cache.rb
13 activesupport/lib/active_support/cache.rb
View
@@ -559,7 +559,7 @@ def initialize(value, options = {})
@value = nil
else
@value = Marshal.dump(value)
- if should_compress?(value, options)
+ if should_compress?(@value, options)
@value = Zlib::Deflate.deflate(@value)
@compressed = true
end
@@ -613,13 +613,10 @@ def size
end
private
- def should_compress?(value, options)
- if options[:compress] && value
- unless value.is_a?(Numeric)
- compress_threshold = options[:compress_threshold] || DEFAULT_COMPRESS_LIMIT
- serialized_value = value.is_a?(String) ? value : Marshal.dump(value)
- return true if serialized_value.size >= compress_threshold
- end
+ def should_compress?(serialized_value, options)
+ if options[:compress]
+ compress_threshold = options[:compress_threshold] || DEFAULT_COMPRESS_LIMIT
+ return true if serialized_value.size >= compress_threshold
end
false
end
Please sign in to comment.
Something went wrong with that request. Please try again.