Skip to content

Commit

Permalink
fix empty! bug (#44)
Browse files Browse the repository at this point in the history
* fix `empty!` bug

* Update Project.toml
  • Loading branch information
ericphanson authored Nov 21, 2023
1 parent 6719d8e commit 0d2635d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LRUCache"
uuid = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
version = "1.5.0"
version = "1.5.1"

[compat]
julia = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/LRUCache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ function Base.empty!(lru::LRU{K, V}) where {K, V}
empty!(lru.keyset)
else
sizehint!(evictions, length(lru))
maxsize = lru.maxsize
_unsafe_resize!(lru, evictions, 0)
lru.maxsize = maxsize # restore `maxsize`
end
end
_finalize_evictions!(lru.finalizer, evictions)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ end
@test length(resources.data) == 6
empty!(cache)
@test length(resources.data) == 11
@test cache.maxsize == 5
end
end

Expand Down

2 comments on commit 0d2635d

@ericphanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Register Failed
@ericphanson, it looks like you are not a publicly listed member/owner in the parent organization (JuliaCollections).
If you are a member/owner, you will need to change your membership to public. See GitHub Help

Please sign in to comment.