Skip to content

Commit fe3a308

Browse files
committed
Rect: clean up the out-of-line equality
This cleans up some whitespace issues and renames the equality function, making it freestanding rather than a method on `Rect`.
1 parent 81a6f49 commit fe3a308

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Sources/SwiftWin32/CG/Rect.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
@_implementationOnly import func CRT.floor
55
@_implementationOnly import func CRT.ceil
66

7+
@inline(__always)
8+
private func __equals(_ lhs: Rect, _ rhs: Rect) -> Bool {
9+
return lhs.origin == rhs.origin && lhs.size == rhs.size
10+
}
11+
712
/// A structure that contains the location and dimensions of a rectangle.
813
public struct Rect {
914
// MARK - Creating Rectangle Values
@@ -219,22 +224,15 @@ public struct Rect {
219224

220225
/// Returns whether the rectangle is equal to the null rectangle.
221226
public var isNull: Bool {
222-
return self.pureEqualityCheck(.null)
223-
}
224-
225-
@inline(__always) private func pureEqualityCheck(_ rhs: Rect)
226-
-> Bool {
227-
return (self.origin == rhs.origin) && (self.size == rhs.size)
227+
return __equals(self, .null)
228228
}
229229
}
230230

231-
232-
233231
extension Rect: Equatable {
234232
// MARK - Operator Functions
235233
public static func == (lhs: Rect, rhs: Rect) -> Bool {
236234
let lhs: Rect = lhs.standardized, rhs: Rect = rhs.standardized
237-
return lhs.pureEqualityCheck(rhs)
235+
return __equals(lhs, rhs)
238236
}
239237
}
240238

0 commit comments

Comments
 (0)