Computes TIndexEntry hash without temporary strings.
This commit is contained in:
parent
f948f52226
commit
489d7e526d
1 changed files with 6 additions and 5 deletions
|
|
@ -364,15 +364,16 @@ proc cmp(a, b: TIndexEntry): int =
|
||||||
if result == 0:
|
if result == 0:
|
||||||
result = cmpIgnoreStyle(a.link, b.link)
|
result = cmpIgnoreStyle(a.link, b.link)
|
||||||
|
|
||||||
proc hash(x: TIndexEntry): int =
|
proc hash(x: TIndexEntry): THash =
|
||||||
## Returns the hash for the combined fields of the type.
|
## Returns the hash for the combined fields of the type.
|
||||||
##
|
##
|
||||||
## The hash is computed as the concatenated string of all available fields.
|
## The hash is computed as the chained hash of the individual string hashes.
|
||||||
assert(not x.keyword.isNil)
|
assert(not x.keyword.isNil)
|
||||||
assert(not x.link.isNil)
|
assert(not x.link.isNil)
|
||||||
let value = x.keyword & x.link & (x.linkTitle or "") & (x.linkDesc or "")
|
result = x.keyword.hash !& x.link.hash
|
||||||
result = value.hash
|
result = result !& (x.linkTitle or "").hash
|
||||||
|
result = result !& (x.linkDesc or "").hash
|
||||||
|
result = !$result
|
||||||
|
|
||||||
proc `<-`(a: var TIndexEntry, b: TIndexEntry) =
|
proc `<-`(a: var TIndexEntry, b: TIndexEntry) =
|
||||||
shallowCopy a.keyword, b.keyword
|
shallowCopy a.keyword, b.keyword
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue