03:09
<Justin Ridgewell>
anyway probably just a JS Map is good enough in practice; I just wouldn't want to rule out using this theoretically more efficient mechanism in case things come up. But I think this would be possible and doesn't relate to the use of Realms.

After looking at this a bunch, I believe the current Map based approach is ideal:

  • O(1) wrap()
  • O(1) get()
  • O(n) run()
  • Automatic GC
03:10
<Justin Ridgewell>
I can't come up with another solution that don't have O(n) run without sacrificing wrap or get
03:11
<Justin Ridgewell>
I did come up with a slightly optimized solution which has O(1) run if the current state has not been wrapped.
03:58
<Justin Ridgewell>
https://github.com/legendecas/proposal-async-context/pull/15