Skip to content

Commit

Permalink
update utf8.count to count
Browse files Browse the repository at this point in the history
  • Loading branch information
wzxha committed May 24, 2018
1 parent 1df6bf2 commit 4f19826
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/Sdifft/Diff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ typealias Matrix = [[Int]]
/// - to: string that be compared
/// - Returns: matrix
func drawMatrix(from: String, to: String) -> Matrix {
let row = from.utf8.count + 1
let column = to.utf8.count + 1
let row = from.count + 1
let column = to.count + 1
var result: [[Int]] = Array(repeating: Array(repeating: 0, count: column), count: row)
for i in 1..<row {
for j in 1..<column {
Expand Down Expand Up @@ -140,9 +140,9 @@ public struct Modification {

init(from: String, to: String, matrix: Matrix) {
let same =
lcs(from: from, to: to, position: (from.utf8.count, to.utf8.count), matrix: matrix, same: ([], []))
add = same.to.getChangeRanges(max: to.utf8.count - 1)
delete = same.from.getChangeRanges(max: from.utf8.count - 1)
lcs(from: from, to: to, position: (from.count, to.count), matrix: matrix, same: ([], []))
add = same.to.getChangeRanges(max: to.count - 1)
delete = same.from.getChangeRanges(max: from.count - 1)
self.same = same.to.getSameRanges()
}
}
Expand Down

0 comments on commit 4f19826

Please sign in to comment.