Skip to content

Commit

Permalink
Merge pull request #694 from schneems/schneems/reduce-object-count
Browse files Browse the repository at this point in the history
Don’t dup string if it’s not the argument
  • Loading branch information
petergoldstein committed Aug 28, 2018
2 parents c02d12b + e05d998 commit 54c9245
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/active_support/cache/dalli_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def namespaced_key(key, options)
# called. If the key is a Hash, then keys will be sorted alphabetically.
def expanded_key(key) # :nodoc:
return key.cache_key.to_s if key.respond_to?(:cache_key)
original_object_id = key.object_id

case key
when Array
Expand All @@ -365,7 +366,7 @@ def expanded_key(key) # :nodoc:

key = key.to_param
if key.respond_to? :force_encoding
key = key.dup
key = key.dup if key.object_id == original_object_id
key.force_encoding('binary')
end
key
Expand Down

0 comments on commit 54c9245

Please sign in to comment.