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>
Fri, 1 Jul 2022 20:15:35 +0000 (22:15 +0200)
commit5366025a15bd794052d3e74be450c5a70e12bf0c
tree653ff24340f380fa9ce310b93568abe24332bff0
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