Skip to content

Commit

Permalink
LeafAST - Refactoring of LeafKit Processing Chain (#46)
Browse files Browse the repository at this point in the history
### API & Performance Changes ###
* Replaces `Unresolved/ResolvedDocument` with `LeafAST`, a document structure capable of representing both unknown state and resolved state AST with public observers on its state.
* Adjusts `LeafRenderer` and `LeafCache` to use LeafAST
  * **Note**: `LeafCache` protocol retains `ResolvedDocument` as an alias to `LeafAST` to prevent breaking changes in this release
* Adds `.insert` method to `LeafCache` protocol with a `replace` parameter to clarify whether inserting an AST is allowed to replace the current cached AST if such a key already exists
* Adds `.remove` method to `LeafCache` protocol to allow removing individual ASTs from the cache
* Improves routine case rendering speed on flat ASTs
* Collapses sequential `.raw` `Syntax`es during AST resolution for faster serialization
* Initial introduction of `LeafError` type for enhanced error handling
  * **Note**:  - not stable, to be changed from `Enum` to `Struct` in next PR for codifying the type and allowing source document referencing
* 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.leaf` extends `b.leaf` and `b.leaf` extends `a.leaf`)
* Re-introduces `index`, `isFirst`, `isLast` variables inside `loop` bodies from Leaf 3
  * **Note**:  - collision is possible between variable names if a key in the `LeafData` provided to a template shares the same name as the variables

### Testing Changes ###
* Add test cases for measuring speed of linear & randomly accessed templates
* Add tests cases for cyclical error handling and missing templates
* Make `TestFiles` threadsafe
* Deactivate `testTagIndicator` for causing data race when actual MultiThreaded Event Loops are running in tests
  • Loading branch information
tdotclare authored Apr 24, 2020
1 parent fbe2cbe commit de65606
Show file tree
Hide file tree
Showing 5 changed files with 534 additions and 478 deletions.
292 changes: 0 additions & 292 deletions Sources/LeafKit/DocumentLoader.swift

This file was deleted.

Loading

0 comments on commit de65606

Please sign in to comment.