Next Up Previous Contents
Next: list-true
Up: Common functions for the Starlink stylesheets
Previous: get-mediatypes
[ID index][Keyword index]

hash-of-tree - Return some hash of a tree

Description

Return some hash of a tree. This is used, for example, when we are generating filenames or equation labels within programcode documents: we can't look `up' into the parent document, so we have to use this function to generate something unique to the document. Returns a string which should be reasonably unique to a node sub-tree. Works by going down a number of levels in the node tree, counting the number of children at each level, and munging them with an RNG.

Note that the (select-by-class) of the children of the node is ***extremely*** important: missing this out results in a substantial slowdown in this function, resulting in a massive (factor of 10?!) slowdown of the down-converter as a whole. The (select-by-class) disables a Jade optimisation which treats the characters in a string as just that, rather than the formally correct node-list. I can't really detect this slowdown in the conversion of a trial document, but perhaps it disables the optimisation on a wider scale, or frustrates caching, or something similar. The depth of the hash doesn't *seem* to make much difference, but I've kept it smallish just in case.

Argument list
nd = singleton-node-list (Given)

The node to be hashed

depth = number (Given)

The number of levels to go down. This should not be supplied by external uses of this function.

Return value

Type: string

A string which should be characteristic of the node subtree. Starts with a letter.


Next Up Previous Contents
Next: list-true
Up: Common functions for the Starlink stylesheets
Previous: get-mediatypes
[ID index][Keyword index]