Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jsapi-util: Rewrite GjsAutoPointer to only use template data
We introduced GjsAutoPointer as part of commit dab3c7d, to avoid duplication of the same code everywhere, and that served us well to create multiple smart pointer types, however since we were relying on std::unique_ptr, all the times we created a pointer with a custom destructor, we were allocating 8bits more, and this can be sensitive when used around in wrappers. However, since we are already constructing the auto-pointers passing all these information as template (generating some custom code, for sure), we can just rely on the template parameters also for the destructor, and so ensuring that the struct size always matches the wrapped pointer, removing all the overhead. This will allow to use GjsAutoPointer's everywhere without increasing the size of the wrapped objects. As per this being all new (even though the API is mainly inspired to unique_ptr), adding various unit tests to ensure we behave correctly.
- Loading branch information
Showing
6 changed files
with
543 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.