diff options
author | sobols <sobols@yandex-team.com> | 2022-10-12 19:31:35 +0300 |
---|---|---|
committer | sobols <sobols@yandex-team.com> | 2022-10-12 19:31:35 +0300 |
commit | 918fcce7e3028401867b3276871686c4add87705 (patch) | |
tree | eac49fbdbaebb83d97e0beb84ddc098396cd6a69 /library/cpp/scheme/scheme.h | |
parent | ee2715d277e3d307e86d4987a14abfb9986fab55 (diff) | |
download | ydb-918fcce7e3028401867b3276871686c4add87705.tar.gz |
[scheme] Allow to create a new null value which shares a pool with the current value without directly attaching it as child
Diffstat (limited to 'library/cpp/scheme/scheme.h')
-rw-r--r-- | library/cpp/scheme/scheme.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index b4cb98c9677..78336d16c8a 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -50,6 +50,11 @@ namespace NSc { // A COW copy will see changes in its parent, but no change in the COW copy will propagate to its parent. public: + // XXX: A newly constructed standalone TValue instance (even null!) consumes ~4 KB of memory because it allocates a memory pool inside. + // Consider building a tree of TValues in top-down order (from root to leaves) to share a single pool + // instead of creating child TValues first and appending them to a parent TValue. + // All somehow cached values should be constant, otherwise the shared pool can grow infinitely. + inline TValue(); inline TValue(TValue& v); inline TValue(const TValue& v); @@ -386,6 +391,8 @@ namespace NSc { TValue Clone() const; // returns deep copy of self (on the separate pool) TValue& CopyFrom(const TValue& other); // deep copy other value into self, returns self + TValue CreateNew() const; // returns a new null value which shares a memory pool with self + TValue& Swap(TValue& v); static bool Same(const TValue&, const TValue&); // point to the same core |