I might have found yet another (better? At least on paper) memory layout for storing #ArkScript scopes and locals
Currently I create a vector<pair<id, value>> for each scope. Quite costly in terms of copies and all
What if I had a
array<pair<id, value>, N>
And my scopes were just views:
view(start, length, min id, max id)
Since only the last scope can grow… it could work. Min and max id are there for a basic bloom filter. I just have to solve the problem for closures that have their own scope that must be kept alive, but by pushing references (value holding a ptr to value) this could be solved easily
Also because of closures, scopes are shared ptr to Scope (the class holding the vec of pair) currently. Quite costly to construct…
I will go back to my old scopes/locals management code and I think I will write an article about how it evolved, and the various performance boosts it yielded
#pldev #proglang