aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/scimpl_private.cpp
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:45 +0300
commit9123176b341b6f2658cff5132482b8237c1416c8 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/scheme/scimpl_private.cpp
parent59e19371de37995fcb36beb16cd6ec030af960bc (diff)
downloadydb-9123176b341b6f2658cff5132482b8237c1416c8.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/scheme/scimpl_private.cpp')
-rw-r--r--library/cpp/scheme/scimpl_private.cpp140
1 files changed, 70 insertions, 70 deletions
diff --git a/library/cpp/scheme/scimpl_private.cpp b/library/cpp/scheme/scimpl_private.cpp
index c2c1e6b6f3..024bf8cc3b 100644
--- a/library/cpp/scheme/scimpl_private.cpp
+++ b/library/cpp/scheme/scimpl_private.cpp
@@ -1,74 +1,74 @@
-#include "scimpl_private.h"
-
-#include <util/generic/algorithm.h>
+#include "scimpl_private.h"
+
+#include <util/generic/algorithm.h>
#include <utility>
-
-namespace NSc {
- namespace NImpl {
- struct TGetKey {
- static inline TStringBuf Do(const TDict::value_type& v) {
- return v.first;
- }
- };
-
- struct TMoveValue {
- static inline TValue&& Do(TDict::value_type& v) {
- return std::move(v.second);
- }
-
- static inline TValue&& Do(TArray::value_type& v) {
- return std::move(v);
- }
- };
-
- template <typename TAction, typename TElement, typename TColl>
+
+namespace NSc {
+ namespace NImpl {
+ struct TGetKey {
+ static inline TStringBuf Do(const TDict::value_type& v) {
+ return v.first;
+ }
+ };
+
+ struct TMoveValue {
+ static inline TValue&& Do(TDict::value_type& v) {
+ return std::move(v.second);
+ }
+
+ static inline TValue&& Do(TArray::value_type& v) {
+ return std::move(v);
+ }
+ };
+
+ template <typename TAction, typename TElement, typename TColl>
static inline void PutToVector(TVector<TElement>& vector, TColl& coll) {
- size_t i = vector.size();
- vector.resize(vector.size() + coll.size());
-
- for (auto& item : coll) {
- vector[i++] = TAction::Do(item);
- }
- }
-
- bool TKeySortContext::Process(const TDict& self) {
- size_t oldSz = Vector.size();
- PutToVector<TGetKey>(Vector, self);
- Sort(Vector.begin() + oldSz, Vector.end());
- return true;
- }
-
- bool TSelfOverrideContext::Process(TValue::TScCore& self) {
- if (self.GetDict().size()) {
- PutToVector<TMoveValue>(Vector, self.Dict);
- } else if (self.GetArray().size()) {
- PutToVector<TMoveValue>(Vector, self.Array);
- }
- return true;
- }
-
- bool TSelfLoopContext::Process(const TValue::TScCore& self) {
- const bool ok = (Vector.end() == Find(Vector.begin(), Vector.end(), &self));
-
- if (!ok) {
- switch (ReportingMode) {
- case EMode::Assert:
- Y_ASSERT(false); // make sure the debug build sees this
- break;
- case EMode::Throw:
- ythrow TSchemeException() << "REFERENCE LOOP DETECTED";
- case EMode::Abort:
- Y_FAIL("REFERENCE LOOP DETECTED");
- break;
- case EMode::Stderr:
+ size_t i = vector.size();
+ vector.resize(vector.size() + coll.size());
+
+ for (auto& item : coll) {
+ vector[i++] = TAction::Do(item);
+ }
+ }
+
+ bool TKeySortContext::Process(const TDict& self) {
+ size_t oldSz = Vector.size();
+ PutToVector<TGetKey>(Vector, self);
+ Sort(Vector.begin() + oldSz, Vector.end());
+ return true;
+ }
+
+ bool TSelfOverrideContext::Process(TValue::TScCore& self) {
+ if (self.GetDict().size()) {
+ PutToVector<TMoveValue>(Vector, self.Dict);
+ } else if (self.GetArray().size()) {
+ PutToVector<TMoveValue>(Vector, self.Array);
+ }
+ return true;
+ }
+
+ bool TSelfLoopContext::Process(const TValue::TScCore& self) {
+ const bool ok = (Vector.end() == Find(Vector.begin(), Vector.end(), &self));
+
+ if (!ok) {
+ switch (ReportingMode) {
+ case EMode::Assert:
+ Y_ASSERT(false); // make sure the debug build sees this
+ break;
+ case EMode::Throw:
+ ythrow TSchemeException() << "REFERENCE LOOP DETECTED";
+ case EMode::Abort:
+ Y_FAIL("REFERENCE LOOP DETECTED");
+ break;
+ case EMode::Stderr:
Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ")
<< " AND " << ToString((const void*)&self) << Endl;
- break;
- }
- }
-
- Vector.push_back(&self);
- return ok;
- }
- }
-}
+ break;
+ }
+ }
+
+ Vector.push_back(&self);
+ return ok;
+ }
+ }
+}