sebastianbergmann/diff — pull request #22 by gcrico (2014-11-21 18:18:11+00:00)
Title: Improve LCS TimeEfficientImplementation

Using a `SplFixedArray` seems to reduce memory allocation (-90% memory peak usage) and have greater lookup speed (+15%) than the two-dimension dynamic `array` storing the LCS matrix. It also seems that a `SplFixedArray` is wiped earlier by the PHP garbage collector.

An other optimization: avoid usage of `array_unshift`. Pushing into the results array and reversing it at the end is (200x ?) faster in most cases.

If this patch is OK, the `Differ->calculateEstimatedFootprint()` could be also adjusted, because the `SplFixedArray` memory cost seems to be completely different than the one of (partially filled) `array X array` matrix.