diff options
author | dgolear <dgolear@yandex-team.com> | 2024-08-15 00:02:42 +0300 |
---|---|---|
committer | dgolear <dgolear@yandex-team.com> | 2024-08-15 00:16:21 +0300 |
commit | fc4a0dd6c5b8c0c8bb25546e9bf08394b8752ee8 (patch) | |
tree | 39123545d9b3cc36f7e12feb1170f1f23c33ff1d | |
parent | 1ab0dd269e79cf843ea577eebcdec512376f5a7c (diff) | |
download | ydb-fc4a0dd6c5b8c0c8bb25546e9bf08394b8752ee8.tar.gz |
YT: Add reserve to container deserialization
16d29b1b377145b9464d5280244b000f207c4563
-rw-r--r-- | yt/yt/core/ytree/serialize-inl.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/yt/yt/core/ytree/serialize-inl.h b/yt/yt/core/ytree/serialize-inl.h index 6d846e42dd..82dcdac2b0 100644 --- a/yt/yt/core/ytree/serialize-inl.h +++ b/yt/yt/core/ytree/serialize-inl.h @@ -154,6 +154,9 @@ void DeserializeSet(T& value, INodePtr node) auto listNode = node->AsList(); auto size = listNode->GetChildCount(); value.clear(); + if constexpr (requires {value.reserve(size);}) { + value.reserve(size); + } for (int i = 0; i < size; ++i) { typename T::value_type item; Deserialize(item, listNode->GetChildOrThrow(i)); @@ -166,6 +169,9 @@ void DeserializeMap(T& value, INodePtr node) { auto mapNode = node->AsMap(); value.clear(); + if constexpr (requires {value.reserve(mapNode->GetChildCount());}) { + value.reserve(mapNode->GetChildCount()); + } for (const auto& [serializedKey, serializedItem] : mapNode->GetChildren()) { typename T::key_type key; TMapKeyHelper<typename T::key_type>::Deserialize(key, serializedKey); |