@@ -48,13 +48,13 @@ public func NSEqualRanges(_ range1: NSRange, _ range2: NSRange) -> Bool {
48
48
}
49
49
50
50
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
53
53
let maxend : Int
54
- if max1 > max2 {
55
- maxend = max1
54
+ if end1 > end2 {
55
+ maxend = end1
56
56
} else {
57
- maxend = max2
57
+ maxend = end2
58
58
}
59
59
let minloc : Int
60
60
if range1. location < range2. location {
@@ -66,17 +66,17 @@ public func NSUnionRange(_ range1: NSRange, _ range2: NSRange) -> NSRange {
66
66
}
67
67
68
68
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
71
71
let minend : Int
72
- if max1 < max2 {
73
- minend = max1
72
+ if end1 < end2 {
73
+ minend = end1
74
74
} else {
75
- minend = max2
75
+ minend = end2
76
76
}
77
- if range2. location <= range1. location && range1. location < max2 {
77
+ if range2. location <= range1. location && range1. location < end2 {
78
78
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 {
80
80
return NSRange ( location: range2. location, length: minend - range2. location)
81
81
}
82
82
return NSRange ( location: 0 , length: 0 )
@@ -221,20 +221,20 @@ extension NSRange {
221
221
}
222
222
223
223
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
227
227
let minloc = location < other. location ? location : other. location
228
228
return NSRange ( location: minloc, length: maxend - minloc)
229
229
}
230
230
231
231
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 {
236
236
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 {
238
238
return NSRange ( location: other. location, length: minend - other. location) ;
239
239
}
240
240
return nil
0 commit comments