finger-tree
finger-tree copied to clipboard
Inline app3/_app3/nodes code.
With the current implementation we have assert(3 <= list.length && list.length <= 12) in src/0-core/concatenate/nodes.js.
Plan:
- [x] Write tests that cover all cases in
nodes(fromlist.length = 3tolist.length = 12) 38b9e052f5a0fe4e0fb1df9d3d0323aca64ba6a8 - [x] Write a benchmark that stresses the
concatmethod - [x] Profile current implementation
- If any of
nodes,_app3,app3shows up as a bottleneck, profile these implementations:- [ ] unroll loop iterations in
nodes(max iterations is fixed) - [x] switch on
list.lengthinnodes736260238f294e6f04b940ff20a5166abbce2edf - [x] handle all cases separately as Digit methods and remove
nodes: First implicit branch on the protototype ofB, then implicit branch on the prototype ofA(e.g.A._nodes_from_list_and_Two(list, B)whereB instanceof Two), and finally explicit branch onlist.lengthusing aswitch
- [ ] unroll loop iterations in
Also the current base cases in app3 use the generic _append and _prepend where list has a size between 1 and 4.
- [x] Explore unrolling these generic loops in those cases.
Plan moved up.
For ii: If implementing the default branch generically we could use nodes to create any Tree from scratch (see #108).
iii. is actually Exercise 3 (page 9) in Hinze and Paterson (see README for link).