Skip to content

Commit 2f0f43a

Browse files
committed
[stdlib] Dictionary, Set: Force-inline hidden Sequence/Collection customization points
This should eliminate a branch, which should probably lead to a tiny overall code size improvement, as well as a tiny performance boost.
1 parent 2b1b68f commit 2f0f43a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

stdlib/public/core/Dictionary.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,16 +1383,19 @@ extension Dictionary {
13831383
}
13841384

13851385
@inlinable
1386+
@inline(__always)
13861387
public func _customContainsEquatableElement(_ element: Element) -> Bool? {
13871388
return _variant.contains(element)
13881389
}
13891390

13901391
@inlinable
1392+
@inline(__always)
13911393
public func _customIndexOfEquatableElement(_ element: Element) -> Index?? {
13921394
return Optional(_variant.index(forKey: element))
13931395
}
13941396

13951397
@inlinable
1398+
@inline(__always)
13961399
public func _customLastIndexOfEquatableElement(_ element: Element) -> Index?? {
13971400
// The first and last elements are the same because each element is unique.
13981401
return _customIndexOfEquatableElement(element)

stdlib/public/core/Set.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ extension Set: Sequence {
266266
}
267267

268268
@inlinable
269+
@inline(__always)
269270
public func _customContainsEquatableElement(_ member: Element) -> Bool? {
270271
return contains(member)
271272
}
@@ -361,13 +362,15 @@ extension Set: Collection {
361362
}
362363

363364
@inlinable
365+
@inline(__always)
364366
public func _customIndexOfEquatableElement(
365367
_ member: Element
366368
) -> Index?? {
367369
return Optional(firstIndex(of: member))
368370
}
369371

370372
@inlinable
373+
@inline(__always)
371374
public func _customLastIndexOfEquatableElement(
372375
_ member: Element
373376
) -> Index?? {

0 commit comments

Comments
 (0)