Skip to content

Commit 473c3aa

Browse files
committed
refactor: address review comments
1 parent 581b6ef commit 473c3aa

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/commonMain/kotlin/io/github/petertrr/diffutils/algorithm/myers/MyersDiff.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2 ->
3535

3636
val path = buildPath(source, target, progress) ?: error("Expected a non-null path node")
3737
val result = buildRevision(path)
38-
progress.diffEnd()
3938

39+
progress.diffEnd()
4040
return result
4141
}
4242

@@ -122,7 +122,7 @@ public class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2 ->
122122

123123
val changes = ArrayList<Change>()
124124

125-
// This can be improved to avoid the non-null assertion on prev
125+
// TODO: this can be improved to avoid the non-null assertion on prev
126126
while (path?.prev != null && path.prev!!.j >= 0) {
127127
check(!path.snake) { "Bad diffpath: found snake when looking for diff" }
128128

src/commonMain/kotlin/io/github/petertrr/diffutils/text/DiffRow.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package io.github.petertrr.diffutils.text
2020

2121
/**
22-
* Describes the diff row in form `[tag, oldLine, newLine)` for showing the difference between two texts.
22+
* Describes the diff row in form `[tag, oldLine, newLine]` for showing the difference between two texts.
2323
*/
2424
public data class DiffRow(val tag: Tag, val oldLine: String, val newLine: String) {
2525
public enum class Tag {
@@ -28,4 +28,7 @@ public data class DiffRow(val tag: Tag, val oldLine: String, val newLine: String
2828
CHANGE,
2929
EQUAL,
3030
}
31+
32+
override fun toString(): String =
33+
"[$tag, $oldLine, $newLine]"
3134
}

src/commonMain/kotlin/io/github/petertrr/diffutils/text/DiffRowGenerator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public class DiffRowGenerator(
168168
original: List<String>,
169169
endPos: Int,
170170
diffRows: MutableList<DiffRow>,
171-
delta: Delta<String>
171+
delta: Delta<String>,
172172
): Int {
173173
val orig: Chunk<String> = delta.source
174174
val rev: Chunk<String> = delta.target

src/commonTest/kotlin/io/github/petertrr/diffutils/DiffUtilsTest.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
*/
1919
package io.github.petertrr.diffutils
2020

21-
import io.github.petertrr.diffutils.patch.*
21+
import io.github.petertrr.diffutils.patch.ChangeDelta
22+
import io.github.petertrr.diffutils.patch.Chunk
23+
import io.github.petertrr.diffutils.patch.DeleteDelta
24+
import io.github.petertrr.diffutils.patch.EqualDelta
25+
import io.github.petertrr.diffutils.patch.InsertDelta
26+
import io.github.petertrr.diffutils.patch.Patch
2227
import io.github.petertrr.diffutils.utils.changeDeltaOf
2328
import io.github.petertrr.diffutils.utils.deleteDeltaOf
2429
import io.github.petertrr.diffutils.utils.insertDeltaOf

0 commit comments

Comments
 (0)