aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/v3/ngx_http_v3.c')
-rw-r--r--src/http/v3/ngx_http_v3.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/http/v3/ngx_http_v3.c b/src/http/v3/ngx_http_v3.c
index f7f79b9f4..e796da772 100644
--- a/src/http/v3/ngx_http_v3.c
+++ b/src/http/v3/ngx_http_v3.c
@@ -78,23 +78,22 @@ ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value, ngx_uint_t prefix)
value -= thresh;
- for (n = 10; n > 1; n--) {
- if (value >> (7 * (n - 1))) {
- break;
+ if (p == NULL) {
+ for (n = 2; value >= 128; n++) {
+ value >>= 7;
}
- }
- if (p == NULL) {
- return n + 1;
+ return n;
}
*p++ |= thresh;
- for ( /* void */ ; n > 1; n--) {
- *p++ = 0x80 | (value >> 7 * (n - 1));
+ while (value >= 128) {
+ *p++ = 0x80 | value;
+ value >>= 7;
}
- *p++ = value & 0x7f;
+ *p++ = value;
return (uintptr_t) p;
}