From 97f19b3f38de3c06fb4456069ed09eab368da90e Mon Sep 17 00:00:00 2001 From: bloeys Date: Fri, 10 Jun 2022 11:22:48 +0400 Subject: [PATCH] Revert cuz golang :) messes up rand add full size --- nset.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/nset.go b/nset.go index f1f935c..7589d97 100644 --- a/nset.go +++ b/nset.go @@ -38,13 +38,9 @@ type NSet[T IntsIf] struct { func (n *NSet[T]) Add(x T) { - //NOTE: The inlines here improve addition times by a good amount (several seconds) - //NOTE: inline of n.GetBucketFromValue(x) - bucket := &n.Buckets[BucketType(x>>n.shiftAmount)] - - //NOTE: This is an inline of n.GetStorageUnitIndex(x) - unitIndex := uint32(((x << BucketIndexingBits) >> BucketIndexingBits) / StorageTypeBits) + bucket := n.GetBucketFromValue(x) + unitIndex := n.GetStorageUnitIndex(x) if unitIndex >= bucket.StorageUnitCount { storageUnitsToAdd := unitIndex - bucket.StorageUnitCount + 1 @@ -54,8 +50,7 @@ func (n *NSet[T]) Add(x T) { bucket.StorageUnitCount += storageUnitsToAdd } - //NOTE: Inline of n.GetBitMask(x) - bucket.Data[unitIndex] |= 1 << (((x << BucketIndexingBits) >> BucketIndexingBits) % StorageTypeBits) + bucket.Data[unitIndex] |= n.GetBitMask(x) } func (n *NSet[T]) Remove(x T) {