Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid creating a new Face in get calls when FACES has that face available #77

Merged
merged 1 commit into from
Aug 6, 2024

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
4 checks passed
@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