mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 15:57:49 +00:00
Native code now holds the Rust memory it works in against the heap limit until it is done with it: a matcher's capture state and stack, a pattern being compiled, the matches and pieces of a replacement, and the text Date.parse reads. A collection counts these bytes as live while they are held. - replace reads its replacement pattern once into parts that refer to ranges of the pattern, so literal text is not copied for each match. Each piece takes fuel for its units, and the result's length is checked against the heap as each piece is added. - The regular expression compiler charges heap through its callback as it builds, including the ranges of a character class, and each class atom and range takes fuel. A compiled form counts the capacity of its lists. - Clearing the groups inside a quantifier and clearing the matcher's state before each attempt take fuel. - Flattening a rope in a String, RegExp or Date method reserves the flat copy on the heap and takes fuel for it. - A RegExp object's bytes are reserved together with its compiled form, so a collection between the two does not drop the compiled form from the heap count.