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

Make *Util components constructible #121

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Conversation

elliotgoodrich
Copy link
Owner

Previously (603949f) we made some changes to TrimUtil to return a std::shared_ptr<void> containing the internal variables used in the algorithm. This allowed us to defer destruction in TrimUtil so that we can skip it with std::_Exit later on - saving 1-2%.

The change did not sit well with me and is not very idiomatic. This commit changes both BuildDirUtil and TrimUtil to be constructible and have their static methods changed to non-const member variables. We store the variables in a std::unique_ptr to defer destruction of the state until the destructor of the *Util - which is skipped when we call std::_Exit.

Previously (603949f) we made some
changes to `TrimUtil` to return a `std::shared_ptr<void>` containing the
internal variables used in the algorithm.  This allowed us to defer
destruction in `TrimUtil` so that we can skip it with `std::_Exit` later
on - saving 1-2%.

The change did not sit well with me and is not very idiomatic.  This
commit changes both `BuildDirUtil` and `TrimUtil` to be constructible
and have their static methods changed to non-`const` member variables.
We store the variables in a `std::unique_ptr` to defer destruction of
the state until the destructor of the `*Util` - which is skipped when we
call `std::_Exit`.
@elliotgoodrich elliotgoodrich merged commit 65c9056 into main Nov 27, 2024
8 checks passed
@elliotgoodrich elliotgoodrich deleted the make-util-ctorable branch November 27, 2024 05:53
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