Simplify the definition of the consume function#1544
Simplify the definition of the consume function#1544YexuanXiao wants to merge 1 commit intomicrosoft:masterfrom
Conversation
|
My biggest concern would be binary size and/or additional function calls for the resulting module. The revised I would recommend compiling something with full optimizations enabled and then look at the disassembly for the Basically the |
I wrote two tests, one that calls uri.AbsoluteUri() once and another that calls uri.AbsoluteUri() five times in succession, using x64 Release. I manually verified the assembly, and each call was inlined. There are many factors that determine how the compiler decides to inline, but I believe this sufficiently demonstrates that the new function does not hinder optimization. |
|
There's a few other large cppwinrt-using projects out there. One of the larger ones that uses the most of these tools is https://github.com/CommunityToolkit/Lottie-Windows - lots of queryinterface, string management, moving up and down the interface hierarchy, etc. Consider using SizeBench to compare the outputs of pre & post. I'm less worried about clock time and more about the codegen. I buy that it's probably going to be identical. |
|
Plugging https://github.com/TranslucentTB/TranslucentTB as another large-ish cppwinrt using project :) |


This PR extracts duplicate code logic into a function to reduce header file size, PCH size, and compilation time.
#1442 and #1448 removed the WINRT_IMPL_SHIM macro, causing the generated code to become bloated.
I've counted that the following pattern appears 33,597 times in the Windows namespace, which significantly increases header file size and actually slows down compilation.
This patch does not introduce any new logic; it merely adds one function call on top of the original code. Based on my testing, the 80MB header files can now be reduced to 60MB, the 2.35GB PCH file can be reduced to 2.2GB, and the time to build the PCH can be reduced from 120 seconds to 110 seconds.
Now, the above pattern is reduced to 1 line, repeated 33,597 times.