From: Kjetil Barvik <barvik@broadpark.no>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] make the ST_{C,M}TIME_NSEC macros more function like
Date: Tue, 17 Mar 2009 18:38:59 +0100 [thread overview]
Message-ID: <86bps0t5fw.fsf@broadpark.no> (raw)
In-Reply-To: <7vhc1ux7nx.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> 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
next prev parent reply other threads:[~2009-03-17 17:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-15 11:38 [PATCH 0/2] git checkout: one bugfix and one cosmetic change Kjetil Barvik
2009-03-15 11:38 ` [PATCH 1/2] checkout bugfix: use stat.mtime instead of stat.ctime in two places Kjetil Barvik
2009-03-15 11:38 ` [PATCH 2/2] make the ST_{C,M}TIME_NSEC macros more function like Kjetil Barvik
2009-03-15 20:01 ` Junio C Hamano
2009-03-15 21:59 ` Kjetil Barvik
2009-03-16 7:12 ` Junio C Hamano
2009-03-17 17:38 ` Kjetil Barvik [this message]
2009-03-15 18:21 ` [PATCH 0/2] git checkout: one bugfix and one cosmetic change Junio C Hamano
2009-03-15 19:38 ` Junio C Hamano
2009-03-16 16:12 ` Michael J Gruber
2009-03-17 4:56 ` Kris Shannon
2009-03-17 8:43 ` Jeff King
2009-03-17 13:39 ` Michael J Gruber
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=86bps0t5fw.fsf@broadpark.no \
--to=barvik@broadpark.no \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).