From a0fe687d25cea2ee52f6bd660f727e7a32d3ec44 Mon Sep 17 00:00:00 2001 From: ChrisBenua Date: Sun, 1 Feb 2026 01:31:08 +0300 Subject: [PATCH] optimize name calculation --- Sources/NeedleFoundation/Component.swift | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Sources/NeedleFoundation/Component.swift b/Sources/NeedleFoundation/Component.swift index 1dc1128..36c18d9 100644 --- a/Sources/NeedleFoundation/Component.swift +++ b/Sources/NeedleFoundation/Component.swift @@ -174,11 +174,7 @@ open class Component: Scope { private let sharedInstanceLock = NSRecursiveLock() private var sharedInstances = [String: Any]() - private lazy var name: String = { - let fullyQualifiedSelfName = String(describing: self) - let parts = fullyQualifiedSelfName.components(separatedBy: ".") - return parts.last ?? fullyQualifiedSelfName - }() + private lazy var name: String = _typeName(type(of: self), qualified: false) // TODO: Replace this with an `open` method, once Swift supports extension // overriding methods. @@ -270,11 +266,7 @@ open class Component: Scope { private let sharedInstanceLock = NSRecursiveLock() private var sharedInstances = [String: Any]() - private lazy var name: String = { - let fullyQualifiedSelfName = String(describing: self) - let parts = fullyQualifiedSelfName.components(separatedBy: ".") - return parts.last ?? fullyQualifiedSelfName - }() + private lazy var name: String = _typeName(type(of: self), qualified: false) // TODO: Replace this with an `open` method, once Swift supports extension // overriding methods.