:: Re: [DNG] simple-netaid from scratc…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Didier Kryn
Date:  
À: dng
Sujet: Re: [DNG] simple-netaid from scratch
Le 11/06/2019 à 20:40, Steve Litt a écrit :
> On Mon, 10 Jun 2019 15:01:53 +0100
> s@po <tuxd3v@???> wrote:
>
>> On Mon, 10 Jun 2019 13:34:54 +0100 (BST)
>> Jim Jackson <jj@???> wrote:
>>
>>> sizeof() is calculated by the compiler, not at run time. The code
>>> generated would be the same.
>> Hello Jim,
>> Indeed it his, my point was only a observation, that if size is
>> fixed, no need to calculate it at compile time, the preprocessor can
>> solve that with a macro.. The code generated will be indeed the same.
>> Only was a observation ;)
> I vote for leaving it as a function.
>
> What would be gained by making it a macro? A microsecond? What are the
> bottlenecks of the software? Are keyboard or mouse input involved?
>
> If these sizeof() calls are deep in a tight nested loop, by all means
> make them into a macro. Otherwise, why give up the simplicity of a
> function for the sometimes edge case weirdness of a macro?
>
> It's funny. So many times people advocate jumping through hoops to save
> a millisecond in a program operated by and therefore bottlenecked by a
> 100wpm typist. 100wpm is 500 keystrokes per minute, or 8.33 keystrokes
> per second, which means each keystroke takes 120 milliseconds. The 1ms
> savings *just doesn't matter*.
>
> And yes, as a matter of fact, I often do use "useless use of cat".
> Costs me nothing perceptible, and makes it easier to rearrange
> pipelines til I get them right.
>

    I fully agree that gaining milisecond is often futile. But this has
nothing to do with this discussion. The discussion was only about style.

    sizeof() is not a real function. Its syntax makes it look like a
function but it is not. Its argument can be either a variable or a type
(which no function can have). It is evaluated at compile time - which is
equivalent to replacing it with the litteral value.

    Didier