On Monday, 4 September 2023 at 09:41:54 UTC, BoQsc wrote:
I've seen everyone using **datatype**`.sizeof` property.

https://dlang.org/spec/property.html#sizeof

It's great, but I wonder if it differ in any way from the standard C function `sizeof()`.

https://www.geeksforgeeks.org/sizeof-operator-c/
https://en.cppreference.com/w/cpp/language/sizeof

I'm seeking for some speed/performance, so that's why the question.
Overall I'm alright with continuing using it.

In both case it's replaced at compile-time by an IntegerExpression (the ast node for an integer literal)

I would not loose too much time comparing the "postfix" style (D) with the "intrinsic" style (C). Possibly there might a few micro ops difference... so only significant compile-time difference for 1 Billion `sizeof` ;)

Reply via email to