summaryrefslogtreecommitdiffstats
path: root/text_diff_notes.md
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2021-03-21 13:34:01 -0700
committerWilfred Hughes <me@wilfred.me.uk>2021-03-21 13:34:01 -0700
commitccd6ac4d44b5c91aa2d1c2534c7be57963b616d5 (patch)
tree3bf4b157dc8bf91e7d97e206c4bb5e8272a17a5d /text_diff_notes.md
parent5b182575981af686459ab9f72310719d9c2cfff4 (diff)
Add notes on LCS weaknesses
Diffstat (limited to 'text_diff_notes.md')
-rw-r--r--text_diff_notes.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/text_diff_notes.md b/text_diff_notes.md
new file mode 100644
index 000000000..c4a183dea
--- /dev/null
+++ b/text_diff_notes.md
@@ -0,0 +1,48 @@
+Consider changing:
+
+```
+foo();
+bar();
+```
+
+To:
+
+```
+if (true) {
+ foo();
+}
+```
+
+What we want:
+
+```
++ if (true) {
+ foo();
+- bar();
++ }
+```
+
+A longest-common-subsequence algorithm is wrong here. The longest
+subsequence is five tokens:
+
+```
+( ) ( ) ;
+```
+
+which leads to:
+
+```
++if+ (+true+) +{+
+ +foo+();
+ -bar-();
++}+
+```
+
+so we claim `foo` is added. We want the following *four* tokens to be
+preserved:
+
+```
+foo ( ) ;
+```
+
+Proposed solution: advance on both sides, keep first match.