Improved ngx_quic_build_int() code and readability.

The function now generates somewhat shorter assembler after inlining.
This commit is contained in:
Sergey Kandaurov 2020-04-22 14:52:16 +03:00
parent 9275f06a57
commit db90ddcb9e

View File

@ -238,29 +238,23 @@ static void
ngx_quic_build_int(u_char **pos, uint64_t value)
{
u_char *p;
ngx_uint_t len;//, len2;
ngx_uint_t bits, len;
p = *pos;
len = 0;
bits = 0;
while (value >> ((1 << len) * 8 - 2)) {
len++;
while (value >> ((8 << bits) - 2)) {
bits++;
}
*p = len << 6;
len = (1 << bits);
// len2 =
len = (1 << len);
len--;
*p |= value >> (len * 8);
p++;
while (len) {
*p++ = value >> ((len-- - 1) * 8);
while (len--) {
*p++ = value >> (len * 8);
}
**pos |= bits << 6;
*pos = p;
// return len2;
}