randomSeed: Bad/redundant "if"
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
In function `randomSeed` (`WMath.cpp`, line 30) there's the code
```cpp
if (seed != 0) {
srandom(seed);
}
```
Since "srandom" handles the value 0 itself (see for example its implementation in `random.c` of AVR-Libc*), it seems there's no need for that "if". Furthermore, it is undocumented and may break functionality - for instance, if a user wants to produce two identical pseudo-random sequences using the seed 0.
- https://github.com/vancegroup-mirrors/avr-libc/blob/master/avr-libc/libc/stdlib/random.c
If that "if" can be removed, it will save a byte or two.
See discussion about this here (not all of it directly relevant): https://forum.arduino.cc/t/randomseed-why-is-0-ignored/337424
Thanks,
Contributor guide
Assessment
This issue has not been assessed yet.