an-cabal/an-rope

Lazily evaluate Node metrics

Closed this issue · 1 comments

hawkw commented

See my comment in internals.rs:

  // TODO: we used to cache grapheme length on nodes, but I removed it for
  //       performance reasons.
  //
  //       this might seem counter-intuitive – we'd expect caching to make it
  //       faster – but since we mostly manipulate `Rope`s by `char` rather
  //       than by `Grapheme`, we often end up spending a lot of time
  //       calculating a grapheme length measurement we *never actually use*.
  //
  //       this way, the added overhead of calculating grapheme length only
  //       happens once it is actually needed.
  //
  //       the downside is that once grapheme length _is_ calculated once,
  //       we don't cache the result, and have to recalcualte grapheme length
  //       every time it's needed. might want to look into rigging up a lazy
  //       field  using `RefCell`s.
  //       see:  https://doc.rust-lang.org/std/cell/#implementation-details-of-logically-immutable-methods
  //        - eliza, 1/10/2017
hawkw commented

This can probably be taken care of at the same time as #57