https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2b1271dbee202e0946d7…
commit c2b1271dbee202e0946d7ac0f7e8ee87b301efbd
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Nov 10 16:20:55 2024 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Wed Jan 22 18:56:08 2025 +0200
[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-…
---
sdk/lib/ucrt/inc/internal_shared.h | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/sdk/lib/ucrt/inc/internal_shared.h b/sdk/lib/ucrt/inc/internal_shared.h
index 7ad4b4bafe3..a0f1a5a841e 100644
--- a/sdk/lib/ucrt/inc/internal_shared.h
+++ b/sdk/lib/ucrt/inc/internal_shared.h
@@ -206,10 +206,31 @@ struct __crt_seh_guarded_call
template<typename Init, typename Action, typename Cleanup>
T operator()(Init init, Action action, Cleanup cleanup)
{
+ T result;
init();
__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
{