]> git.ipfire.org Git - thirdparty/git.git/commit
xdiff: refactor xdl_hash_record()
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Mon, 28 Jul 2025 19:05:19 +0000 (22:05 +0300)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Jul 2025 19:33:54 +0000 (12:33 -0700)
commit41d97837ab1e5a35fdcfd7f6af9b5d56af62e92a
tree7b830b33cba98a8a7bf55c8e7de05a539cfe8287
parente813a0200a7121b97fec535f0d0b460b0a33356c
xdiff: refactor xdl_hash_record()

Inline the check for whitespace flags so that the compiler can hoist
it out of the loop in xdl_prepare_ctx(). This improves the performance
by 8%.

$ hyperfine --warmup=1 -L rev HEAD,HEAD^  --setup='git checkout {rev} -- :/ && make git' ': {rev}; GIT_CONFIG_GLOBAL=/dev/null ./git log --oneline --shortstat v2.0.0..v2.5.0'
Benchmark 1: : HEAD; GIT_CONFIG_GLOBAL=/dev/null ./git log --oneline --shortstat v2.0.0..v2.5.0
  Time (mean ± σ):      1.670 s ±  0.044 s    [User: 1.473 s, System: 0.196 s]
  Range (min … max):    1.619 s …  1.754 s    10 runs

Benchmark 2: : HEAD^; GIT_CONFIG_GLOBAL=/dev/null ./git log --oneline --shortstat v2.0.0..v2.5.0
  Time (mean ± σ):      1.801 s ±  0.021 s    [User: 1.605 s, System: 0.192 s]
  Range (min … max):    1.766 s …  1.831 s    10 runs

Summary
  ': HEAD^; GIT_CONFIG_GLOBAL=/dev/null ./git log --oneline --shortstat v2.0.0..v2.5.0' ran
    1.08 ± 0.03 times faster than ': HEAD^^; GIT_CONFIG_GLOBAL=/dev/null ./git log --oneline --shortstat v2.0.0..v2.5.0'

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff/xutils.c
xdiff/xutils.h