Optimize circular buffer to avoid modulo

CLA: trivial

Avoid doing the division via modulo where possible.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23097)
This commit is contained in:
Rose 2023-12-19 11:19:38 -05:00 committed by Tomas Mraz
parent 6e155858d7
commit d6e4056805

View File

@ -141,9 +141,10 @@ int BIO_hex_string(BIO *out, int indent, int width, const void *data,
BIO_printf(out, "%02X:", d[i]);
j = (j + 1) % width;
if (!j)
if (++j >= width) {
j = 0;
BIO_printf(out, "\n");
}
}
if (i && !j)