Skip to content

Commit 4900cc7

Browse files
author
rauhul-varma
committed
remove uncessary CGFloat casts from NSGeometry
1 parent 036b98c commit 4900cc7

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

Foundation/NSGeometry.swift

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public struct CGSize {
119119

120120
extension CGSize {
121121
public static var zero: CGSize {
122-
return CGSize(width: CGFloat(0), height: CGFloat(0))
122+
return CGSize(width: 0, height: 0)
123123
}
124124

125125
public init(width: Int, height: Int) {
@@ -682,10 +682,10 @@ public func NSEdgeInsetsEqual(_ aInsets: NSEdgeInsets, _ bInsets: NSEdgeInsets)
682682
}
683683

684684
public func NSInsetRect(_ aRect: NSRect, _ dX: CGFloat, _ dY: CGFloat) -> NSRect {
685-
let x = CGFloat(aRect.origin.x.native + dX.native)
686-
let y = CGFloat(aRect.origin.y.native + dY.native)
687-
let w = CGFloat(aRect.size.width.native - (dX.native * 2))
688-
let h = CGFloat(aRect.size.height.native - (dY.native * 2))
685+
let x = aRect.origin.x.native + dX.native
686+
let y = aRect.origin.y.native + dY.native
687+
let w = aRect.size.width.native - (dX.native * 2)
688+
let h = aRect.size.height.native - (dY.native * 2)
689689
return NSRect(x: x, y: y, width: w, height: h)
690690
}
691691

@@ -990,25 +990,19 @@ public func NSPointFromString(_ aString: String) -> NSPoint {
990990
}
991991

992992
let parsedNumbers = _scanDoublesFromString(aString, number: 2)
993-
994993
let x = parsedNumbers[0]
995994
let y = parsedNumbers[1]
996-
let result = NSPoint(x: CGFloat(x), y: CGFloat(y))
997-
998-
return result
995+
return NSPoint(x: x, y: y)
999996
}
1000997

1001998
public func NSSizeFromString(_ aString: String) -> NSSize {
1002999
if aString.isEmpty {
10031000
return .zero
10041001
}
10051002
let parsedNumbers = _scanDoublesFromString(aString, number: 2)
1006-
10071003
let w = parsedNumbers[0]
10081004
let h = parsedNumbers[1]
1009-
let result = NSSize(width: CGFloat(w), height: CGFloat(h))
1010-
1011-
return result
1005+
return NSSize(width: w, height: h)
10121006
}
10131007

10141008
public func NSRectFromString(_ aString: String) -> NSRect {
@@ -1017,15 +1011,11 @@ public func NSRectFromString(_ aString: String) -> NSRect {
10171011
}
10181012

10191013
let parsedNumbers = _scanDoublesFromString(aString, number: 4)
1020-
10211014
let x = parsedNumbers[0]
10221015
let y = parsedNumbers[1]
10231016
let w = parsedNumbers[2]
10241017
let h = parsedNumbers[3]
1025-
1026-
let result = NSRect(x: CGFloat(x), y: CGFloat(y), width: CGFloat(w), height: CGFloat(h))
1027-
1028-
return result
1018+
return NSRect(x: x, y: y, width: w, height: h)
10291019
}
10301020

10311021
extension NSValue {

0 commit comments

Comments
 (0)