Skip to content

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Aug 6, 2024

The get(f::Function, collection, key) method is typically better than get(collection, key, f()) when f is not trivial. This avoids calling it unless it is actually needed.

Made on top of #75 to avoid a merge conflict.

Before (same benchmark as in #75):

9.508 ms (290571 allocations: 18.78 MiB)

After

  8.243 ms (201949 allocations: 16.58 MiB)

Instead of providing Face() as the fallback value with a get call, we
can instead provide the constructor Face as the first argument,
preventing it from being called needlessly.
@tecosaur tecosaur merged commit eada2dc into main Aug 6, 2024
@tecosaur tecosaur deleted the kc/face_get branch August 6, 2024 13:50
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.

2 participants