File tree 5 files changed +19
-8
lines changed
5 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ final class AppGraph: GraphHost {
25
25
}
26
26
27
27
private lazy var launchProfileOptions = LaunchProfileOptions (
28
- rawValue: EnvironmentHelper . value ( for: " OPENSWIFTUI_PROFILE_LAUNCH " )
28
+ rawValue: EnvironmentHelper . int32 ( for: " OPENSWIFTUI_PROFILE_LAUNCH " )
29
29
)
30
30
31
31
var didCollectLaunchProfile : Bool = false
Original file line number Diff line number Diff line change 9
9
internal import COpenSwiftUI
10
10
internal import OpenGraphShims
11
11
12
- private let waitingForPreviewThunks = EnvironmentHelper . value ( for: " XCODE_RUNNING_FOR_PREVIEWS " ) != 0
12
+ private let waitingForPreviewThunks = EnvironmentHelper . bool ( for: " XCODE_RUNNING_FOR_PREVIEWS " )
13
13
private var blockedGraphHosts : [ Unmanaged < GraphHost > ] = [ ]
14
14
15
15
class GraphHost {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import Foundation
12
12
import QuartzCore
13
13
#endif
14
14
15
- private let enableProfiler = EnvironmentHelper . value ( for: " OPENSWIFTUI_PROFILE_BENCHMARKS " ) != 0
15
+ private let enableProfiler = EnvironmentHelper . bool ( for: " OPENSWIFTUI_PROFILE_BENCHMARKS " )
16
16
17
17
public protocol _BenchmarkHost : AnyObject {
18
18
func _renderForTest( interval: Double )
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ extension _ViewDebug {
69
69
@inline ( __always)
70
70
static func instantiateIfNeeded( ) {
71
71
if !isInitialized {
72
- let debugValue = UInt32 ( bitPattern: EnvironmentHelper . value ( for: " OPENSWIFTUI_VIEW_DEBUG " ) )
72
+ let debugValue = UInt32 ( bitPattern: EnvironmentHelper . int32 ( for: " OPENSWIFTUI_VIEW_DEBUG " ) )
73
73
properties = Properties ( rawValue: debugValue)
74
74
isInitialized = true
75
75
}
Original file line number Diff line number Diff line change
1
+ //
2
+ // EnvironmentHelper.swift
3
+ // OpenSwiftUICore
4
+ //
5
+ // Audited for RELEASE_2024
6
+ // Status: Complete
7
+
1
8
#if canImport(Darwin)
2
9
import Darwin
3
10
#elseif canImport(Glibc)
@@ -8,15 +15,19 @@ import WASILibc
8
15
#error("Unsupported Platform")
9
16
#endif
10
17
11
- enum EnvironmentHelper {
18
+ package enum EnvironmentHelper {
12
19
@_transparent
13
- @inline ( __always)
14
- static func value( for key: String ) -> Int32 {
20
+ package static func int32( for key: String ) -> Int32 {
15
21
key. withCString { string in
16
22
guard let env = getenv ( string) else {
17
23
return 0
18
24
}
19
25
return atoi ( env)
20
- }
26
+ }
27
+ }
28
+
29
+ @_transparent
30
+ package static func bool( for key: String ) -> Bool {
31
+ int32 ( for: key) != 0
21
32
}
22
33
}
You can’t perform that action at this time.
0 commit comments