replace most Pos objects/ptrs with indexes into a position table
Pos objects are somewhat wasteful as they duplicate the origin file name and input type for each object. on files that produce more than one Pos when parsed this a sizeable waste of memory (one pointer per Pos). the same goes for ptr<Pos> on 64 bit machines: parsing enough source to require 8 bytes to locate a position would need at least 8GB of input and 64GB of expression memory. it's not likely that we'll hit that any time soon, so we can use a uint32_t index to locate positions instead.
This commit is contained in:
@@ -80,7 +80,7 @@ Env & EvalState::allocEnv(size_t size)
|
||||
|
||||
|
||||
[[gnu::always_inline]]
|
||||
void EvalState::forceValue(Value & v, const Pos & pos)
|
||||
void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||
{
|
||||
forceValue(v, [&]() { return pos; });
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void EvalState::forceValue(Value & v, Callable getPos)
|
||||
|
||||
|
||||
[[gnu::always_inline]]
|
||||
inline void EvalState::forceAttrs(Value & v, const Pos & pos)
|
||||
inline void EvalState::forceAttrs(Value & v, const PosIdx pos)
|
||||
{
|
||||
forceAttrs(v, [&]() { return pos; });
|
||||
}
|
||||
@@ -126,7 +126,7 @@ inline void EvalState::forceAttrs(Value & v, Callable getPos)
|
||||
|
||||
|
||||
[[gnu::always_inline]]
|
||||
inline void EvalState::forceList(Value & v, const Pos & pos)
|
||||
inline void EvalState::forceList(Value & v, const PosIdx pos)
|
||||
{
|
||||
forceValue(v, pos);
|
||||
if (!v.isList())
|
||||
|
||||
Reference in New Issue
Block a user