From ba463680f5aa62d192180c2ca30e93132ab1075f Mon Sep 17 00:00:00 2001 From: Solar Designer Date: Mon, 27 May 2024 22:19:04 +0200 Subject: [PATCH] Shuffle external mode: Optimization: Don't rewrite unchanged part --- run/john.conf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/run/john.conf b/run/john.conf index d9ef775654..f8e79ce821 100644 --- a/run/john.conf +++ b/run/john.conf @@ -3971,7 +3971,7 @@ void next() # Shuffle (try all permutations of) characters in each short input word [List.External:Shuffle] -int max_length, unique, length, base[0x80], id[0x80], jd[0x80]; +int max_length, unique, length, base[0x80], id[0x80], jd[0x80], unseen[0x80]; void init() { @@ -3998,11 +3998,13 @@ void new() } } } + + unseen = 0; } void next() { - int unseen, c, i, j, k; + int prev_unseen, c, i, j, k; if ((i = length) <= max_length) while (i--) { @@ -4011,17 +4013,21 @@ void next() continue; } - unseen = i = -1; + prev_unseen = -1; + if (!unseen) + unseen = i = -1; + else if (i--) + prev_unseen = unseen[i]; while (++i < length) { /* Skip id[i] previously unseen char indices */ j = -1; k = id[i]; while (k >= 0) - if (unseen & (1 << ++j)) + if (prev_unseen & (1 << ++j)) k--; if (unique) { word[i] = base[j]; - unseen &= ~(1 << j); + unseen[i] = prev_unseen &= ~(1 << j); continue; } /* Same chars must only appear in one order */ @@ -4036,7 +4042,7 @@ void next() if (k < i) break; word[i] = c; - unseen &= ~(1 << (jd[i] = j)); + unseen[i] = prev_unseen &= ~(1 << (jd[i] = j)); } if (i >= length) /* Not a dupe */