aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-05-28 19:41:22 +1200
committerDavid Phillips <david@sighup.nz>2017-05-28 19:41:22 +1200
commit2c45b6e531f3630330ca1599bd96f7f12814fdc1 (patch)
tree66dac33db86b44b083c5bd3cabe00dbcf719194f
parentff244210acaf78beb6530c9f9d64a5f6965fdc75 (diff)
downloadsand-leek-2c45b6e531f3630330ca1599bd96f7f12814fdc1.tar.xz
Revert "Change raw_len from hard-coded to equation"
This reverts commit ff244210acaf78beb6530c9f9d64a5f6965fdc75. This actually made the algorithm slightly slower
-rw-r--r--sand-leek.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sand-leek.c b/sand-leek.c
index 66e1f0e..a5de3d0 100644
--- a/sand-leek.c
+++ b/sand-leek.c
@@ -177,7 +177,25 @@ work(void *arg) {
goto STOP;
}
- int raw_len = (search_len*10)/16;
+ int raw_len = 0;
+ switch (search_len) {
+ case 1: raw_len = 0; break;
+ case 2: raw_len = 1; break;
+ case 3: raw_len = 1; break;
+ case 4: raw_len = 2; break;
+ case 5: raw_len = 3; break;
+ case 6: raw_len = 3; break;
+ case 7: raw_len = 4; break;
+ case 8: raw_len = 5; break;
+ case 9: raw_len = 5; break;
+ case 10: raw_len = 6; break;
+ case 11: raw_len = 6; break;
+ case 12: raw_len = 7; break;
+ case 13: raw_len = 8; break;
+ case 14: raw_len = 8; break;
+ case 15: raw_len = 9; break;
+ case 16: raw_len = 10; break;
+ }
if (memcmp(sha, search_raw, raw_len) == 0) {
/* check the remaining partial byte */
switch (search_len) {