* fixes #21393 and misc style changes * progress --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
This commit is contained in:
parent
7dc80a7fef
commit
8a19ac2070
11 changed files with 70 additions and 61 deletions
|
|
@ -247,7 +247,7 @@ proc hash*[T](x: ptr[T]): Hash {.inline.} =
|
|||
when defined(nimPreviewHashRef) or defined(nimdoc):
|
||||
proc hash*[T](x: ref[T]): Hash {.inline.} =
|
||||
## Efficient `hash` overload.
|
||||
##
|
||||
##
|
||||
## .. important:: Use `-d:nimPreviewHashRef` to
|
||||
## enable hashing `ref`s. It is expected that this behavior
|
||||
## becomes the new default in upcoming versions.
|
||||
|
|
@ -536,6 +536,7 @@ proc hash*[T: tuple | object | proc](x: T): Hash =
|
|||
elif T is (proc):
|
||||
result = hash(pointer(x))
|
||||
else:
|
||||
result = 0
|
||||
for f in fields(x):
|
||||
result = result !& hash(f)
|
||||
result = !$result
|
||||
|
|
@ -551,6 +552,7 @@ proc hash*[A](x: openArray[A]): Hash =
|
|||
else:
|
||||
result = murmurHash(toOpenArrayByte(x, 0, x.high))
|
||||
else:
|
||||
result = 0
|
||||
for a in x:
|
||||
result = result !& hash(a)
|
||||
result = !$result
|
||||
|
|
@ -583,6 +585,7 @@ proc hash*[A](aBuf: openArray[A], sPos, ePos: int): Hash =
|
|||
proc hash*[A](x: set[A]): Hash =
|
||||
## Efficient hashing of sets.
|
||||
## There must be a `hash` proc defined for the element type `A`.
|
||||
result = 0
|
||||
for it in items(x):
|
||||
result = result !& hash(it)
|
||||
result = !$result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue