<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/xdiff, branch v2.52.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.52.0</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.52.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-10-14T19:56:09Z</updated>
<entry>
<title>Merge branch 'en/xdiff-cleanup'</title>
<updated>2025-10-14T19:56:09Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-10-14T19:56:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9ff172d0ee65dfea6a8e329ab4363e2afa6dea49'/>
<id>urn:sha1:9ff172d0ee65dfea6a8e329ab4363e2afa6dea49</id>
<content type='text'>
A lot of code clean-up of xdiff.
Split out of a larger topic.

* en/xdiff-cleanup:
  xdiff: change type of xdfile_t.changed from char to bool
  xdiff: add macros DISCARD(0), KEEP(1), INVESTIGATE(2) in xprepare.c
  xdiff: rename rchg -&gt; changed in xdfile_t
  xdiff: delete chastore from xdfile_t
  xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t
  xdiff: delete redundant array xdfile_t.ha
  xdiff: delete struct diffdata_t
  xdiff: delete local variables that alias fields in xrecord_t
  xdiff: delete superfluous function xdl_get_rec() in xemit
  xdiff: delete unnecessary fields from xrecord_t and xdfile_t
  xdiff: delete local variables and initialize/free xdfile_t directly
  xdiff: delete static forward declarations in xprepare
</content>
</entry>
<entry>
<title>xdiff: change type of xdfile_t.changed from char to bool</title>
<updated>2025-10-03T17:19:40Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8b9c5d2e3a38b6e0c2278fe10fe2a4bf34496a9d'/>
<id>urn:sha1:8b9c5d2e3a38b6e0c2278fe10fe2a4bf34496a9d</id>
<content type='text'>
The only values possible for 'changed' is 1 and 0, which exactly maps
to a bool type. It might not look like this because action1 and action2
(which use to be dis1, and dis2) were also of type char and were
assigned numerical values within a few lines of 'changed' (what used to
be rchg).

Using DISCARD/KEEP/INVESTIGATE for action1[i]/action2[j], and true/false
for changed[k] makes it clear to future readers that these are
logically separate concepts.

Best-viewed-with: --color-words
Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: add macros DISCARD(0), KEEP(1), INVESTIGATE(2) in xprepare.c</title>
<updated>2025-10-03T17:19:40Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e385e1b7d2d7f531a0006131e7f1d974de351df5'/>
<id>urn:sha1:e385e1b7d2d7f531a0006131e7f1d974de351df5</id>
<content type='text'>
This commit is refactor-only; no behavior is changed. A future commit
will use bool literals for changed[i].

The functions xdl_clean_mmatch() and xdl_cleanup_records() will be
cleaned up more in a future patch series. The changes to
xdl_cleanup_records(), in this patch, are just to make it clear why
`char rchg` is refactored to `bool changed`.

Rename dis* to action* and replace literal numericals with macros.
The old names came from when dis* (which I think was short for discard)
was treated like a boolean, but over time it grew into a ternary state
machine. The result was confusing because dis* and rchg* both used 0/1
values with different meanings.

The new names and macros make the states explicit. nm is short for
number of matches, and mlim is a heuristic limit:

  nm == 0       -&gt; action[i] = DISCARD     -&gt; changed[i] = true
  0 &lt; nm &lt; mlim -&gt; action[i] = KEEP        -&gt; changed[i] = false
  nm &gt;= mlim    -&gt; action[i] = INVESTIGATE -&gt; changed[i] = xdl_clean_mmatch()

When need_min is true, only DISCARD and KEEP occur because the limit
is effectively infinite.

Best-viewed-with: --color-words
Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: rename rchg -&gt; changed in xdfile_t</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b7de64a6d6f58953a0c1dc7ff34f7080b3e38b37'/>
<id>urn:sha1:b7de64a6d6f58953a0c1dc7ff34f7080b3e38b37</id>
<content type='text'>
The field rchg (now 'changed') declares if a line in a file is changed
or not. A later commit will change it's type from 'char' to 'bool'
to make its purpose even more clear.

Best-viewed-with: --color-words
Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete chastore from xdfile_t</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d43d591252cfac10433aac01cc3d9d906c2f72c3'/>
<id>urn:sha1:d43d591252cfac10433aac01cc3d9d906c2f72c3</id>
<content type='text'>
xdfile_t currently uses chastore_t which is an arena allocator. I
think that xrecord_t used to be a linked list and recs didn't exist
originally. When recs was added I think they forgot to remove
xdfile_t.next, but was overlooked. This dual data structure setup
makes the code somewhat confusing.

Additionally the C type chastore_t isn't FFI friendly, and provides
little to no performance benefit over using realloc to grow an array.

Performance impact of deleting fields from xdfile_t:
Deleting ha is about 5% slower.
Deleting cha is about 5% faster.

Delete ha, but keep cha
  time hyperfine --warmup 3 -L exe build_v2.51.0/git,build_delete_ha/git '{exe} log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null'
  Benchmark 1: build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.269 s ±  0.017 s    [User: 1.135 s, System: 0.128 s]
    Range (min … max):    1.249 s …  1.286 s    10 runs

  Benchmark 2: build_delete_ha/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.339 s ±  0.017 s    [User: 1.234 s, System: 0.099 s]
    Range (min … max):    1.320 s …  1.358 s    10 runs

  Summary
    build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null ran
      1.06 ± 0.02 times faster than build_delete_ha/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null

Delete cha, but keep ha
  time hyperfine --warmup 3 -L exe build_v2.51.0/git,build_delete_chastore/git '{exe} log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null'
  Benchmark 1: build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.290 s ±  0.001 s    [User: 1.154 s, System: 0.130 s]
    Range (min … max):    1.288 s …  1.292 s    10 runs

  Benchmark 2: build_delete_chastore/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.232 s ±  0.017 s    [User: 1.105 s, System: 0.121 s]
    Range (min … max):    1.205 s …  1.249 s    10 runs

  Summary
    build_delete_chastore/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null ran
      1.05 ± 0.01 times faster than build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null

Delete ha AND chastore
  time hyperfine --warmup 3 -L exe build_v2.51.0/git,build_delete_ha_and_chastore/git '{exe} log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null'
  Benchmark 1: build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.291 s ±  0.002 s    [User: 1.156 s, System: 0.129 s]
    Range (min … max):    1.287 s …  1.295 s    10 runs

  Benchmark 2: build_delete_ha_and_chastore/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null
    Time (mean ± σ):      1.306 s ±  0.001 s    [User: 1.195 s, System: 0.105 s]
    Range (min … max):    1.305 s …  1.308 s    10 runs

  Summary
    build_v2.51.0/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null ran
      1.01 ± 0.00 times faster than build_delete_ha_and_chastore/git log --oneline --shortstat --diff-algorithm=myers -3000 v2.39.1 &gt;/dev/null

Best-viewed-with: --color-words
Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6d507bd41a6f57f802a93a134cca0949a3d4370a'/>
<id>urn:sha1:6d507bd41a6f57f802a93a134cca0949a3d4370a</id>
<content type='text'>
The fields from xdlclass_t are aliases of xrecord_t:
xdlclass_t.line -&gt; xrecord_t.ptr
xdlclass_t.size -&gt; xrecord_t.size
xdlclass_t.ha   -&gt; xrecord_t.ha

xdlclass_t carries a copy of the data in xrecord_t, but instead of
embedding xrecord_t it duplicates the individual fields. A future
commit will change the types used in xrecord_t so embed it in
xdlclass_t first, so we don't have to remember to change the types
here as well.

Best-viewed-with: --color-words
Helped-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete redundant array xdfile_t.ha</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5c294dceb23633a8bcced946ce3f65a06038cf52'/>
<id>urn:sha1:5c294dceb23633a8bcced946ce3f65a06038cf52</id>
<content type='text'>
When 0 &lt;= i &lt; xdfile_t.nreff the following is true:
xdfile_t.ha[i] == xdfile_t.recs[xdfile_t.rindex[i]]

This makes the code about 5% slower. The fields rindex and ha are
specific to the classic diff (myers and minimal). I plan on creating a
struct for classic diff, but there's a lot of cleanup that needs to be
done before that can happen and leaving ha in would make those cleanups
harder to follow.

A subsequent commit will delete the chastore cha from xdfile_t. That
later commit will investigate deleting ha and cha independently and
together.

Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete struct diffdata_t</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f4ea812b2d930fb1825b99dc11ca186691dade99'/>
<id>urn:sha1:f4ea812b2d930fb1825b99dc11ca186691dade99</id>
<content type='text'>
Every field in this struct is an alias for a certain field in xdfile_t.

diffdata_t.nrec   -&gt; xdfile_t.nreff
diffdata_t.ha     -&gt; xdfile_t.ha
diffdata_t.rindex -&gt; xdfile_t.rindex
diffdata_t.rchg   -&gt; xdfile_t.rchg

I think this struct existed before xdfile_t, and was kept for backward
compatibility reasons. I think xdiffi should have been refactored to
use the new (xdfile_t) struct, but was easier to alias it instead.

The local variables rchg* and rindex* don't shorten the lines by much,
nor do they really need to be there to make the code more readable.
Delete them.

Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete local variables that alias fields in xrecord_t</title>
<updated>2025-09-30T21:12:46Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7c6ce2e47b274b299dd0a3b185e70f2ee5e3e07a'/>
<id>urn:sha1:7c6ce2e47b274b299dd0a3b185e70f2ee5e3e07a</id>
<content type='text'>
Use the type xrecord_t as the local variable for the functions in the
file xdiff/xemit.c. Most places directly reference the fields inside of
this struct, doing that here makes it more consistent with the rest of
the code.

Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>xdiff: delete superfluous function xdl_get_rec() in xemit</title>
<updated>2025-09-30T21:12:39Z</updated>
<author>
<name>Ezekiel Newren</name>
<email>ezekielnewren@gmail.com</email>
</author>
<published>2025-09-26T22:41:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7bdeb3afad908e52baab6e58397423aa2d2f3d29'/>
<id>urn:sha1:7bdeb3afad908e52baab6e58397423aa2d2f3d29</id>
<content type='text'>
When xrecord_t was a linked list, and recs didn't exist, I assume this
function walked the list until it found the right record. Accessing
a contiguous array is so trivial that this function is now superfluous.
Delete it.

Signed-off-by: Ezekiel Newren &lt;ezekielnewren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
