Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ int roll_table::unique_rolls(int count, int* results, luck_type rollee_luck, int
int seen_capacity = 256;
int seen_mask = 255;
std::vector<int> heap_seen;
uint64_t fast_mask = 0;

if (use_set)
{
Expand Down Expand Up @@ -259,6 +260,13 @@ int roll_table::unique_rolls(int count, int* results, luck_type rollee_luck, int
seen[h] = k;
}
}
else
{
for (int j = 0; j < start_index; j++)
{
fast_mask |= (1ULL << (results[j] & 63));
}
}

for (int i = 0; i < count; i++)
{
Expand All @@ -278,10 +286,14 @@ int roll_table::unique_rolls(int count, int* results, luck_type rollee_luck, int
}
else
{
for (int j = 0; j < start_index + i; j++)
if (fast_mask & (1ULL << (k & 63)))
{
if (results[j] == k) goto repeat;
for (int j = 0; j < start_index + i; j++)
{
if (results[j] == k) goto repeat;
}
}
fast_mask |= (1ULL << (k & 63));
}
results[start_index + i] = k;
}
Expand Down
Loading