Skip to content

Commit bc0448d

Browse files
committed
Fix distanceFromStart calculations
Needs to reference code unit locations instead of specific character locations
1 parent d1a673b commit bc0448d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Foundation/NSJSONSerialization.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,9 @@ private struct JSONReader {
286286
func hasNext(input: Index) -> Bool {
287287
return input + step <= buffer.endIndex
288288
}
289-
290-
func distanceFromStart(index: Index) -> Int {
291-
/// Keep track of deltas after decoding strings
292-
return 0
289+
290+
func distanceFromStart(index: Index) -> Index.Distance {
291+
return buffer.startIndex.distanceTo(index) / step
293292
}
294293
}
295294

0 commit comments

Comments
 (0)