Simplify and optimize __fill_random_buf
authorGeorg Sauthoff <mail@gms.tf>
Thu, 30 Jun 2022 21:30:46 +0000 (23:30 +0200)
committerGeorg Sauthoff <mail@gms.tf>
Thu, 30 Jun 2022 23:12:06 +0000 (01:12 +0200)
commit36c4e89c70973bce3f7984bb1488c34eeac27fc1
treed08b82b395d1a35e750820778c546dea44f8fc85
parent660879102e32a0ed3d3225afaebcc0d46625a4a6
Simplify and optimize __fill_random_buf

This reduces the number of source lines and the code size.

For example, when compiling with GCC 12.1 (-O3 -march=skylake), the
resulting assembly shrinks from 33 to 27 instructions and the number of
jump instructions is reduced from 4 to 3.

NB: GCC is able to eliminate the memcpy() call.

NB: Even if a compiler doesn't eliminate the memcpy() call, it's very
unlikely to ever get called since the buffer sizes are expected to be
powers of two (>= 8), usually.

Signed-off-by: Georg Sauthoff <mail@gms.tf>
lib/rand.c