diff --git a/src/fifo.cr b/src/fifo.cr index b0f013a..33b4185 100644 --- a/src/fifo.cr +++ b/src/fifo.cr @@ -30,8 +30,8 @@ class FIFO(V) # NOTE: `#<<(v : V)` is the only function since it's enough for the intended use, feel free to improve this. # WARNING: implementation is extremely simple (3 lines) and not designed to be highly efficient. def <<(v : V) : V? + @data.select! { |x| v != v } # remove dups @data.unshift v # push on top of the stack - @data.uniq! # remove dups @data.pop if @data.size > @max_entries # remove least recently used entry if `@data` is too big end end