lib/lru_redux/cache.rb in lru_redux-0.8.3 vs lib/lru_redux/cache.rb in lru_redux-0.8.4
- old
+ new
@@ -87,28 +87,19 @@
a
end
def delete(key)
node = @data.delete(key)
+
return unless node
- if node[3].nil?
- @head = @head[0]
- if @head.nil?
- @tail = nil
- else
- @head[3] = nil
- end
- elsif node[0].nil?
- @tail = @tail[3]
- @tail[0] = nil
- else
- prev = node[0]
- nex = node[3]
+ prev = node[0]
+ nex = node[3]
- prev[3] = nex if prev
- nex[0] = prev if nex
- end
+ nex ? nex[0] = prev : @head = prev
+ prev ? prev[3] = nex : @tail = nex
+
+ node[2]
end
def clear
@data.clear
@head = @tail = nil