lib/skylight/util/lru_cache.rb in skylight-5.1.0.beta vs lib/skylight/util/lru_cache.rb in skylight-5.1.0.beta2
- old
+ new
@@ -17,18 +17,14 @@
# Individual hash operations here are atomic in MRI.
def fetch(key)
found = true
value = @data.delete(key) { found = false }
- if !found && block_given?
- value = yield
- end
+ value = yield if !found && block_given?
@data[key] = value if value
- if !found && value && @data.length > @max_size
- @data.shift
- end
+ @data.shift if !found && value && @data.length > @max_size
value
end
def clear