diff options
author | fippo <fippo@yandex-team.ru> | 2022-02-10 16:50:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:08 +0300 |
commit | 7bf72dabd2102d9781c1ec7a754579757baa7b90 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 3e57c324d47a3a202cb3c5a9648d2f92103d5213 (diff) | |
download | ydb-7bf72dabd2102d9781c1ec7a754579757baa7b90.tar.gz |
Restoring authorship annotation for <fippo@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/coroutine/engine/events.h | 8 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 8 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 4 | ||||
-rw-r--r-- | library/cpp/xml/document/node-attr.h | 30 | ||||
-rw-r--r-- | library/cpp/xml/document/xml-document-decl.h | 108 | ||||
-rw-r--r-- | library/cpp/xml/document/xml-document.cpp | 42 | ||||
-rw-r--r-- | library/cpp/xml/document/xml-document_ut.cpp | 36 | ||||
-rw-r--r-- | util/generic/queue.h | 30 | ||||
-rw-r--r-- | util/generic/utility.h | 12 | ||||
-rw-r--r-- | util/generic/utility_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/vector.h | 6 | ||||
-rw-r--r-- | util/string/split.h | 26 | ||||
-rw-r--r-- | util/string/split_ut.cpp | 12 | ||||
-rw-r--r-- | util/system/guard.h | 2 | ||||
-rw-r--r-- | util/thread/factory.cpp | 14 | ||||
-rw-r--r-- | util/thread/factory.h | 2 | ||||
-rw-r--r-- | util/thread/pool.cpp | 6 | ||||
-rw-r--r-- | util/ysaveload.h | 32 |
18 files changed, 190 insertions, 190 deletions
diff --git a/library/cpp/coroutine/engine/events.h b/library/cpp/coroutine/engine/events.h index b6d767c746..07cc4d25e8 100644 --- a/library/cpp/coroutine/engine/events.h +++ b/library/cpp/coroutine/engine/events.h @@ -102,10 +102,10 @@ public: void BroadCast(size_t number) noexcept { for (size_t i = 0; i < number && !Waiters_.Empty(); ++i) { - Waiters_.PopFront()->Wake(); - } - } - + Waiters_.PopFront()->Wake(); + } + } + private: TIntrusiveList<TWaiter> Waiters_; }; diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index b1e42295ac..24a5b69eef 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -222,14 +222,14 @@ TString MD5::Calc(const TArrayRef<const ui8>& data) { TString MD5::CalcRaw(TStringBuf data) { return CalcRaw(MakeUnsignedArrayRef(data)); -} - +} + TString MD5::CalcRaw(const TArrayRef<const ui8>& data) { TString result; result.ReserveAndResize(16); MD5().Update(data).Final(reinterpret_cast<ui8*>(result.begin())); - return result; -} + return result; +} ui64 MD5::CalcHalfMix(const char* data, size_t len) { return CalcHalfMix(MakeUnsignedArrayRef(data, len)); diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 216cf49c3f..2c17aa0518 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/array_ref.h> -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> class IInputStream; @@ -58,7 +58,7 @@ public: static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded static TString CalcRaw(TStringBuf data); // 16-byte raw static TString CalcRaw(const TArrayRef<const ui8>& data); // 16-byte raw - + static ui64 CalcHalfMix(TStringBuf data); static ui64 CalcHalfMix(const TArrayRef<const ui8>& data); static ui64 CalcHalfMix(const char* data, size_t len); diff --git a/library/cpp/xml/document/node-attr.h b/library/cpp/xml/document/node-attr.h index baf2812d95..6e74403943 100644 --- a/library/cpp/xml/document/node-attr.h +++ b/library/cpp/xml/document/node-attr.h @@ -182,28 +182,28 @@ namespace NXml { return TNode(DocPointer, child); } - template <class T> + template <class T> typename std::enable_if<!std::is_convertible_v<T, TStringBuf>, TNode>::type TNode::AddText(const T& value) { - TStringStream ss; - ss << value; - return AddText(ss.Str()); - } - + TStringStream ss; + ss << value; + return AddText(ss.Str()); + } + inline TNode TNode::AddText(TStringBuf value) { if (IsNull()) { THROW(XmlException, "addChild [value=" << value << "]: can't add child to null node"); - } - - xmlNode* child = xmlNewTextLen((xmlChar*)value.data(), value.size()); - child = xmlAddChild(NodePointer, child); - + } + + xmlNode* child = xmlNewTextLen((xmlChar*)value.data(), value.size()); + child = xmlAddChild(NodePointer, child); + if (!child) { THROW(XmlException, "addChild [value=" << value << "]: xmlNewTextChild returned NULL"); - } - - return TNode(DocPointer, child); - } + } + + return TNode(DocPointer, child); + } } diff --git a/library/cpp/xml/document/xml-document-decl.h b/library/cpp/xml/document/xml-document-decl.h index af8c31a37b..bfda1fb7e6 100644 --- a/library/cpp/xml/document/xml-document-decl.h +++ b/library/cpp/xml/document/xml-document-decl.h @@ -263,13 +263,13 @@ namespace NXml { TConstNode FirstChild() const; /** - * get parent node - * throws exception if has no parent - */ - TNode Parent(); - TConstNode Parent() const; - - /** + * get parent node + * throws exception if has no parent + */ + TNode Parent(); + TConstNode Parent() const; + + /** * get node neighbour * @param name: neighbour name * @note if name is empty, returns the next sibling node of type "element" @@ -307,17 +307,17 @@ namespace NXml { TNode AddChild(const TConstNode& node); /** - * create text child node - * @param name: child name - * @param value: node value - */ - template <class T> + * create text child node + * @param name: child name + * @param value: node value + */ + template <class T> typename std::enable_if<!std::is_convertible_v<T, TStringBuf>, TNode>::type AddText(const T& value); - + TNode AddText(TStringBuf value); - /** + /** * get node attribute * @param name: attribute name * throws exception if attribute not found @@ -398,17 +398,17 @@ namespace NXml { void DelAttr(TZtStringBuf name); /** - * set node application data - * @param priv: new application data pointer - */ - void SetPrivate(void* priv); - - /** - * @return application data pointer, passed by SetPrivate - */ - void* GetPrivate() const; - - /** + * set node application data + * @param priv: new application data pointer + */ + void SetPrivate(void* priv); + + /** + * @return application data pointer, passed by SetPrivate + */ + void* GetPrivate() const; + + /** * get node name */ TString Name() const; @@ -418,7 +418,7 @@ namespace NXml { */ TString Path() const; - /** + /** * get node xml representation */ TString ToString(TZtStringBuf enc = "") const { @@ -430,16 +430,16 @@ namespace NXml { void SaveAsHtml(IOutputStream& stream, TZtStringBuf enc = "", bool shouldFormat = false) const; /** - * get pointer to internal node - */ - xmlNode* GetPtr(); - const xmlNode* GetPtr() const; - - /** - * check if node is text-only node - */ - bool IsText() const; - + * get pointer to internal node + */ + xmlNode* GetPtr(); + const xmlNode* GetPtr() const; + + /** + * check if node is text-only node + */ + bool IsText() const; + /** * unlink node from parent and free */ @@ -667,27 +667,27 @@ namespace NXml { } /** - * @return application data pointer, passed by SetPrivate - */ + * @return application data pointer, passed by SetPrivate + */ void* GetPrivate() const { - return ActualNode.GetPrivate(); - } - - /** - * get pointer to internal node - */ + return ActualNode.GetPrivate(); + } + + /** + * get pointer to internal node + */ const xmlNode* GetPtr() const { - return ActualNode.GetPtr(); - } - - /** - * check if node is text-only node - */ + return ActualNode.GetPtr(); + } + + /** + * check if node is text-only node + */ bool IsText() const { - return ActualNode.IsText(); - } - - /** + return ActualNode.IsText(); + } + + /** * get node xpath */ TString Path() const { diff --git a/library/cpp/xml/document/xml-document.cpp b/library/cpp/xml/document/xml-document.cpp index 93beed3199..18a554d732 100644 --- a/library/cpp/xml/document/xml-document.cpp +++ b/library/cpp/xml/document/xml-document.cpp @@ -209,15 +209,15 @@ namespace NXml { TNode TNode::Parent() { if (nullptr == NodePointer->parent) - THROW(XmlException, "Parent node not exists"); + THROW(XmlException, "Parent node not exists"); + + return TNode(DocPointer, NodePointer->parent); + } - return TNode(DocPointer, NodePointer->parent); - } - TConstNode TNode::Parent() const { - return const_cast<TNode*>(this)->Parent(); - } - + return const_cast<TNode*>(this)->Parent(); + } + TNode TNode::NextSibling(TZtStringBuf name) { if (IsNull()) THROW(XmlException, "Node is null"); @@ -255,13 +255,13 @@ namespace NXml { } void TNode::SetPrivate(void* priv) { - NodePointer->_private = priv; - } + NodePointer->_private = priv; + } void* TNode::GetPrivate() const { - return NodePointer->_private; - } - + return NodePointer->_private; + } + TNode TNode::Find(xmlNode* start, TZtStringBuf name) { for (; start; start = start->next) if (start->type == XML_ELEMENT_NODE && (name.empty() || !xmlStrcmp(start->name, XMLCHAR(name.c_str())))) @@ -286,20 +286,20 @@ namespace NXml { } xmlNode* TNode::GetPtr() { - return NodePointer; - } - + return NodePointer; + } + const xmlNode* TNode::GetPtr() const { - return NodePointer; - } - + return NodePointer; + } + bool TNode::IsText() const { if (IsNull()) THROW(XmlException, "Node is null"); - return NodePointer->type == XML_TEXT_NODE; - } - + return NodePointer->type == XML_TEXT_NODE; + } + void TNode::Remove() { xmlNode* nodePtr = GetPtr(); xmlUnlinkNode(nodePtr); diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp index 11f548b814..9f537b75c4 100644 --- a/library/cpp/xml/document/xml-document_ut.cpp +++ b/library/cpp/xml/document/xml-document_ut.cpp @@ -92,28 +92,28 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст"); } Y_UNIT_TEST(XmlNodes) { - using namespace NXml; - TDocument xml("<?xml version=\"1.0\"?>\n" - "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", - NXml::TDocument::String); - TNode root = xml.Root(); + using namespace NXml; + TDocument xml("<?xml version=\"1.0\"?>\n" + "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", + NXml::TDocument::String); + TNode root = xml.Root(); UNIT_ASSERT_EQUAL(root.Value<TString>(), "qqasdfgww"); - TConstNode node = root.FirstChild(); - UNIT_ASSERT_EQUAL(node.IsText(), true); + TConstNode node = root.FirstChild(); + UNIT_ASSERT_EQUAL(node.IsText(), true); UNIT_ASSERT_EQUAL(node.Value<TString>(), "qq"); - node = node.NextSibling(); - UNIT_ASSERT_EQUAL(node.IsText(), false); - UNIT_ASSERT_EQUAL(node.Name(), "a"); + node = node.NextSibling(); + UNIT_ASSERT_EQUAL(node.IsText(), false); + UNIT_ASSERT_EQUAL(node.Name(), "a"); UNIT_ASSERT_EQUAL(node.Value<TString>(), "asdfg"); - node = node.NextSibling(); - UNIT_ASSERT_EQUAL(node.IsText(), true); + node = node.NextSibling(); + UNIT_ASSERT_EQUAL(node.IsText(), true); UNIT_ASSERT_EQUAL(node.Value<TString>(), "ww"); - node = node.NextSibling(); - UNIT_ASSERT_EQUAL(node.IsText(), false); - UNIT_ASSERT_EQUAL(node.Name(), "c"); + node = node.NextSibling(); + UNIT_ASSERT_EQUAL(node.IsText(), false); + UNIT_ASSERT_EQUAL(node.Name(), "c"); UNIT_ASSERT_EQUAL(node.Value<TString>(), ""); - node = node.NextSibling(); - UNIT_ASSERT_EQUAL(node.IsNull(), true); + node = node.NextSibling(); + UNIT_ASSERT_EQUAL(node.IsNull(), true); TStringStream iterLog; for (const auto& node2 : root.Nodes("/root/*")) { iterLog << node2.Name() << ';'; @@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EXCEPTION(node.Name(), yexception); UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception); UNIT_ASSERT_EXCEPTION(node.IsText(), yexception); - } + } Y_UNIT_TEST(DefVal) { using namespace NXml; TDocument xml("<?xml version=\"1.0\"?>\n" diff --git a/util/generic/queue.h b/util/generic/queue.h index 64d05a9efe..f5959f68f2 100644 --- a/util/generic/queue.h +++ b/util/generic/queue.h @@ -23,14 +23,14 @@ public: inline void clear() { this->c.clear(); } - - inline S& Container() { - return this->c; - } - - inline const S& Container() const { - return this->c; - } + + inline S& Container() { + return this->c; + } + + inline const S& Container() const { + return this->c; + } }; template <class T, class S, class C> @@ -48,11 +48,11 @@ public: this->c.clear(); } - inline S& Container() { - return this->c; - } - - inline const S& Container() const { - return this->c; - } + inline S& Container() { + return this->c; + } + + inline const S& Container() const { + return this->c; + } }; diff --git a/util/generic/utility.h b/util/generic/utility.h index e91a799cf1..43b98eeafc 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -11,9 +11,9 @@ static constexpr const T& Min(const T& l, const T& r) { template <typename T, typename... Args> static constexpr const T& Min(const T& a, const T& b, const Args&... args) { - return Min(a, Min(b, args...)); -} - + return Min(a, Min(b, args...)); +} + template <class T> static constexpr const T& Max(const T& l, const T& r) { return l < r ? r : l; @@ -21,9 +21,9 @@ static constexpr const T& Max(const T& l, const T& r) { template <typename T, typename... Args> static constexpr const T& Max(const T& a, const T& b, const Args&... args) { - return Max(a, Max(b, args...)); -} - + return Max(a, Max(b, args...)); +} + // replace with http://en.cppreference.com/w/cpp/algorithm/clamp in c++17 template <class T> constexpr const T& ClampVal(const T& val, const T& min, const T& max) { diff --git a/util/generic/utility_ut.cpp b/util/generic/utility_ut.cpp index c232d93822..8e9d5afff9 100644 --- a/util/generic/utility_ut.cpp +++ b/util/generic/utility_ut.cpp @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TUtilityTest) { TTest j(1); DoSwap(i, j); - + UNIT_ASSERT_EQUAL(i.Val, 1); UNIT_ASSERT_EQUAL(j.Val, 0); } diff --git a/util/generic/vector.h b/util/generic/vector.h index 9af65ce700..a5b258955a 100644 --- a/util/generic/vector.h +++ b/util/generic/vector.h @@ -125,8 +125,8 @@ public: #endif inline void crop(size_type size) { - if (this->size() > size) { + if (this->size() > size) { this->erase(this->begin() + size, this->end()); - } - } + } + } }; diff --git a/util/string/split.h b/util/string/split.h index 3d7c6d1a95..bc46d9e64c 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -423,14 +423,14 @@ inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, SplitString(s.data(), s.data() + s.size(), delim, consumer); return res.size(); } - + template <class P, class D> -void GetNext(TStringBuf& s, D delim, P& param) { - TStringBuf next = s.NextTok(delim); +void GetNext(TStringBuf& s, D delim, P& param) { + TStringBuf next = s.NextTok(delim); Y_ENSURE(next.IsInited(), TStringBuf("Split: number of fields less than number of Split output arguments")); - param = FromString<P>(next); -} - + param = FromString<P>(next); +} + template <class P, class D> void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) { TStringBuf next = s.NextTok(delim); @@ -444,17 +444,17 @@ void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) { // example: // Split(TStringBuf("Sherlock,2014,36.6"), ',', name, year, temperature); template <class D, class P1, class P2> -void Split(TStringBuf s, D delim, P1& p1, P2& p2) { - GetNext(s, delim, p1); - GetNext(s, delim, p2); +void Split(TStringBuf s, D delim, P1& p1, P2& p2) { + GetNext(s, delim, p1); + GetNext(s, delim, p2); Y_ENSURE(!s.IsInited(), TStringBuf("Split: number of fields more than number of Split output arguments")); -} - +} + template <class D, class P1, class P2, class... Other> void Split(TStringBuf s, D delim, P1& p1, P2& p2, Other&... other) { - GetNext(s, delim, p1); + GetNext(s, delim, p1); Split(s, delim, p2, other...); -} +} /** * \fn auto StringSplitter(...) diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index e027d1ac7d..43e59f2d75 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { UNIT_ASSERT_VALUES_EQUAL(num1, 22); UNIT_ASSERT_VALUES_EQUAL(num2, 33.5); UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz"); - } + } Y_UNIT_TEST(ConvenientSplitTestWithMaybe) { TString data("abc 42"); @@ -280,11 +280,11 @@ Y_UNIT_TEST_SUITE(SplitStringTest) { Y_UNIT_TEST(ConvenientSplitTestExceptions) { TString data("abc 22 33"); TString s1, s2, s3, s4; - - UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2), yexception); - UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, s3)); - UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, s3, s4), yexception); - } + + UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2), yexception); + UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, s3)); + UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, s3, s4), yexception); + } Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) { TString data("abc 22 33"); diff --git a/util/system/guard.h b/util/system/guard.h index e8571293a1..efc091d5f8 100644 --- a/util/system/guard.h +++ b/util/system/guard.h @@ -83,7 +83,7 @@ private: private: T* T_; }; - + /* * { * auto guard = Guard(Lock_); diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp index 082fe1a339..48e898f32d 100644 --- a/util/thread/factory.cpp +++ b/util/thread/factory.cpp @@ -49,7 +49,7 @@ namespace { return new TPoolThread; } }; - + class TThreadFactoryFuncObj: public IThreadFactory::IThreadAble { public: TThreadFactoryFuncObj(const std::function<void()>& func) @@ -63,17 +63,17 @@ namespace { private: std::function<void()> Func; - }; + }; } THolder<IThread> IThreadFactory::Run(std::function<void()> func) { THolder<IThread> ret(DoCreate()); - + ret->Run(new ::TThreadFactoryFuncObj(func)); - - return ret; -} - + + return ret; +} + static IThreadFactory* SystemThreadPoolImpl() { return Singleton<TSystemThreadFactory>(); } diff --git a/util/thread/factory.h b/util/thread/factory.h index 29b1aac16b..561fcbac88 100644 --- a/util/thread/factory.h +++ b/util/thread/factory.h @@ -49,7 +49,7 @@ public: // XXX: rename to Start inline THolder<IThread> Run(IThreadAble* func) { THolder<IThread> ret(DoCreate()); - + ret->Run(func); return ret; diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index b6cb59644d..05fad02e9b 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -641,7 +641,7 @@ size_t TSimpleThreadPool::Size() const noexcept { return 0; } -namespace { +namespace { class TOwnedObjectInQueue: public IObjectInQueue { private: THolder<IObjectInQueue> Owned; @@ -657,8 +657,8 @@ namespace { Owned->Process(data); } }; -} - +} + void IThreadPool::SafeAdd(IObjectInQueue* obj) { Y_ENSURE_EX(Add(obj), TThreadPoolException() << TStringBuf("can not add object to queue")); } diff --git a/util/ysaveload.h b/util/ysaveload.h index 225579a68b..02efb4049b 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -617,28 +617,28 @@ template <class T1, class T2, class T3, class T4> class TSerializer<THashSet<T1, T2, T3, T4>>: public TSetSerializer<THashSet<T1, T2, T3, T4>, false> { }; -template <class T1, class T2> +template <class T1, class T2> class TSerializer<TQueue<T1, T2>> { -public: +public: static inline void Save(IOutputStream* rh, const TQueue<T1, T2>& v) { - ::Save(rh, v.Container()); - } + ::Save(rh, v.Container()); + } static inline void Load(IInputStream* in, TQueue<T1, T2>& t) { - ::Load(in, t.Container()); - } -}; - -template <class T1, class T2, class T3> + ::Load(in, t.Container()); + } +}; + +template <class T1, class T2, class T3> class TSerializer<TPriorityQueue<T1, T2, T3>> { -public: +public: static inline void Save(IOutputStream* rh, const TPriorityQueue<T1, T2, T3>& v) { - ::Save(rh, v.Container()); - } + ::Save(rh, v.Container()); + } static inline void Load(IInputStream* in, TPriorityQueue<T1, T2, T3>& t) { - ::Load(in, t.Container()); - } -}; - + ::Load(in, t.Container()); + } +}; + #ifndef __NVCC__ namespace NPrivate { |