From d6e4056805f54bb1a0ef41fa3a6a35b70c94edba Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:19:38 -0500 Subject: [PATCH] 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) --- crypto/bio/bio_dump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/bio/bio_dump.c b/crypto/bio/bio_dump.c index c453da6268..40c18410e4 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)