Skip to content

Commit

Permalink
Remove @inlinable and @usableFromInline decorations
Browse files Browse the repository at this point in the history
I don't think they improve performance that much, and they have deep consequence on ABI stability, so I guess it's better to remove them now, when the library is still young.
  • Loading branch information
tgrapperon committed Jun 8, 2021
1 parent 187eb5f commit f77d967
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 15 deletions.
4 changes: 0 additions & 4 deletions Sources/ComposableEnvironment/ComposableEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import Foundation
open class ComposableEnvironment {
public required init() {}

@usableFromInline
var dependencies: ComposableDependencies = .init()

@usableFromInline
var hasReceivedDependenciesFromParent: Bool = false

@usableFromInline
var knownChildren: Set<AnyKeyPath> = []

@inlinable
@discardableResult
public func with<V>(_ keyPath: WritableKeyPath<ComposableDependencies, V>, _ value: V) -> Self {
dependencies[keyPath: keyPath] = value
Expand Down
3 changes: 0 additions & 3 deletions Sources/ComposableEnvironment/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ public protocol DependencyKey {
}

public struct ComposableDependencies {
@usableFromInline
var values = [AnyHashableType: Any]()

@inlinable
public subscript<T>(_ key: T.Type) -> T.Value where T: DependencyKey {
get { values[AnyHashableType(key)] as? T.Value ?? key.defaultValue }
set { values[AnyHashableType(key)] = newValue }
}

@inlinable
mutating func mergeFromUpstream(_ upstreamDependencies: ComposableDependencies) {
// We should preserve existing overrides
values = values.merging(upstreamDependencies.values,
Expand Down
2 changes: 0 additions & 2 deletions Sources/ComposableEnvironment/Dependency.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// Use this property wrapper to declare depencies in a ComposableEnvironment subclass.
@propertyWrapper
public struct Dependency<Value> {
@inlinable
public static subscript<EnclosingSelf: ComposableEnvironment>(
_enclosingInstance instance: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
Expand All @@ -18,7 +17,6 @@ public struct Dependency<Value> {
}
}

@usableFromInline
var keyPath: KeyPath<ComposableDependencies, Value>

public init(_ keyPath: KeyPath<ComposableDependencies, Value>) {
Expand Down
2 changes: 0 additions & 2 deletions Sources/ComposableEnvironment/DerivedEnvironment.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@propertyWrapper
public final class DerivedEnvironment<Value> where Value: ComposableEnvironment {
@inlinable
public static subscript<EnclosingSelf: ComposableEnvironment>(
_enclosingInstance instance: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
Expand All @@ -21,7 +20,6 @@ public final class DerivedEnvironment<Value> where Value: ComposableEnvironment
}
}

@usableFromInline
var environment: Value

public init(wrappedValue: Value) {
Expand Down
4 changes: 0 additions & 4 deletions Sources/ComposableEnvironment/Internal/AnyType.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
@usableFromInline
struct AnyHashableType: Hashable {
private var type: Any
private var isEqualTo: (AnyHashableType) -> Bool
private var hashInto: (inout Hasher) -> Void

@usableFromInline
init<T>(_ type: T.Type) {
self.type = type
isEqualTo = { $0.type is T.Type }
hashInto = { $0.combine(String(describing: T.self)) }
}

@usableFromInline
func hash(into hasher: inout Hasher) {
hashInto(&hasher)
}

@usableFromInline
static func == (lhs: AnyHashableType, rhs: AnyHashableType) -> Bool {
lhs.isEqualTo(rhs)
}
Expand Down

0 comments on commit f77d967

Please sign in to comment.