git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH, WAS: "weird diff output?" 1/2] xdiff: add xdl_hash_and_recmatch helper function

From
Jacob Keller <jacob.keller@gmail.com>
Date
Apr 15, 2016, 19:09 UTC
Message-ID
<CA+P7+xquEuu0aLb9vFaFhzun4YYW4PmiXycAt01HUxxUXqUuyQ@mail.gmail.com>
In-Reply-To
<xmqq60vidbsu.fsf@gitster.mtv.corp.google.com>
On Fri, Apr 15, 2016 at 10:25 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
> Jacob Keller <jacob.e.keller@intel.com> writes:
>
>> From: Jacob Keller <jacob.keller@gmail.com>
>>
>> It is a common pattern in xdl_change_compact to check that hashes and
>> strings match. The resulting code to perform this change causes very
>> long lines and makes it hard to follow the intention. Introduce a helper
>> function xdl_hash_and_recmatch which performs both checks to increase
>> code readability.
>
> Think _why_ it is common to check hash and then do recmatch().  What
> is the combination of two trying to compute?
>
> How about calling it after "what" it computes, not after "how" it
> computes it?  E.g.
>
>     static int recs_match(xrecord_t **recs, long x, long y, long flags)
>
> if we answer the above question "they try to see if two records match".
> We could also go s/recs/lines/.
>
> The xdl_recmatch() function appears in xutils.c, and over there the
> functions do not use arrays of (xrecord_t *), so I think we are
> better off without xdl_ prefix to avoid confusion.
>

That makes sense. I like the sound of recs_match, and it's shorter too which is nice.

Regards, Jake

Previous: Junio C HamanoNext: Jacob Keller
Message 4 of 22 in “implement better chunk heuristics”
  1. 0/2 implement better chunk heuristicsJacob Keller, Apr 15, 2016
  2. 1/2 xdiff: add xdl_hash_and_recmatch helper functionJacob Keller, Apr 15, 2016
  3. Junio C HamanoApr 15, 2016
  4. Jacob KellerApr 15, 2016
  5. 2/2 xdiff: implement empty line chunk heuristicJacob Keller, Apr 15, 2016
  6. Stefan BellerApr 15, 2016
  7. Junio C HamanoApr 15, 2016
  8. Jacob KellerApr 15, 2016
  9. Junio C HamanoApr 15, 2016
  10. Jacob KellerApr 15, 2016
  11. Jacob KellerApr 15, 2016
  12. Junio C HamanoApr 15, 2016
  13. Jacob KellerApr 15, 2016
  14. Jacob KellerApr 15, 2016
  15. Stefan BellerApr 15, 2016
  16. Stefan BellerApr 15, 2016
  17. Junio C HamanoApr 15, 2016
  18. Stefan BellerApr 15, 2016
  19. Junio C HamanoApr 15, 2016
  20. Jacob KellerApr 15, 2016
  21. Jacob KellerApr 15, 2016
  22. Jacob KellerApr 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.