From 3a03072abfaab683337c54922feca3d5cb096254 Mon Sep 17 00:00:00 2001 From: sigsegv7 Date: Sun, 17 Sep 2023 07:25:44 -0400 Subject: Optimize step decrementation logic Signed-off-by: sigsegv7 --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 1eef5eb..b889ec2 100644 --- a/main.c +++ b/main.c @@ -89,7 +89,8 @@ encrypt(char *buf, size_t buf_size) /* Ensure we don't cause any overflows */ while (((current_pos + step) >= buf_size) && step > 1) - step /= 2; + /* Essentially divide the step by 2, just faster */ + step >>= 1; } } -- cgit v1.2.3