Skip to content

Commit

Permalink
Speedups: intset: fix corner case for int64 on 32bit systems
Browse files Browse the repository at this point in the history
original idea was to only use bucket->val if int<pointer,
but we always have a union now anyway
  • Loading branch information
black-sliver committed Feb 4, 2024
1 parent ea9d933 commit 809ad6a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions intset.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ static bool INTSET_FUNC(add)(INTSET_NAME *set, INTSET_TYPE val)
return true; /* ok */

bucket = set->buckets + ((size_t)val % set->bucket_count);
if (bucket->count == 0 && sizeof(INTSET_TYPE) <= sizeof(INTSET_TYPE*)) {
if (bucket->count == 0) {
bucket->val = val;
bucket->count = 1;
} else if (bucket->count == 1 && sizeof(INTSET_TYPE) <= sizeof(INTSET_TYPE*)) {
} else if (bucket->count == 1) {
INTSET_TYPE old = bucket->val;
bucket->data = (INTSET_TYPE*)malloc(2 * sizeof(INTSET_TYPE));
if (!bucket->data) {
Expand Down

0 comments on commit 809ad6a

Please sign in to comment.