From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:19:38 +0000 (-0500) Subject: Optimize circular buffer to avoid modulo X-Git-Tag: openssl-3.3.0-alpha1~381 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6e4056805f54bb1a0ef41fa3a6a35b70c94edba;p=thirdparty%2Fopenssl.git Optimize circular buffer to avoid modulo CLA: trivial Avoid doing the division via modulo where possible. Reviewed-by: Matt Caswell Reviewed-by: Matthias St. Pierre Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/23097) --- diff --git a/crypto/bio/bio_dump.c b/crypto/bio/bio_dump.c index c453da62688..40c18410e4c 100644 --- a/crypto/bio/bio_dump.c +++ b/crypto/bio/bio_dump.c @@ -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)