author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 26 Sep 2010 16:26:56 +0000 (18:26 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 30 Sep 2010 18:43:07 +0000 (11:43 -0700) | ||
commit | c099789bb01b810e40f9cfaa5c842ed568110fc8 | |
tree | 1a4b9a59bd1363fc47636b1b6a49a838f9377bad | tree | snapshot |
parent | ad14b450c0c70bfcf90de0aa19ffa5e44e402b69 | commit | diff |
diff: avoid repeated scanning while looking for funcname
For each hunk, xdl_find_func searches the preimage for a function name
until the beginning of the file. If the file does not contain any
function names, this search has complexity O(n^2) in the number of
hunks n.
Instead, inline xdl_find_func() and keep track of up to which line we
have scanned already and the contents of the last funcname line that
we have found.
Noticed and a different approach proposed by Clemens Buchacher.
This alternative solution was done by René Scharfe.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
For each hunk, xdl_find_func searches the preimage for a function name
until the beginning of the file. If the file does not contain any
function names, this search has complexity O(n^2) in the number of
hunks n.
Instead, inline xdl_find_func() and keep track of up to which line we
have scanned already and the contents of the last funcname line that
we have found.
Noticed and a different approach proposed by Clemens Buchacher.
This alternative solution was done by René Scharfe.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff/xemit.c | diff | blob | history |