LeafAST - Substantial Refactoring of LeafKit processing chain
Pre-release
Pre-release
API & Performance Changes
- Replaces
Unresolved/ResolvedDocumentwithLeafAST, a document structure capable of representing both unknown state and resolved state AST with public observers on its state. - Adjusts
LeafRendererandLeafCacheto use LeafAST- Note:
LeafCacheprotocol retainsResolvedDocumentas an alias toLeafASTto prevent breaking changes in this release
- Note:
- Adds
.insertmethod toLeafCacheprotocol with areplaceparameter to clarify whether inserting an AST is allowed to replace the current cached AST if such a key already exists - Adds
.removemethod toLeafCacheprotocol to allow removing individual ASTs from the cache - Improves routine case rendering speed on flat ASTs
- Collapses sequential
.rawSyntaxes during AST resolution for faster serialization - Initial introduction of
LeafErrortype for enhanced error handling- Note: - not stable, to be changed from
EnumtoStructin next PR for codifying the type and allowing source document referencing
- Note: - not stable, to be changed from
- Changes DefaultLeafCache behavior to return provided AST or nil if caching is off
Bug Fixes
- Prevents crash on malformed external Leaf documents that cause cyclical loops (eg,
a.leafextendsb.leafandb.leafextendsa.leaf) - Re-introduces
index,isFirst,isLastvariables insideloopbodies from Leaf 3- Note: - collision is possible between variable names if a key in the
LeafDataprovided to a template shares the same name as the variables
- Note: - collision is possible between variable names if a key in the
Testing Changes
- Add test cases for measuring speed of linear & randomly accessed templates
- Add tests cases for cyclical error handling and missing templates
- Make
TestFilesthreadsafe - Deactivate
testTagIndicatorfor causing data race when actual MultiThreaded Event Loops are running in tests