HSDiff.Optimize (hunt_szymanski_diff v0.1.0)

Summary

Functions

Optimize the diff by

Functions

optimize(diff_blocks)

Optimize the diff by:

  • merging consecutive eq: blocks into eq: count
  • merging consecutive del: blocks into del: count
  • merging consecutive ins: blocks into a single ins: [lines...]

Example input:

[
  eq: ["Line A"],
  del: ["Line B"],
  ins: ["Line B changed"],
  eq: ["Line C", "Line D"],
  del: ["Line E"],
  ins: ["Line E new"],
  eq: ["Line F"]
]

becomes:

[
  eq: 1,
  del: 1,
  ins: ["Line B changed"],
  eq: 2,
  del: 1,
  ins: ["Line E new"],
  eq: 1
]