Feature #4059
closedSimple maps with string keys
100%
Description
Studying the performance of the XSLT-in-XSLT compiler (nearly complete but not yet released) I think there is an opportunity for an improved map implementation that will deliver better performance in many cases. In particular (a) where the keys are all strings, (b) where the map is constructed "in one go", and (c) where calls to put() and remove() are unlikely to happen.
In this case we could implement the map as a simple Java HashMap<String, GroundedValue>
(and on Javascript, simply as an object). In the event that put() or remove() is called, the structure could be bulk-copied to the existing HashTrieMap implementation.
We could use this structure:
(a) if requested by a call on a new extension function, say saxon:dictionary(keys, values)
(b) for a map{} literal if the keys are all strings
(c) for a constant map loaded from a SEF file (this case is common in the XSLT-in-XSLT compiler.
(d) for maps constructed using parse-json().
With a bit of work in the optimizer we might also detect some cases where the map is constructed using xsl:map or map:merge(), provided static analysis of the operand is possible.
On the Javascript side there are probably even greater savings by using a Javascript "object" directly, rather than our HashTrieMap implementation.
Please register to edit this issue