Skip to content

Commit

Permalink
Simplify contains(where:) with Key Paths
Browse files Browse the repository at this point in the history
  • Loading branch information
BAHATTIN KOC committed Aug 31, 2024
1 parent ab4c5d9 commit ff19d64
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/Private/CoreAnimation/Layers/ShapeItemLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ShapeItemLayer: BaseAnimationLayer {
"`ShapeItemLayer` must contain exactly one `ShapeItem` that draws a `GPPath`")

try context.compatibilityAssert(
!otherItems.contains(where: { $0.item.drawsCGPath }),
!otherItems.contains(where: \.item.drawsCGPath),
"`ShapeItemLayer` must contain exactly one `ShapeItem` that draws a `GPPath`")

super.init()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Private/CoreAnimation/Layers/ShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ extension CALayer {
// but in practice can be any combination of items. The implementation expects all path-drawing
// shape items to be managed by a `GroupLayer`, so if there's a top-level path item we
// have to create a placeholder group.
if parentGroup == nil, otherItems.contains(where: { $0.item.drawsCGPath }) {
if parentGroup == nil, otherItems.contains(where: \.item.drawsCGPath) {
groupItems = [Group(items: items.map { $0.item }, name: "")]
otherItems = []
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ final class SnapshotTests: XCTestCase {
animationName = animationName.replacingOccurrences(of: "-", with: "/")

XCTAssert(
Samples.sampleAnimationURLs.contains(where: { $0.absoluteString.hasSuffix("\(animationName).json") })
|| Samples.sampleAnimationURLs.contains(where: { $0.absoluteString.hasSuffix("\(animationName).lottie") }),
Samples.sampleAnimationURLs.contains(where: \.absoluteString.hasSuffix("\(animationName).json"))
|| Samples.sampleAnimationURLs.contains(where: \.absoluteString.hasSuffix("\(animationName).lottie")),
"Snapshot \"\(snapshotURL.lastPathComponent)\" has no corresponding sample animation. Expecting \(animationName).json|.lottie")
}
}
Expand Down

0 comments on commit ff19d64

Please sign in to comment.