Class TruffleString.MaterializeSubstringNode

java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.strings.TruffleString.MaterializeSubstringNode
All Implemented Interfaces:
NodeInterface, Cloneable
Enclosing class:
TruffleString

public abstract static class TruffleString.MaterializeSubstringNode extends Node
Extended version of TruffleString.MaterializeNode that also materializes substrings/string views created via e.g. TruffleString.SubstringNode with the lazy parameter set to true or via TruffleString.FromByteArrayNode with the copy parameter set to false. Note that this node returns a potentially new TruffleString, because these substrings cannot be materialized internally. Native-backed strings are kept as-is, since this node cannot decide whether a native-backed string is a substring/string view.

Lazy substrings keep a reference to the potentially larger byte array they were created from, which may keep more memory alive than necessary (see the caveats mentioned at TruffleString.SubstringNode.execute(AbstractTruffleString, int, int, TruffleString.Encoding, boolean)). With this node, unnecessarily held memory is reclaimed by copying the referenced subregions. This is especially useful if a string is added to a data structure known to be long-lived, e.g. during string interning.

Since:
25.1
See Also: