Project

Profile

Help

Feature #4059

closed

Simple maps with string keys

Added by Michael Kay over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2018-12-02
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:
Platforms:

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

Also available in: Atom PDF