Unnecessary use of sizeof() #3

Closed
Doctor-Coomer wants to merge 1 commits from master into master
Doctor-Coomer commented 2024-01-20 06:33:16 +00:00 (Migrated from github.com)

Hello,

The "size of" the data type char is always going to be one byte. The math in calculating names of players or the map doesn't need sizeof() calls, especially with a data type that is only one byte.

Multiplying numbers by one is useless.

Hello, The "size of" the data type char is always going to be one byte. The math in calculating names of players or the map doesn't need sizeof() calls, especially with a data type that is only one byte. Multiplying numbers by one is useless.
ALittlePatate commented 2024-01-20 10:46:01 +00:00 (Migrated from github.com)

Hey, thanks the interest you have in this project.
The use of sizeof() when allocating memory is good practice, even if sizeof(char) is always 1 on modern hardware.
The multiplication you're talking about will be evaluated at compile time, thus resulting in the exact same assembly code.

Hey, thanks the interest you have in this project. The use of sizeof() when allocating memory is good practice, even if sizeof(char) is always 1 on modern hardware. The multiplication you're talking about will be evaluated at compile time, thus resulting in the exact same assembly code.

Pull request closed

Sign in to join this conversation.