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

Re: [PATCH 2/2] make the ST_{C,M}TIME_NSEC macros more function like

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Mar 17, 2009, 17:38 UTC
Message-ID
<86bps0t5fw.fsf@broadpark.no>
In-Reply-To
<7vhc1ux7nx.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Kjetil Barvik <barvik@broadpark.no> writes:
>
>>     [...] in C or Pascal, calling a function with a large structure as
>>     an argument will cause the entire structure to be copied,
>>     potentially causing serious performance degradation, and mutations
>>     to the structure are invisible to the caller. [...]
>>
>>   So in my eyes it make more sense to be consistent and take the address
>>   of all struct like objects (&st in this case) for all arguments to
>>   "function-like" things.
>
> Notice the "mutations to the structure are invisible to the caller" part.
> The call site of st_ctime_nsec(st) can be sure that st won't be modified,
> without checking the definition of the function.
>
> Which is actually a nice property.  When st_ctime_nsec(st) is implemented as
> a macro, you _could_ write it in such a way to mutate what is in st, but
> the implementation does not do so, and will be unlikely to in the future,
> so I think writing it as if it is a function that receives a structure by
> value will help readers of the calling code.
>
> And the readability is what we should optimize for when picking from two
> ways to write it, and when the generated code is the same.
  OK, I guess we can dropp this patch!  :-)
  -- kjetil
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 13 in “git checkout: one bugfix and one cosmetic change”
  1. 0/2 git checkout: one bugfix and one cosmetic changeKjetil Barvik, Mar 15, 2009
  2. 1/2 checkout bugfix: use stat.mtime instead of stat.ctime in two placesKjetil Barvik, Mar 15, 2009
  3. 2/2 make the ST_{C,M}TIME_NSEC macros more function likeKjetil Barvik, Mar 15, 2009
  4. Junio C HamanoMar 15, 2009
  5. Kjetil BarvikMar 15, 2009
  6. Junio C HamanoMar 16, 2009
  7. Kjetil BarvikMar 17, 2009
  8. Junio C HamanoMar 15, 2009
  9. Junio C HamanoMar 15, 2009
  10. Michael J GruberMar 16, 2009
  11. Kris ShannonMar 17, 2009
  12. Jeff KingMar 17, 2009
  13. Michael J GruberMar 17, 2009

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.