]> 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>
Thu, 7 Jan 2021 13:49:44 +0000 (14:49 +0100)
commit41cd68416c8f35e80523fb3102b6a9c9982446c4
tree643119e80c844893c01453d3f52bf36d50e55b0f
parent94b33ba705c75a6c02fc0567f0d6a776d4f03d07
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