@@ -103,25 +103,23 @@ internal extension String {
103
103
internal func _stringByFixingSlashes( compress : Bool = true , stripTrailing: Bool = true ) -> String {
104
104
var result = self
105
105
if compress {
106
- result. withMutableCharacters { characterView in
107
- let startPos = characterView. startIndex
108
- var endPos = characterView. endIndex
109
- var curPos = startPos
110
-
111
- while curPos < endPos {
112
- if characterView [ curPos] == " / " {
113
- var afterLastSlashPos = curPos
114
- while afterLastSlashPos < endPos && characterView [ afterLastSlashPos] == " / " {
115
- afterLastSlashPos = characterView. index ( after: afterLastSlashPos)
116
- }
117
- if afterLastSlashPos != characterView. index ( after: curPos) {
118
- characterView. replaceSubrange ( curPos ..< afterLastSlashPos, with: [ " / " ] )
119
- endPos = characterView. endIndex
120
- }
121
- curPos = afterLastSlashPos
122
- } else {
123
- curPos = characterView. index ( after: curPos)
106
+ let startPos = result. startIndex
107
+ var endPos = result. endIndex
108
+ var curPos = startPos
109
+
110
+ while curPos < endPos {
111
+ if result [ curPos] == " / " {
112
+ var afterLastSlashPos = curPos
113
+ while afterLastSlashPos < endPos && result [ afterLastSlashPos] == " / " {
114
+ afterLastSlashPos = result. index ( after: afterLastSlashPos)
124
115
}
116
+ if afterLastSlashPos != result. index ( after: curPos) {
117
+ result. replaceSubrange ( curPos ..< afterLastSlashPos, with: [ " / " ] )
118
+ endPos = result. endIndex
119
+ }
120
+ curPos = afterLastSlashPos
121
+ } else {
122
+ curPos = result. index ( after: curPos)
125
123
}
126
124
}
127
125
}
@@ -214,25 +212,23 @@ public extension NSString {
214
212
215
213
var result = _swiftObject
216
214
if compress {
217
- result. withMutableCharacters { characterView in
218
- let startPos = characterView. startIndex
219
- var endPos = characterView. endIndex
220
- var curPos = startPos
221
-
222
- while curPos < endPos {
223
- if characterView [ curPos] == " / " {
224
- var afterLastSlashPos = curPos
225
- while afterLastSlashPos < endPos && characterView [ afterLastSlashPos] == " / " {
226
- afterLastSlashPos = characterView. index ( after: afterLastSlashPos)
227
- }
228
- if afterLastSlashPos != characterView. index ( after: curPos) {
229
- characterView. replaceSubrange ( curPos ..< afterLastSlashPos, with: [ " / " ] )
230
- endPos = characterView. endIndex
231
- }
232
- curPos = afterLastSlashPos
233
- } else {
234
- curPos = characterView. index ( after: curPos)
215
+ let startPos = result. startIndex
216
+ var endPos = result. endIndex
217
+ var curPos = startPos
218
+
219
+ while curPos < endPos {
220
+ if result [ curPos] == " / " {
221
+ var afterLastSlashPos = curPos
222
+ while afterLastSlashPos < endPos && result [ afterLastSlashPos] == " / " {
223
+ afterLastSlashPos = result. index ( after: afterLastSlashPos)
235
224
}
225
+ if afterLastSlashPos != result. index ( after: curPos) {
226
+ result. replaceSubrange ( curPos ..< afterLastSlashPos, with: [ " / " ] )
227
+ endPos = result. endIndex
228
+ }
229
+ curPos = afterLastSlashPos
230
+ } else {
231
+ curPos = result. index ( after: curPos)
236
232
}
237
233
}
238
234
}
0 commit comments