From 28b65804723604e2a6bbd0c9aed854866dda6374 Mon Sep 17 00:00:00 2001 From: Eric Rabil Date: Thu, 11 Aug 2022 14:45:04 -0400 Subject: [PATCH] Disable resolution stacktraces by default to improve performance --- Sources/Pwomise/Pwomise.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Pwomise/Pwomise.swift b/Sources/Pwomise/Pwomise.swift index 65c46c7..acefc30 100644 --- a/Sources/Pwomise/Pwomise.swift +++ b/Sources/Pwomise/Pwomise.swift @@ -25,6 +25,10 @@ private let dispatch_get_current_queue = dlsym(dlopen(nil, RTLD_GLOBAL), "dispat unsafeBitCast($0, to: dispatch_get_current_queue_t.self) } +public struct PromiseRuntime { + /// Enable this when debugging double-resolve errors to locate the first resolver + public static var recordResolutionStackTrace = false +} public class Promise: CustomDebugStringConvertible { internal typealias Pending = PendingPromise public typealias Completion = Result @@ -114,7 +118,9 @@ public class Promise: CustomDebugStringConvertible { return } - resolutionStackTrace = Thread.callStackSymbols + if PromiseRuntime.recordResolutionStackTrace { + resolutionStackTrace = Thread.callStackSymbols + } } }