Once $indexPath is set (on the very first line returned), the three regular expressions inside the "if ($indexPath)" block of the diff() subroutine are applied to every single line of the resulting patch. This is unnecessary.
Created attachment 8682 [details] Patch v1 Patch v1 undefines the $indexPath variable so that the three regex replacement statements do not get run after the paths in each patch header are processed. Note that I didn't actually do any benchmarking; this seemed like an obvious performance win.
ddkilzer landed this in r14713.