Skip to content

Commit

Permalink
We don't need to dup key, since only value is weak.
Browse files Browse the repository at this point in the history
  • Loading branch information
miloops committed Nov 19, 2010
1 parent 7d563f9 commit a84add0
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions activesupport/lib/active_support/weak_hash.rb
Expand Up @@ -22,16 +22,9 @@ def [](key)
end

def []=(key, value)
key2 = case key
when Fixnum, Symbol, true, false, nil
key
else
key.dup
end

@rev_cache[value.object_id][key2] = true
@cache[key2] = value.object_id
@key_map[key.object_id] = key2
@rev_cache[value.object_id][key] = true
@cache[key] = value.object_id
@key_map[key.object_id] = key

ObjectSpace.define_finalizer(value, @reclaim_value)
end
Expand Down

0 comments on commit a84add0

Please sign in to comment.