Skip to content

perf: Optimize Cache::remove for value types that need drop - #19

Open
malik672 wants to merge 1 commit into
DaniPopes:mainfrom
malik672:remove
Open

perf: Optimize Cache::remove for value types that need drop#19
malik672 wants to merge 1 commit into
DaniPopes:mainfrom
malik672:remove

Conversation

@malik672

Copy link
Copy Markdown

Optimize Cache::remove for value types that need drop by moving the stored entry out of the bucket instead of cloning the value and then dropping the original pair.

For types that do not need drop, remove keeps the old cheap clone path so small Copy-like values such as u64 do not pay extra work moving the whole (K, V) pair.

Criterion comparison:

Case Before After Result
u64 -> u64 28.060 µs 26.312 µs no meaningful change
u64 -> String(64b) 152.74 µs 71.014 µs ~55% faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant