Skip to content

Commit

Permalink
Shuffle external mode: Skip dupe char search if unique so far
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed May 29, 2024
1 parent 19620df commit 2ecbae6
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions run/john.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3971,7 +3971,7 @@ void next()

# Shuffle (try all permutations of) characters in each short input word
[List.External:Shuffle]
int max_length, length, base[0x80], id[0x80], jd[0x80], unseen[0x80], unique[0x100], clz[0x1000];
int max_length, length, base[0x80], id[0x80], jd[0x80], unseen[0x80], unique[0x100], c2mask[0x100], clz[0x1000];

void init()
{
Expand All @@ -3990,19 +3990,15 @@ void new()
{
int c, i;

length = -1;
length = i = -1;
while (c = word[++length]) {
if (length > max_length)
return;
base[length] = c;
id[length] = 0;
i = unique[c] = -1;
while (++i < length) {
if (word[i] == c) {
unique[c] = 0;
break;
}
}
c2mask[base[length] = c] = id[length] = 0;
}
while (c = word[++i]) {
unique[c] = !c2mask[c];
c2mask[c] |= 1 << i;
}

unseen = 0;
Expand Down Expand Up @@ -4041,14 +4037,14 @@ void next()
unseen[i] = prev_unseen &= ~(1 << j);
continue;
}
/* Same chars must only appear in one order */
c = word[k = i];
while (k--)
if (word[k] == c)
break;
if (k >= 0)
/* or not unique so far */
if ((prev_unseen & (mask = c2mask[c = word[k = i]])) != mask) {
/* Same chars must only appear in one order */
while (word[--k] != c)
continue;
if (jd[k] >= j) /* Wrong order */
break;
}
unseen[i] = prev_unseen &= ~(1 << (jd[i] = j));
}

Expand Down

0 comments on commit 2ecbae6

Please sign in to comment.