blob: 5f7c3e37b849d9c7683b88f2fc9e9d7ad1d106a7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#
#
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# set handling
proc cardSetImpl(s: ptr UncheckedArray[uint8], len: int): int {.inline.} =
var i = 0
result = 0
when defined(x86) or defined(amd64):
while i < len - 8:
inc(result, countBits64((cast[ptr uint64](s[i].unsafeAddr))[]))
inc(i, 8)
while i < len:
inc(result, countBits32(uint32(s[i])))
inc(i, 1)
proc cardSet(s: ptr UncheckedArray[uint8], len: int): int {.compilerproc, inline.} =
result = cardSetImpl(s, len)
|