diff options
author | Sergey Kandaurov <pluknet@nginx.com> | 2020-04-22 14:52:16 +0300 |
---|---|---|
committer | Sergey Kandaurov <pluknet@nginx.com> | 2020-04-22 14:52:16 +0300 |
commit | db90ddcb9ed847b101ebb794bfadcd3ef829147c (patch) | |
tree | 8196f4514bf876c11cb81cd7b6c8115aafb411ed /src | |
parent | 9275f06a57fe43cbe79fc98c126817e591a0cef3 (diff) | |
download | nginx-db90ddcb9ed847b101ebb794bfadcd3ef829147c.tar.gz nginx-db90ddcb9ed847b101ebb794bfadcd3ef829147c.zip |
Improved ngx_quic_build_int() code and readability.
The function now generates somewhat shorter assembler after inlining.
Diffstat (limited to 'src')
-rw-r--r-- | src/event/ngx_event_quic_transport.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/event/ngx_event_quic_transport.c b/src/event/ngx_event_quic_transport.c index 1a2cada35..19e7ba305 100644 --- a/src/event/ngx_event_quic_transport.c +++ b/src/event/ngx_event_quic_transport.c @@ -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; } |