summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-05-28 13:39:51 +0800
committerKeuin <[email protected]>2022-05-28 13:39:51 +0800
commitdb89021276d9d501dbb6f8a0485d4b5754113b7f (patch)
treef8b4c0d096a147a464ec4c6a5abdb9edaec21e6a
parent2718019bef355092a2f5e10f33c6002a1c261c2b (diff)
Optimization: reduce checking stop_signal.
-rw-r--r--main.c4
1 files changed, 3 insertions, 1 deletions
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;