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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Kjetil Barvik <barvik@xxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux