about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/windows/compat.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/library/std/src/sys/windows/compat.rs b/library/std/src/sys/windows/compat.rs
index c55df042003..ded97bb7eaa 100644
--- a/library/std/src/sys/windows/compat.rs
+++ b/library/std/src/sys/windows/compat.rs
@@ -102,21 +102,23 @@ macro_rules! compat_fn {
             }
 
             #[allow(dead_code)]
+            #[inline(always)]
             pub fn option() -> Option<F> {
-                unsafe { PTR }
+                unsafe {
+                    if cfg!(miri) {
+                        // Miri does not run `init`, so we just call `get_f` each time.
+                        get_f()
+                    } else {
+                        PTR
+                    }
+                }
             }
 
             #[allow(dead_code)]
             pub unsafe fn call($($argname: $argtype),*) -> $rettype {
-                if let Some(ptr) = PTR {
+                if let Some(ptr) = option() {
                     return ptr($($argname),*);
                 }
-                if cfg!(miri) {
-                    // Miri does not run `init`, so we just call `get_f` each time.
-                    if let Some(ptr) = get_f() {
-                        return ptr($($argname),*);
-                    }
-                }
                 $fallback_body
             }
         }