Reactos

[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?

+22 -1
+22 -1
sdk/lib/ucrt/inc/internal_shared.h
··· 206 206 template<typename Init, typename Action, typename Cleanup> 207 207 T operator()(Init init, Action action, Cleanup cleanup) 208 208 { 209 + T result; 209 210 init(); 210 211 __try 211 212 { 212 - return action(); 213 + result = action(); 214 + } 215 + __finally 216 + { 217 + cleanup(); 218 + } 219 + __endtry 220 + return result; 221 + } 222 + }; 223 + 224 + template<> 225 + struct __crt_seh_guarded_call<void> 226 + { 227 + template<typename Init, typename Action, typename Cleanup> 228 + void operator()(Init init, Action action, Cleanup cleanup) 229 + { 230 + init(); 231 + __try 232 + { 233 + action(); 213 234 } 214 235 __finally 215 236 {