Skip to content

Commit

Permalink
Optimize circular buffer to avoid modulo
Browse files Browse the repository at this point in the history
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 #23097)
  • Loading branch information
AtariDreams authored and t8m committed Dec 22, 2023
1 parent 6e15585 commit d6e4056
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypto/bio/bio_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d6e4056

Please sign in to comment.