Skip to content

Commit

Permalink
Revert SnapKit#574
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjpayne committed Aug 5, 2019
1 parent 222e14a commit 1754aed
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions Source/LayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,17 @@ public class LayoutConstraint : NSLayoutConstraint {
}

internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
#if os(OSX)
// ensure first anchor items match
guard let item1 = lhs.firstAnchor.item,
let item2 = rhs.firstAnchor.item,
item1 === item2 else {
return false
}

// ensure second anchor items match
guard ((lhs.secondAnchor?.item == nil && rhs.secondAnchor?.item == nil) ||
(lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else {
return false
}
#else
guard lhs.firstAnchor == rhs.firstAnchor else {
return false
}
guard ((lhs.secondAnchor == nil && rhs.secondAnchor == nil) ||
(lhs.secondAnchor! == rhs.secondAnchor!)) else {
return false
}
#endif


// ensure attributes, relation, priorty and multiplier match
// If firstItem or secondItem on either constraint has a dangling pointer
// this comparison can cause a crash. The solution for this is to ensure
// your layout code hold strong references to things like Views, LayoutGuides
// and LayoutAnchors as SnapKit will not keep strong references to any of these.
guard lhs.firstAttribute == rhs.firstAttribute &&
lhs.secondAttribute == rhs.secondAttribute &&
lhs.relation == rhs.relation &&
lhs.priority == rhs.priority &&
lhs.multiplier == rhs.multiplier else {
lhs.multiplier == rhs.multiplier &&
lhs.secondItem === rhs.secondItem &&
lhs.firstItem === rhs.firstItem else {
return false
}
return true
Expand Down

0 comments on commit 1754aed

Please sign in to comment.