]> git.ipfire.org Git - thirdparty/wireguard-go.git/commit
device: simplify copying counter to nonce
authorJosh Bleecher Snyder <josh@tailscale.com>
Tue, 15 Dec 2020 02:30:13 +0000 (18:30 -0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 Dec 2020 17:11:55 +0000 (18:11 +0100)
commit74008520cdd9abe83033bc78a1f588f843b89eba
tree643119e80c844893c01453d3f52bf36d50e55b0f
parentae6b17f7595e3d425f7b63e470d159327018ef04
device: simplify copying counter to nonce

Since we already have it packed into a uint64
in a known byte order, write it back out again
the same byte order instead of copying byte by byte.

This should also generate more efficient code,
because the compiler can do a single uint64 write,
instead of eight bounds checks and eight byte writes.

Due to a missed optimization, it actually generates a mishmash
of smaller writes: 1 byte, 4 bytes, 2 bytes, 1 byte.
This is https://golang.org/issue/41663.
The code is still better than before, and will get better yet
once that compiler bug gets fixed.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
device/receive.go