Skip to content

winrt::impl::error_ok and friends are duplicated in each translation unit #921

@dmachaj

Description

@dmachaj

I was running a binary size analysis tool on our optimized binary and the "wasteful duplication" analysis flagged winrt::impl::error_ok and all of the other errors in that same block. These are constexpr so they are in the readonly segment, as expected, but they are duplicated. According to this tool they are 4 bytes each, duplicated 42 times, and add up to 168 bytes each. That adds up to roughly 3KB of our final binary being copies of these error codes.

This can be fixed by changing constexpr to inline constexpr. That syntax will result in them being de-duped to a single copy. It requires C++17, but cppwinrt already requires that so it shouldn't be a problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions