Skip to content

Commit 4c021b6

Browse files
authored
Make trivial AttributedString dynamicMemberLookup subscripts inlinable (#1207)
1 parent 6cde050 commit 4c021b6

File tree

5 files changed

+5
-0
lines changed

5 files changed

+5
-0
lines changed

Sources/FoundationEssentials/AttributedString/AttributeContainer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extension AttributeContainer {
3333
}
3434

3535
@preconcurrency
36+
@inlinable // Trivial implementation, allows callers to optimize away the keypath allocation
3637
public subscript<K: AttributedStringKey>(dynamicMember keyPath: KeyPath<AttributeDynamicLookup, K>) -> K.Value? where K.Value : Sendable {
3738
get { self[K.self] }
3839
set { self[K.self] = newValue }

Sources/FoundationEssentials/AttributedString/AttributedString+Runs+Run.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ extension AttributedString.Runs.Run {
8181
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
8282
extension AttributedString.Runs.Run {
8383
@preconcurrency
84+
@inlinable // Trivial implementation, allows callers to optimize away the keypath allocation
8485
public subscript<K: AttributedStringKey>(
8586
dynamicMember keyPath: KeyPath<AttributeDynamicLookup, K>
8687
) -> K.Value?

Sources/FoundationEssentials/AttributedString/AttributedString.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ extension AttributedString: AttributedStringProtocol {
243243
}
244244

245245
@preconcurrency
246+
@inlinable // Trivial implementation, allows callers to optimize away the keypath allocation
246247
public subscript<K: AttributedStringKey>(
247248
dynamicMember keyPath: KeyPath<AttributeDynamicLookup, K>
248249
) -> K.Value? where K.Value: Sendable {

Sources/FoundationEssentials/AttributedString/AttributedSubstring.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ extension AttributedSubstring {
177177
}
178178

179179
@preconcurrency
180+
@inlinable // Trivial implementation, allows callers to optimize away the keypath allocation
180181
public subscript<K: AttributedStringKey>(
181182
dynamicMember keyPath: KeyPath<AttributeDynamicLookup, K>
182183
) -> K.Value? where K.Value : Sendable {

Sources/FoundationEssentials/AttributedString/DiscontiguousAttributedSubstring.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ extension DiscontiguousAttributedSubstring {
194194
}
195195
}
196196

197+
@inlinable // Trivial implementation, allows callers to optimize away the keypath allocation
197198
public subscript<K: AttributedStringKey>(
198199
dynamicMember keyPath: KeyPath<AttributeDynamicLookup, K>
199200
) -> K.Value? where K.Value : Sendable {

0 commit comments

Comments
 (0)