diff options
author | kennyj <kennyj@gmail.com> | 2011-10-30 03:14:35 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2011-10-30 03:14:35 +0900 |
commit | 3b546afd049221fd4aa407d6b99f1c4de312c704 (patch) | |
tree | 5975b53743eec9dd5ac1cde81a5da6df8b1e3bf5 /activesupport | |
parent | e848bcacdd324903875a18b998403fb141a05dd3 (diff) | |
download | rails-3b546afd049221fd4aa407d6b99f1c4de312c704.tar.gz rails-3b546afd049221fd4aa407d6b99f1c4de312c704.tar.bz2 rails-3b546afd049221fd4aa407d6b99f1c4de312c704.zip |
avoided to call twice
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 8cb74b2a86..df3602f860 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -559,7 +559,7 @@ module ActiveSupport @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 @@ module ActiveSupport 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 |