Skip to content

Commit

Permalink
Merge branch 'key'
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlongco committed Mar 17, 2024
2 parents bb6793a + 07f6d13 commit 018650b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions Sources/Factory/Factory/Key.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@

import Foundation

public struct FactoryKey: Hashable {
internal struct FactoryKey: Hashable {

@usableFromInline let type: ObjectIdentifier
@usableFromInline let key: StaticString
let type: ObjectIdentifier
let key: StaticString

@inlinable
@inline(__always)
init(type: Any.Type, key: StaticString = #function) {
internal init(type: Any.Type, key: StaticString) {
self.type = ObjectIdentifier(type)
self.key = key
}

@inlinable
@inline(__always)
public func hash(into hasher: inout Hasher) {
internal func hash(into hasher: inout Hasher) {
hasher.combine(self.type)
if key.hasPointerRepresentation {
hasher.combine(bytes: UnsafeRawBufferPointer(start: key.utf8Start, count: key.utf8CodeUnitCount))
Expand All @@ -30,8 +26,7 @@ public struct FactoryKey: Hashable {
}
}

@inlinable
public static func == (lhs: Self, rhs: Self) -> Bool {
internal static func == (lhs: Self, rhs: Self) -> Bool {
guard lhs.type == rhs.type && lhs.key.hasPointerRepresentation == rhs.key.hasPointerRepresentation else {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Factory/Factory/Registrations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Foundation
public struct FactoryRegistration<P,T> {

/// Key used to manage registrations and cached values.
public let key: FactoryKey
internal let key: FactoryKey
/// A strong reference to the container supporting this Factory.
internal let container: ManagedContainer
/// Typed factory with scope and factory.
Expand Down

0 comments on commit 018650b

Please sign in to comment.