[UCRT] Improve __crt_seh_guarded_call

This is a workaround for an MSVC compiler bug, which would result in degraded performance. See https://developercommunity.visualstudio.com/t/_local_unwind-generated-when-returning-f/10673261?
This commit is contained in:
Timo Kreuzer 2024-11-10 16:20:55 +02:00
parent a58b713a5e
commit c2b1271dbe

View file

@ -206,10 +206,31 @@ struct __crt_seh_guarded_call
template<typename Init, typename Action, typename Cleanup> template<typename Init, typename Action, typename Cleanup>
T operator()(Init init, Action action, Cleanup cleanup) T operator()(Init init, Action action, Cleanup cleanup)
{ {
T result;
init(); init();
__try __try
{ {
return action(); result = action();
}
__finally
{
cleanup();
}
__endtry
return result;
}
};
template<>
struct __crt_seh_guarded_call<void>
{
template<typename Init, typename Action, typename Cleanup>
void operator()(Init init, Action action, Cleanup cleanup)
{
init();
__try
{
action();
} }
__finally __finally
{ {