unbox_value_or: Replace param::hstring with hstring#1558
unbox_value_or: Replace param::hstring with hstring#1558justanotheranonymoususer wants to merge 4 commits intomicrosoft:masterfrom
Conversation
|
This is a performance regression, the following code which would previously use a fast-pass string (and be allocation-free) will now allocate a string on the heap: auto foo = unbox_value_or<hstring>(nullptr, L"bar"); |
|
I don't think this is actually a regression. Let's compare the old and new code for Old code (
New code (
Both paths heap-allocate when the default is used. The function returns The new code is actually better on the success path: zero cost vs. a |
hstring has a move constructor that avoids calling WindowsDuplicateString, which would be used here, no? |
|
If it were a named local, implicit move would kick in: So the old code does copy-construct through Let me know if I'm missing something. Also intuitively, I can't see how |
|
Hmmm yeah you're right, can't move out of a lvalue ref. |
Partially fixes: #1527
Similar to #1530
@DefaultRyan please review