fge/json-patch — pull request #2 by rwatler (2013-04-11 16:32:23+00:00)
Title: Revised factorizing implementation and test case data

Revise factorizing implementation and test cases to cover multiple overlapping add/remove diff array index adjustments. The implementation now properly tracks multiple deferred and advanced removes so that array indexes can be computed properly as the factorizing pass is made on the diffs. To do this, add and remove diffs are paired up front and the pairings are recorded by new members in the diffs themselves for the subsequent factorizing pass. I am guessing that this moves the approach closer to what you had imagined up front.

Also, I cosmetically enhanced the object diffs by preserving field order for the adds, removes, and commons sets. This predictability makes the tests easier to compose and follow. I suppose that will also apply to anyone looking at the generated diffs.

Finally, the refactoring of the LCS algorithm introduced a significant bug that messed up the order of the result when common beginning elements were supposed to be prepended and instead were appended, (that was a bugger to track down)!