Skip to content

Commit ff75ac8

Browse files
authored
Merge pull request #2682 from revolter/patch-1
2 parents 17a35c2 + 26b33a3 commit ff75ac8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Sources/Foundation/NSRange.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public func NSEqualRanges(_ range1: NSRange, _ range2: NSRange) -> Bool {
4848
}
4949

5050
public func NSUnionRange(_ range1: NSRange, _ range2: NSRange) -> NSRange {
51-
let max1 = range1.location + range1.length
52-
let max2 = range2.location + range2.length
51+
let end1 = range1.location + range1.length
52+
let end2 = range2.location + range2.length
5353
let maxend: Int
54-
if max1 > max2 {
55-
maxend = max1
54+
if end1 > end2 {
55+
maxend = end1
5656
} else {
57-
maxend = max2
57+
maxend = end2
5858
}
5959
let minloc: Int
6060
if range1.location < range2.location {
@@ -66,17 +66,17 @@ public func NSUnionRange(_ range1: NSRange, _ range2: NSRange) -> NSRange {
6666
}
6767

6868
public func NSIntersectionRange(_ range1: NSRange, _ range2: NSRange) -> NSRange {
69-
let max1 = range1.location + range1.length
70-
let max2 = range2.location + range2.length
69+
let end1 = range1.location + range1.length
70+
let end2 = range2.location + range2.length
7171
let minend: Int
72-
if max1 < max2 {
73-
minend = max1
72+
if end1 < end2 {
73+
minend = end1
7474
} else {
75-
minend = max2
75+
minend = end2
7676
}
77-
if range2.location <= range1.location && range1.location < max2 {
77+
if range2.location <= range1.location && range1.location < end2 {
7878
return NSRange(location: range1.location, length: minend - range1.location)
79-
} else if range1.location <= range2.location && range2.location < max1 {
79+
} else if range1.location <= range2.location && range2.location < end1 {
8080
return NSRange(location: range2.location, length: minend - range2.location)
8181
}
8282
return NSRange(location: 0, length: 0)
@@ -221,20 +221,20 @@ extension NSRange {
221221
}
222222

223223
public func union(_ other: NSRange) -> NSRange {
224-
let max1 = location + length
225-
let max2 = other.location + other.length
226-
let maxend = (max1 < max2) ? max2 : max1
224+
let end1 = location + length
225+
let end2 = other.location + other.length
226+
let maxend = (end1 < end2) ? end2 : end1
227227
let minloc = location < other.location ? location : other.location
228228
return NSRange(location: minloc, length: maxend - minloc)
229229
}
230230

231231
public func intersection(_ other: NSRange) -> NSRange? {
232-
let max1 = location + length
233-
let max2 = other.location + other.length
234-
let minend = (max1 < max2) ? max1 : max2
235-
if other.location <= location && location < max2 {
232+
let end1 = location + length
233+
let end2 = other.location + other.length
234+
let minend = (end1 < end2) ? end1 : end2
235+
if other.location <= location && location < end2 {
236236
return NSRange(location: location, length: minend - location)
237-
} else if location <= other.location && other.location < max1 {
237+
} else if location <= other.location && other.location < end1 {
238238
return NSRange(location: other.location, length: minend - other.location);
239239
}
240240
return nil

0 commit comments

Comments
 (0)