finger-tree icon indicating copy to clipboard operation
finger-tree copied to clipboard

Inline app3/_app3/nodes code.

Open make-github-pseudonymous-again opened this issue 5 years ago • 3 comments

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 (from list.length = 3 to list.length = 12) 38b9e052f5a0fe4e0fb1df9d3d0323aca64ba6a8
  • [x] Write a benchmark that stresses the concat method
  • [x] Profile current implementation
  • If any of nodes, _app3, app3 shows up as a bottleneck, profile these implementations:
    1. [ ] unroll loop iterations in nodes (max iterations is fixed)
    2. [x] switch on list.length in nodes 736260238f294e6f04b940ff20a5166abbce2edf
    3. [x] handle all cases separately as Digit methods and remove nodes: First implicit branch on the protototype of B, then implicit branch on the prototype of A (e.g. A._nodes_from_list_and_Two(list, B) where B instanceof Two), and finally explicit branch on list.length using a switch

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).