Skip to content

Could we make the text diff even more concise? #4

Description

@simonbrunel

Hi @icflorescu.

As discussions are not enabled for this repository, I hope you don't mind I create an issue to discuss this suggestion. It's not a huge optimization but since the goal of this library is to reduce the size of the output diff, wouldn't it be more efficient to flatten the output array and apply the following logic:

  • DELETE === a negative number
  • EQUAL === a positive number
  • INSERT === a string
// fast-diff: 86 chars
[[0,"The "],[-1,"sleepy"],[1,"quick"],[0," brown fox"],[1," jumps over the lazy dog"]]

// textdiff-create: 64 chars
[[0,4],[-1,6],[1,"quick"],[0,10],[1," jumps over the lazy dog"]]

// proposal: 44 chars
[4,-6,"quick",10," jumps over the lazy dog"]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions