Skip to content

<exception>: Optimize exception_ptr a bit #6387

Description

It seems that we can optimize exception_ptr a bit without breaking ABI, given the internal implementation details actually use shared_ptr.

The following is possibly the full list but I'm not very sure.

  • the default constructor and constructor from nullptr_t can just rely on the default member initializers (initializing both internal pointer members to nullptr).
  • the swap function can just std::swap both pointer members.
  • the operator== can just compare _Data1 (which is equal to the result of get() of the internally reinterpreted shared).
  • the assignment operator from nullptr_t can swap *this with the empty exception_ptr first, which avoids one uninlined call to __ExceptionPtrAssign.
  • operator bool() can just return _Data1 != nullptr.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions