From db89021276d9d501dbb6f8a0485d4b5754113b7f Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 28 May 2022 13:39:51 +0800 Subject: Optimization: reduce checking stop_signal. --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1589c6a..5b2f73d 100644 --- a/main.c +++ b/main.c @@ -60,8 +60,10 @@ bool yield_possible_key( uint64_t plaintext; char key[8]; symmetric_key skey; + /* check `stop_signal` after every 256 round of loop */ + uint8_t check_stop = 0; do { - if ((b != 0 && k >= b) || atomic_load(stop_signal)) { + if ((b != 0 && k >= b) || (!check_stop++ && atomic_load(stop_signal))) { // out of range, stop ctx->finished = true; return false; -- cgit v1.2.3