-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Enable WINRT_LEAN_AND_MEAN #15215
Enable WINRT_LEAN_AND_MEAN #15215
Conversation
Okay, there is at least one place where we are using |
Relevant from moons ago: #9621 (comment) |
Dang, excellent memory! It looks like cppwinrt implements |
It takes about 17 minutes to build without this change (based on #15206, recent comparable) |
It might have saved us around 30 seconds per leg on agent build. It also makes the PCHs smaller as a treat. TerminalAppLib PCH (debug x64) before: 1955 MB |
namespace std | ||
{ | ||
template<> | ||
struct hash<::winrt::Windows::UI::Xaml::DataTemplate> : public hash_winrt_object_as_pointer | ||
{ | ||
}; | ||
template<> | ||
struct hash<::winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem> : public hash_winrt_object_as_pointer | ||
{ | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also just pass hash_winrt_object_as_pointer
directly as a trailing template parameter to the two hashmaps. That would seem cleaner to me. With using
statements you can make the template names a bit shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fair. i was going for "maximal equivalence in minimal lines deleted". I'll probably move over to this
size_t operator()(const ::winrt::Windows::Foundation::IUnknown& value) const noexcept | ||
{ | ||
void* const abi_value = winrt::get_abi(value.try_as<::winrt::Windows::Foundation::IUnknown>()); | ||
return std::hash<void*>{}(abi_value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra try_as
seems redundant? It might make sense to do
size_t operator()(const auto& value) const noexcept
{
return std::hash<void*>{}(winrt::get_abi(value));
}
or alternatively
size_t operator()(const auto& value) const noexcept
{
return til::hash(winrt::get_abi(value));
}
Due to the novel design choices in std::unordered_map
I suspect there's not a particularly big difference between the two though, so I don't think it matters what you pick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh. I copied this directly out of winrt/base.h
.
WINRT_LEAN_AND_MEAN
removes a bunch of less often used parts of the C++/WinRT headers:std::hash
specializations for every objectoperator <<(ostream)
overloads for anyIStringable
There's only one place where we were using even one of these.
Enabling this saves us (optimistically) 30 seconds of build time on the CI agents and shrinks our largest PCH (TerminalApp, x64, Debug) by about 150MiB.
It's not huge, but it's not nothing.