git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ezekiel Newren <ezekielnewren@gmail.com>
Cc: Phillip Wood <phillip.wood123@gmail.com>,
	 Ezekiel Newren via GitGitGadget <gitgitgadget@gmail.com>,
	 git@vger.kernel.org,  Elijah Newren <newren@gmail.com>,
	 Ben Knoble <ben.knoble@gmail.com>,  Jeff King <peff@peff.net>
Subject: Re: [PATCH v5 10/13] xdiff: delete rchg aliasing
Date: Thu, 25 Sep 2025 00:09:50 -0700	[thread overview]
Message-ID: <xmqqh5wrhutd.fsf@gitster.g> (raw)
In-Reply-To: <CAH=ZcbAm8++qGNX883epk0h3NA-Z=8+RX1bDJeTe=n2jjSsdmg@mail.gmail.com> (Ezekiel Newren's message of "Wed, 24 Sep 2025 16:46:34 -0600")

Ezekiel Newren <ezekielnewren@gmail.com> writes:

> I'd agree that my reasons for making this change are insufficient. I
> think usage tracking tools _is_ a weak argument, but perhaps not quite
> as weak as what you're thinking. For example, when I renamed the rchg
> field to changed, it was as simple as right-clicking the field,
> choosing Rename, typing 'changed', and letting the IDE update every
> use. Patch 11/13, "xdiff: rename rchg -> changed in xdfile_t", was
> generated directly from that one action. That patch was clean because
> I had already gone through and removed all the aliases of that field.

If I am reading you correctly, you are describing IDE's syntax-aware
editor's symbol renaming feature; I am not quite sure what it has to
do with "usage tracking", which would be more of static analysis
thing, no?

Surely, IDE makes these symbol renaming easy and that would be one
reason that makes "because we will change this part of the code in
later commit" less relevant, isn't it?  Whether the struct member
rchg is accessed directly in the conditional and loop, or is used as
the source of an assignment to a local variable, it needs to be
renamed either way.  And with tools, it is not as bad.

>> Sure.  But looking at the use of rchg[12] in xdl_build_script(), if
>> they were "const char *", combined with the fact that they are local
>> and their addresses are never taken (to be leaked to our callers),
>> you wouldn't have much trouble with the current code, or would you
>> still have issues?
>
> For xdl_build_script() specifically it would work just fine keeping
> the local variable aliasing in.

And transliterating that directly to Rust would not cause the borrow
issue as you described?  Then it would be great.  One less thing to
worry about when we need to look at C and then write an equivalent
in Rust.

> 2. Keep this commit with reasons like this:
>   * Refactor churn: Later commits will refactor rchg.
>   * No additional meaning: The local variables express the same
> meaning as the struct field itself. Also, the conditional and the
> inner loop is easy enough to follow without using the local aliases to
> make the code shorter.

If you have to go route #2, I can live with it, but "No additional
meaning" is _not_ a valid reason to remove aliasing variables.

By definition, a local variable that aliases something like a deeply
nested structure member should *not* introduce any additional
meaning (in other words, if the code modifies that local variable
making it out of sync with the underlying structure, the variable is
not without "addtional meaning" and is no longer an alias).

The whole reason I asked you to justify removal of the local
variable on the basis of lack of readability improvement ("the
original is simple enough to read without shorter variables") was
just that.  "This variable is merely an alias to something else",
aka "There is no meaning added by the presence of this variable", is
*not* a valid reason to remove it by itself.

So, with the same code but with a better justification like "the
original uses a few local variables to shorten the code, but open
coding the access to underlying members of nested structure without
these local variables is not all that hard to read, so let's do so",
would probably be an acceptable explanation with no need for other
excuses, I would think.

Thanks.

  reply	other threads:[~2025-09-25  7:09 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-07 19:45 [PATCH 00/17] Use rust types in xdiff Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 01/17] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-09  8:55   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 02/17] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-09  8:56   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 03/17] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-09  8:56   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 04/17] xdiff: delete xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-09  8:56   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 05/17] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-09  8:56   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 06/17] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-09  8:57   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 07/17] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-09  8:57   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 08/17] xdiff: delete chastore from xdfile_t, view with --color-words Ezekiel Newren via GitGitGadget
2025-09-09  8:58   ` Elijah Newren
2025-09-09 13:50     ` Phillip Wood
2025-09-09 20:33     ` Junio C Hamano
2025-09-10 22:02     ` Ben Knoble
2025-09-07 19:45 ` [PATCH 09/17] xdiff: treat xdfile_t.rchg like an enum Ezekiel Newren via GitGitGadget
2025-09-09  8:58   ` Elijah Newren
2025-09-07 19:45 ` [PATCH 10/17] compat/rust_types.h: define rust primitive types Ezekiel Newren via GitGitGadget
2025-09-08 15:08   ` Junio C Hamano
2025-09-08 16:15     ` Ezekiel Newren
2025-09-07 19:45 ` [PATCH 11/17] xdiff: include compat/rust_types.h Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 12/17] xdiff: make xrecord_t.ptr a u8 instead of char Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 13/17] xdiff: make xrecord_t.size a usize instead of long Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 14/17] xdiff: split xrecord_t.ha into line_hash and minimal_perfect_hash Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 15/17] xdiff: make xdfile_t.nrec a usize instead of long Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 16/17] xdiff: make xdfile_t.nreff " Ezekiel Newren via GitGitGadget
2025-09-07 19:45 ` [PATCH 17/17] xdiff: change the types of dstart, dend, rchg, and rindex in xdfile_t Ezekiel Newren via GitGitGadget
2025-09-16 21:56 ` [PATCH 00/17] Use rust types in xdiff Junio C Hamano
2025-09-16 22:01   ` Ezekiel Newren
2025-09-17  2:16     ` Elijah Newren
2025-09-17 13:53       ` Junio C Hamano
2025-09-17  6:22     ` Junio C Hamano
2025-09-18 23:56 ` [PATCH v2 00/10] " Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 01/10] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 02/10] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 03/10] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 04/10] xdiff: delete xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 05/10] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 06/10] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 07/10] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 08/10] xdiff: delete chastore from xdfile_t Ezekiel Newren via GitGitGadget
2025-09-18 23:56   ` [PATCH v2 10/10] xdiff: treat xdfile_t.rchg like an enum Ezekiel Newren via GitGitGadget
2025-09-19  0:33   ` [PATCH v2 00/10] Use rust types in xdiff Junio C Hamano
2025-09-19  0:41     ` Ezekiel Newren
2025-09-19 15:15     ` Ezekiel Newren
2025-09-19 15:16   ` [PATCH v3 00/10] Cleanup xdfile_t and xrecord_t " Ezekiel Newren via GitGitGadget
2025-09-19 15:16     ` [PATCH v3 01/10] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-20 17:16       ` Junio C Hamano
2025-09-20 17:41         ` Ezekiel Newren
2025-09-20 18:31           ` Elijah Newren
2025-09-20 22:25             ` Ben Knoble
2025-09-20 22:43             ` Junio C Hamano
2025-09-20 17:46         ` Ben Knoble
2025-09-20 18:46           ` Jeff King
2025-09-20 22:25             ` Ben Knoble
2025-09-20 22:52             ` Junio C Hamano
2025-09-20 23:15               ` Jeff King
2025-09-19 15:16     ` [PATCH v3 02/10] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-20 17:36       ` Junio C Hamano
2025-09-19 15:16     ` [PATCH v3 03/10] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-19 15:16     ` [PATCH v3 04/10] xdiff: delete xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-20 17:48       ` Junio C Hamano
2025-09-21 13:06       ` Phillip Wood
2025-09-21 15:07         ` Ezekiel Newren
2025-09-19 15:16     ` [PATCH v3 05/10] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-21 13:06       ` Phillip Wood
2025-09-21 16:03         ` Ezekiel Newren
2025-09-19 15:16     ` [PATCH v3 06/10] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-19 15:16     ` [PATCH v3 07/10] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-21 13:06       ` Phillip Wood
2025-09-21 16:07         ` Ezekiel Newren
2025-09-19 15:16     ` [PATCH v3 08/10] xdiff: delete chastore from xdfile_t Ezekiel Newren via GitGitGadget
2025-09-19 15:16     ` [PATCH v3 09/10] xdiff: delete rchg aliasing Ezekiel Newren via GitGitGadget
2025-09-21 13:07       ` Phillip Wood
2025-09-21 16:37         ` Ezekiel Newren
2025-09-19 15:16     ` [PATCH v3 10/10] xdiff: treat xdfile_t.rchg like an enum Ezekiel Newren via GitGitGadget
2025-09-21  0:00       ` Junio C Hamano
2025-09-21  0:38         ` Ezekiel Newren
2025-09-21  9:19           ` Phillip Wood
2025-09-21 16:11             ` Ezekiel Newren
2025-09-19 23:30     ` [PATCH v3 00/10] Cleanup xdfile_t and xrecord_t in xdiff Elijah Newren
2025-09-19 23:37       ` Ezekiel Newren
2025-09-22 19:51     ` [PATCH v4 00/12] " Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 01/12] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 02/12] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 03/12] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 04/12] xdiff: delete superfluous function xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 05/12] xdiff: delete superfluous local variables that alias fields in xrecord_t Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 06/12] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 07/12] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 08/12] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 09/12] xdiff: delete chastore from xdfile_t Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 10/12] xdiff: delete rchg aliasing Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 11/12] xdiff: use bool literals for xdfile_t.rchg Ezekiel Newren via GitGitGadget
2025-09-22 19:51       ` [PATCH v4 12/12] xdiff: refactor 'char *rchg' to 'bool *changed' in xdfile_t Ezekiel Newren via GitGitGadget
2025-09-22 22:39       ` [PATCH v4 00/12] Cleanup xdfile_t and xrecord_t in xdiff Junio C Hamano
2025-09-23  0:13         ` Ezekiel Newren
2025-09-23  1:06           ` Junio C Hamano
2025-09-23  1:30             ` Ezekiel Newren
2025-09-23 14:12               ` Junio C Hamano
2025-09-23 16:50                 ` Ezekiel Newren
2025-09-23 21:24       ` [PATCH v5 00/13] " Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 01/13] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 02/13] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 03/13] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 04/13] xdiff: delete superfluous function xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-30 13:31           ` Kristoffer Haugsbakk
2025-09-30 19:35             ` Ezekiel Newren
2025-09-30 20:05               ` Junio C Hamano
2025-09-23 21:24         ` [PATCH v5 05/13] xdiff: delete superfluous local variables that alias fields in xrecord_t Ezekiel Newren via GitGitGadget
2025-09-24 10:22           ` Phillip Wood
2025-09-24 14:52             ` Ezekiel Newren
2025-09-23 21:24         ` [PATCH v5 06/13] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 07/13] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 08/13] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 09/13] xdiff: delete chastore from xdfile_t Ezekiel Newren via GitGitGadget
2025-09-23 21:24         ` [PATCH v5 10/13] xdiff: delete rchg aliasing Ezekiel Newren via GitGitGadget
2025-09-24 10:22           ` Phillip Wood
2025-09-24 15:01             ` Ezekiel Newren
2025-09-24 15:34               ` Junio C Hamano
2025-09-24 15:58                 ` Ezekiel Newren
2025-09-24 21:31                   ` Junio C Hamano
2025-09-24 22:46                     ` Ezekiel Newren
2025-09-25  7:09                       ` Junio C Hamano [this message]
2025-09-25 22:02                         ` Ezekiel Newren
2025-09-23 21:24         ` [PATCH v5 11/13] xdiff: rename rchg -> changed in xdfile_t Ezekiel Newren via GitGitGadget
2025-09-24 10:22           ` Phillip Wood
2025-09-24 15:10             ` Ezekiel Newren
2025-09-24 15:18               ` Phillip Wood
2025-09-23 21:24         ` [PATCH v5 12/13] xdiff: use enum macros NONE(0), SOME(1), TOO_MANY(2) in xprepare.c Ezekiel Newren via GitGitGadget
2025-09-24 10:21           ` Phillip Wood
2025-09-24 14:46             ` Ezekiel Newren
2025-09-24 15:18               ` Phillip Wood
2025-09-24 17:29                 ` Junio C Hamano
2025-09-25 18:40                 ` Ezekiel Newren
2025-09-26  2:29                   ` Ezekiel Newren
2025-09-23 21:24         ` [PATCH v5 13/13] xdiff: change type of xdfile_t.changed from char to bool Ezekiel Newren via GitGitGadget
2025-09-24 10:21           ` Phillip Wood
2025-09-24 15:14             ` Ezekiel Newren
2025-09-26 22:41         ` [PATCH v6 00/12] Cleanup xdfile_t and xrecord_t in xdiff Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 01/12] xdiff: delete static forward declarations in xprepare Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 02/12] xdiff: delete local variables and initialize/free xdfile_t directly Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 03/12] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 04/12] xdiff: delete superfluous function xdl_get_rec() in xemit Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 05/12] xdiff: delete local variables that alias fields in xrecord_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 06/12] xdiff: delete struct diffdata_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 07/12] xdiff: delete redundant array xdfile_t.ha Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 08/12] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 09/12] xdiff: delete chastore from xdfile_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 10/12] xdiff: rename rchg -> changed in xdfile_t Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 11/12] xdiff: add macros DISCARD(0), KEEP(1), INVESTIGATE(2) in xprepare.c Ezekiel Newren via GitGitGadget
2025-09-26 22:41           ` [PATCH v6 12/12] xdiff: change type of xdfile_t.changed from char to bool Ezekiel Newren via GitGitGadget
2025-10-03 13:47           ` [PATCH v6 00/12] Cleanup xdfile_t and xrecord_t in xdiff Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh5wrhutd.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ben.knoble@gmail.com \
    --cc=ezekielnewren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).