ged-odoo / blockdom

A fast virtual dom library
MIT License
556 stars 25 forks source link

imp: only keep minimal number of references in memory #2

Closed ged-odoo closed 3 years ago

ged-odoo commented 3 years ago

Now, blockdom keep an array of refs with all the nodes necessary to reach the target refs. But it can be reduced to a smaller number of refs.

  1. The "easy but not optimal" way is to compact chains of single nodes in one. So, if I have <p><p><p><block-text-0/></p></p></p>, we can reuse the previous index to store the next reference when computing them, and end up with an array of either 1 or 2 (depending if we keep el in it) references.
  2. The "optimal" way is to compact all chains of consecutive nodes that are only used by one path into one. This is the same as above, except that it works in a more generic way.
ged-odoo commented 3 years ago

it was done by commit https://github.com/ged-odoo/blockdom/commit/b2c29a71089c5434097bb3c228c91768fcebe82c (optimal way)