@@ -178,6 +178,12 @@ extension DistributedActorSystem {
178
178
) async throws where Act: DistributedActor ,
179
179
// Act.ID == ActorID, // FIXME(distributed): can we bring this back?
180
180
ResultHandler: DistributedTargetInvocationResultHandler {
181
+ // NOTE: Implementation could be made more efficient because we still risk
182
+ // demangling a RemoteCallTarget identity (if it is a mangled name) multiple
183
+ // times. We would prefer to store if it is a mangled name, demangle, and
184
+ // always refer to that demangled repr perhaps? We do cache the resulting
185
+ // pretty formatted name of the call target, but perhaps we can do better.
186
+
181
187
// Get the expected parameter count of the func
182
188
guard let targetName = target. identifier else {
183
189
throw ExecuteDistributedTargetError (
@@ -338,33 +344,24 @@ extension DistributedActorSystem {
338
344
/// however its exact format is not specified and may change in future versions.
339
345
@available ( SwiftStdlib 5 . 7 , * )
340
346
public struct RemoteCallTarget : CustomStringConvertible {
341
- private let _storage : _Storage
342
- private enum _Storage {
343
- case mangledName( String )
344
- }
347
+ private let _identifier : String
345
348
346
- // Only intended to be created by the _Distributed library.
347
- // TODO(distributed): make this internal and only allow calling by the synthesized code?
348
- public init ( _mangledName: String ) {
349
- self . _storage = . mangledName( _mangledName)
349
+ public init ( _ identifier: String ) {
350
+ self . _identifier = identifier
350
351
}
351
352
352
353
/// The underlying identifier of the target, returned as-is.
353
354
public var identifier : String ? {
354
- switch self . _storage {
355
- case . mangledName( let name) :
356
- return name
357
- }
355
+ return _identifier
358
356
}
359
357
358
+ /// Attempts to pretty format the underlying target identifier.
359
+ /// If unable to, returns the raw underlying identifier.
360
360
public var description : String {
361
- switch self . _storage {
362
- case . mangledName( let mangledName) :
363
- if let name = _getFunctionFullNameFromMangledName ( mangledName: mangledName) {
364
- return name
365
- } else {
366
- return " \( mangledName) "
367
- }
361
+ if let name = _getFunctionFullNameFromMangledName ( mangledName: _identifier) {
362
+ return name
363
+ } else {
364
+ return " \( _identifier) "
368
365
}
369
366
}
370
367
}
0 commit comments