summary refs log tree commit diff stats
path: root/compiler/bitsets.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/bitsets.nim')
-rw-r--r--compiler/bitsets.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/bitsets.nim b/compiler/bitsets.nim
index 67598f9ca..7d142b01d 100644
--- a/compiler/bitsets.nim
+++ b/compiler/bitsets.nim
@@ -87,5 +87,11 @@ const populationCount: array[uint8, uint8] = block:
     arr
 
 proc bitSetCard*(x: TBitSet): BiggestInt =
+  result = 0
   for it in x:
     result.inc int(populationCount[it])
+
+proc bitSetToWord*(s: TBitSet; size: int): BiggestUInt =
+  result = 0
+  for j in 0..<size:
+    if j < s.len: result = result or (BiggestUInt(s[j]) shl (j * 8))