Permalink
Browse files

Make use of the values returned by internal_compute instead of writin…

…g to closure captured vars.
  • Loading branch information...
1 parent ba64801 commit 8a2ddc393afe57fe5ee51bc9c2bf49357eac0fb3 @thedarkone committed Dec 10, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 lib/thread_safe/atomic_reference_cache_backend.rb
@@ -441,26 +441,23 @@ def compute_if_present(key)
end
def compute(key)
- new_value = nil
internal_compute(key) do |old_value|
if (new_value = yield(NULL == old_value ? nil : old_value)).nil?
NULL
else
new_value
end
end
- new_value
end
- def merge_pair(key, new_value)
+ def merge_pair(key, value)
internal_compute(key) do |old_value|
- if NULL == old_value || !(new_value = yield(old_value)).nil?
- new_value
+ if NULL == old_value || !(value = yield(old_value)).nil?
+ value
else
NULL
end
end
- new_value
end
def replace_pair(key, old_value, new_value)

0 comments on commit 8a2ddc3

Please sign in to comment.