Re:Performance Showdown: Rust vs Javascript (2020)
by nyanpasu64 on Friday February 12, 2021 @10:00AM
(#26114313)
yikes, that initializes the first 200 bytes to 0x00, or only the first 50 integers in the array. this code is... bad.
[ Parent
| on HN ]
Re:Performance Showdown: Rust vs Javascript (2020)
by felixr on Friday February 12, 2021 @10:57AM
(#26115016)
> only the first 50 integers
or the first 100 integers https://gcc.gnu.org/wiki/avr-gcc
Re:Performance Showdown: Rust vs Javascript (2020)
by MertsA on Sunday February 14, 2021 @05:15AM
(#26131044)
For anyone who isn't well versed in C, int is most of the time 32 bits but it's architecture dependent with some machines being e.g. 16 bit. If you need the size to be exactly 32 bits then you can just use int32_t or similar and let the compiler make that happen regardless of the architecture it's compiling to. The original code should have specified 200 * sizeof(int) or better yet since it's a local variable just ditch the memset and change it to int hasz[200] = {}; which will do the same.