diff options
author | Oleg Sidorkin <osidorkin@gmail.com> | 2022-02-10 16:49:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:36 +0300 |
commit | f8f6804a3e352897afabc93afcb32081e3fca601 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util | |
parent | 5ce74d4fee2d42a4b86efc02dfdc704d458760e1 (diff) | |
download | ydb-f8f6804a3e352897afabc93afcb32081e3fca601.tar.gz |
Restoring authorship annotation for Oleg Sidorkin <osidorkin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/generic/algorithm.h | 8 | ||||
-rw-r--r-- | util/generic/hash.h | 2 | ||||
-rw-r--r-- | util/generic/ptr.pxd | 12 | ||||
-rw-r--r-- | util/generic/ptr_ut.pyx | 36 | ||||
-rw-r--r-- | util/generic/strbase.h | 8 | ||||
-rw-r--r-- | util/generic/string.cpp | 28 | ||||
-rw-r--r-- | util/generic/string.h | 28 | ||||
-rw-r--r-- | util/generic/string.pxd | 4 | ||||
-rw-r--r-- | util/generic/string_ut.cpp | 12 | ||||
-rw-r--r-- | util/generic/string_ut.h | 20 | ||||
-rw-r--r-- | util/string/subst.h | 2 | ||||
-rw-r--r-- | util/system/compat.h | 2 | ||||
-rw-r--r-- | util/system/filemap.cpp | 14 | ||||
-rw-r--r-- | util/system/filemap.h | 10 | ||||
-rw-r--r-- | util/system/filemap_ut.cpp | 70 | ||||
-rw-r--r-- | util/tests/cython/test_generic.py | 2 | ||||
-rw-r--r-- | util/tests/cython/ya.make | 2 |
17 files changed, 130 insertions, 130 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index da68f2d8eb..badfb88993 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -316,25 +316,25 @@ static inline T UniqueBy(T f, T l, const TGetKey& getKey) { template <class C> void SortUnique(C& c) { Sort(c.begin(), c.end()); - c.erase(Unique(c.begin(), c.end()), c.end()); + c.erase(Unique(c.begin(), c.end()), c.end()); } template <class C, class Cmp> void SortUnique(C& c, Cmp cmp) { Sort(c.begin(), c.end(), cmp); - c.erase(Unique(c.begin(), c.end()), c.end()); + c.erase(Unique(c.begin(), c.end()), c.end()); } template <class C, class TGetKey> void SortUniqueBy(C& c, const TGetKey& getKey) { SortBy(c, getKey); - c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); + c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); } template <class C, class TGetKey> void StableSortUniqueBy(C& c, const TGetKey& getKey) { StableSortBy(c, getKey); - c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); + c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); } template <class C, class TValue> diff --git a/util/generic/hash.h b/util/generic/hash.h index c8ba6c5591..e46db21fa9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -812,7 +812,7 @@ public: template <class OtherKey> size_type erase_one(const OtherKey& key); - // void (instead of iterator) is intended, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2023.pdf + // void (instead of iterator) is intended, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2023.pdf void erase(const iterator& it); void erase(iterator first, iterator last); diff --git a/util/generic/ptr.pxd b/util/generic/ptr.pxd index 8ca52bd4fc..16e8d19144 100644 --- a/util/generic/ptr.pxd +++ b/util/generic/ptr.pxd @@ -1,11 +1,11 @@ -cdef extern from "<util/generic/ptr.h>" nogil: - cdef cppclass THolder[T]: +cdef extern from "<util/generic/ptr.h>" nogil: + cdef cppclass THolder[T]: THolder(...) - T* Get() - void Destroy() - T* Release() + T* Get() + void Destroy() + T* Release() void Reset() - void Reset(T*) + void Reset(T*) void Swap(THolder[T]) diff --git a/util/generic/ptr_ut.pyx b/util/generic/ptr_ut.pyx index 2c4f2fbb73..759681a2cb 100644 --- a/util/generic/ptr_ut.pyx +++ b/util/generic/ptr_ut.pyx @@ -1,24 +1,24 @@ from libcpp.utility cimport pair from util.generic.ptr cimport MakeAtomicShared, TAtomicSharedPtr, THolder -from util.generic.string cimport TString +from util.generic.string cimport TString from util.system.types cimport ui64 - -import pytest -import unittest - - -class TestHolder(unittest.TestCase): - - def test_basic(self): - cdef THolder[TString] holder - holder.Reset(new TString("aaa")) - assert holder.Get()[0] == "aaa" - holder.Destroy() - assert holder.Get() == NULL - holder.Reset(new TString("bbb")) - assert holder.Get()[0] == "bbb" - holder.Reset(new TString("ccc")) - assert holder.Get()[0] == "ccc" + +import pytest +import unittest + + +class TestHolder(unittest.TestCase): + + def test_basic(self): + cdef THolder[TString] holder + holder.Reset(new TString("aaa")) + assert holder.Get()[0] == "aaa" + holder.Destroy() + assert holder.Get() == NULL + holder.Reset(new TString("bbb")) + assert holder.Get()[0] == "bbb" + holder.Reset(new TString("ccc")) + assert holder.Get()[0] == "ccc" def test_make_atomic_shared(self): cdef TAtomicSharedPtr[pair[ui64, TString]] atomic_shared_ptr = MakeAtomicShared[pair[ui64, TString]](15, "Some string") diff --git a/util/generic/strbase.h b/util/generic/strbase.h index 92ff9c35a5..ab39fc7537 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -173,10 +173,10 @@ public: } inline TCharType front() const noexcept { - Y_ASSERT(!empty()); - return Ptr()[0]; - } - + Y_ASSERT(!empty()); + return Ptr()[0]; + } + constexpr const TCharType* data() const noexcept { return Ptr(); } diff --git a/util/generic/string.cpp b/util/generic/string.cpp index b00f75cf6e..3c655f1f66 100644 --- a/util/generic/string.cpp +++ b/util/generic/string.cpp @@ -61,7 +61,7 @@ TBasicString<wchar16, std::char_traits<wchar16>>::AppendUtf8(const ::TStringBuf& if (pos != s.size()) { ythrow yexception() << "failed to decode UTF-8 string at pos " << pos << ::NDetail::InStringMsg(s.data(), s.size()); } - resize(oldSize + written); + resize(oldSize + written); return *this; } @@ -98,17 +98,17 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendAscii(const ::TStringBuf template <> TBasicString<char, std::char_traits<char>>& TBasicString<char, std::char_traits<char>>::AppendUtf16(const ::TWtringBuf& s) { - const size_t oldSize = size(); - ReserveAndResize(size() + WideToUTF8BufferSize(s.size())); - - size_t written = 0; - WideToUTF8(s.data(), s.size(), begin() + oldSize, written); - - resize(oldSize + written); - - return *this; -} - + const size_t oldSize = size(); + ReserveAndResize(size() + WideToUTF8BufferSize(s.size())); + + size_t written = 0; + WideToUTF8(s.data(), s.size(), begin() + oldSize, written); + + resize(oldSize + written); + + return *this; +} + template <> TUtf32String& TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf8(const ::TStringBuf& s) { @@ -119,7 +119,7 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf8(const ::TStringBuf& if (pos != s.size()) { ythrow yexception() << "failed to decode UTF-8 string at pos " << pos << ::NDetail::InStringMsg(s.data(), s.size()); } - resize(oldSize + written); + resize(oldSize + written); return *this; } @@ -135,7 +135,7 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf16(const ::TWtringBuf NDetail::UTF16ToUTF32ImplScalar(s.data(), s.data() + s.size(), end); size_t written = end - oldEnd; - resize(oldSize + written); + resize(oldSize + written); return *this; } diff --git a/util/generic/string.h b/util/generic/string.h index 7a35b056b6..8cd8aa6917 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -282,18 +282,18 @@ public: #endif } - using TBase::front; - + using TBase::front; + inline reference front() noexcept { - Y_ASSERT(!this->empty()); + Y_ASSERT(!this->empty()); #ifdef TSTRING_IS_STD_STRING return Storage_.front(); #else return reference(*this, 0); #endif - } - + } + inline size_t length() const noexcept { return ConstRef().length(); } @@ -536,11 +536,11 @@ private: return s1.size() + SumLength(r...); } - template <typename... R> - static size_t SumLength(const TCharType /*s1*/, const R&... r) noexcept { - return 1 + SumLength(r...); - } - + template <typename... R> + static size_t SumLength(const TCharType /*s1*/, const R&... r) noexcept { + return 1 + SumLength(r...); + } + static constexpr size_t SumLength() noexcept { return 0; } @@ -553,10 +553,10 @@ private: template <typename... R, class TNextCharType, typename = std::enable_if_t<std::is_same<TCharType, TNextCharType>::value>> static void CopyAll(TCharType* p, const TNextCharType s, const R&... r) { - p[0] = s; - CopyAll(p + 1, r...); - } - + p[0] = s; + CopyAll(p + 1, r...); + } + static void CopyAll(TCharType*) noexcept { } diff --git a/util/generic/string.pxd b/util/generic/string.pxd index 33d17a48de..c25f7392a1 100644 --- a/util/generic/string.pxd +++ b/util/generic/string.pxd @@ -7,9 +7,9 @@ cdef extern from "<util/generic/strbuf.h>" nogil: TStringBuf(const char*) except + TStringBuf(const char*, size_t) except + const char* data() - char* Data() + char* Data() size_t size() - size_t Size() + size_t Size() cdef extern from "<util/generic/string.h>" nogil: diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index a236df0d83..ac82e9091d 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -745,19 +745,19 @@ public: UNIT_TEST(TestCharRef); #endif UNIT_TEST(TestBack) - UNIT_TEST(TestFront) + UNIT_TEST(TestFront) UNIT_TEST(TestIterators); UNIT_TEST(TestReverseIterators); - UNIT_TEST(TestAppendUtf16) + UNIT_TEST(TestAppendUtf16) UNIT_TEST(TestFillingAssign) UNIT_TEST(TestStdStreamApi) //UNIT_TEST(TestOperatorsCI); must fail UNIT_TEST_SUITE_END(); - - void TestAppendUtf16() { + + void TestAppendUtf16() { TString appended = TString("А роза упала").AppendUtf16(u" на лапу Азора"); UNIT_ASSERT(appended == "А роза упала на лапу Азора"); - } + } void TestFillingAssign() { TString s("abc"); @@ -807,7 +807,7 @@ public: UNIT_TEST(TestCharRef); #endif UNIT_TEST(TestBack); - UNIT_TEST(TestFront) + UNIT_TEST(TestFront) UNIT_TEST(TestDecodingMethods); UNIT_TEST(TestIterators); UNIT_TEST(TestReverseIterators); diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index d154ba20ae..44bb10bdeb 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -1060,20 +1060,20 @@ public: UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'r'); } - - void TestFront() { - const char_type chars[] = {'f', 'o', 'o', 0}; - - TStringType str = chars; - const TStringType constStr = str; - + + void TestFront() { + const char_type chars[] = {'f', 'o', 'o', 0}; + + TStringType str = chars; + const TStringType constStr = str; + UNIT_ASSERT_VALUES_EQUAL(constStr.front(), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(str.front(), (ui8)'f'); - - str.front() = 'r'; + + str.front() = 'r'; UNIT_ASSERT_VALUES_EQUAL(constStr.front(), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(str.front(), (ui8)'r'); - } + } void TestIterators() { const char_type chars[] = {'f', 'o', 0}; diff --git a/util/string/subst.h b/util/string/subst.h index 6c72fab4c6..45b622fbef 100644 --- a/util/string/subst.h +++ b/util/string/subst.h @@ -50,7 +50,7 @@ size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from = * @return Result string */ template <class TStringType, class TPatternType> -Y_WARN_UNUSED_RESULT TStringType SubstGlobalCopy(TStringType result, TPatternType what, TPatternType with, size_t from = 0) { +Y_WARN_UNUSED_RESULT TStringType SubstGlobalCopy(TStringType result, TPatternType what, TPatternType with, size_t from = 0) { SubstGlobal(result, what, with, from); return result; } diff --git a/util/system/compat.h b/util/system/compat.h index e7394d2cff..c53dbcca17 100644 --- a/util/system/compat.h +++ b/util/system/compat.h @@ -4,7 +4,7 @@ #include <cstdarg> -#include <csignal> +#include <csignal> #if defined(_unix_) #include <unistd.h> diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index b64e2d5314..7454a4cb94 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -214,10 +214,10 @@ public: ; } - inline bool IsWritable() const noexcept { + inline bool IsWritable() const noexcept { return (Mode_ & oRdWr || Mode_ & oCopyOnWr); - } - + } + inline TMapResult Map(i64 offset, size_t size) { assert(File_.IsOpen()); @@ -427,10 +427,10 @@ bool TMemoryMap::IsOpen() const noexcept { return Impl_->IsOpen(); } -bool TMemoryMap::IsWritable() const noexcept { - return Impl_->IsWritable(); -} - +bool TMemoryMap::IsWritable() const noexcept { + return Impl_->IsWritable(); +} + TMemoryMap::EOpenMode TMemoryMap::GetMode() const noexcept { return Impl_->GetMode(); } diff --git a/util/system/filemap.h b/util/system/filemap.h index 8be30c0a71..11be64bff4 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -88,7 +88,7 @@ public: i64 Length() const noexcept; bool IsOpen() const noexcept; - bool IsWritable() const noexcept; + bool IsWritable() const noexcept; EOpenMode GetMode() const noexcept; TFile GetFile() const noexcept; @@ -146,10 +146,10 @@ public: return Map_.IsOpen(); } - inline bool IsWritable() const noexcept { - return Map_.IsWritable(); - } - + inline bool IsWritable() const noexcept { + return Map_.IsWritable(); + } + EOpenMode GetMode() const noexcept { return Map_.GetMode(); } diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp index 91ab5026b8..73f109dc88 100644 --- a/util/system/filemap_ut.cpp +++ b/util/system/filemap_ut.cpp @@ -317,43 +317,43 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { } NFs::Remove(FileName_); } - + Y_UNIT_TEST(TestMemoryMapIsWritable) { - TFile file(FileName_, CreateAlways | WrOnly); - file.Close(); - - { - TMemoryMap mappedMem(FileName_, TMemoryMap::oRdOnly); - UNIT_ASSERT(!mappedMem.IsWritable()); - } - { - TMemoryMap mappedMem(FileName_, TMemoryMap::oRdWr); - UNIT_ASSERT(mappedMem.IsWritable()); - } + TFile file(FileName_, CreateAlways | WrOnly); + file.Close(); + + { + TMemoryMap mappedMem(FileName_, TMemoryMap::oRdOnly); + UNIT_ASSERT(!mappedMem.IsWritable()); + } + { + TMemoryMap mappedMem(FileName_, TMemoryMap::oRdWr); + UNIT_ASSERT(mappedMem.IsWritable()); + } NFs::Remove(FileName_); - } - + } + Y_UNIT_TEST(TestFileMapIsWritable) { - TFile file(FileName_, CreateAlways | WrOnly); - file.Close(); - { - TMemoryMap mappedMem(FileName_, TMemoryMap::oRdOnly); - TFileMap fileMap(mappedMem); - UNIT_ASSERT(!fileMap.IsWritable()); - } - { - TMemoryMap mappedMem(FileName_, TMemoryMap::oRdWr); - TFileMap fileMap(mappedMem); - UNIT_ASSERT(fileMap.IsWritable()); - } - { - TFileMap fileMap(FileName_, TFileMap::oRdOnly); - UNIT_ASSERT(!fileMap.IsWritable()); - } - { - TFileMap fileMap(FileName_, TFileMap::oRdWr); - UNIT_ASSERT(fileMap.IsWritable()); - } + TFile file(FileName_, CreateAlways | WrOnly); + file.Close(); + { + TMemoryMap mappedMem(FileName_, TMemoryMap::oRdOnly); + TFileMap fileMap(mappedMem); + UNIT_ASSERT(!fileMap.IsWritable()); + } + { + TMemoryMap mappedMem(FileName_, TMemoryMap::oRdWr); + TFileMap fileMap(mappedMem); + UNIT_ASSERT(fileMap.IsWritable()); + } + { + TFileMap fileMap(FileName_, TFileMap::oRdOnly); + UNIT_ASSERT(!fileMap.IsWritable()); + } + { + TFileMap fileMap(FileName_, TFileMap::oRdWr); + UNIT_ASSERT(fileMap.IsWritable()); + } NFs::Remove(FileName_); - } + } }; diff --git a/util/tests/cython/test_generic.py b/util/tests/cython/test_generic.py index bc1f61b509..a0d61339cc 100644 --- a/util/tests/cython/test_generic.py +++ b/util/tests/cython/test_generic.py @@ -7,7 +7,7 @@ from util.generic.hash_ut import TestHash from util.generic.hash_set_ut import TestHashSet from util.generic.list_ut import TestList from util.generic.maybe_ut import TestMaybe -from util.generic.ptr_ut import TestHolder +from util.generic.ptr_ut import TestHolder from util.generic.string_ut import TestStroka from util.generic.vector_ut import TestVector from util.string.cast_ut import TestFromString, TestToString diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make index 6078498711..b928c19026 100644 --- a/util/tests/cython/ya.make +++ b/util/tests/cython/ya.make @@ -14,7 +14,7 @@ PY_SRCS( generic/array_ref_ut.pyx generic/deque_ut.pyx generic/maybe_ut.pyx - generic/ptr_ut.pyx + generic/ptr_ut.pyx generic/string_ut.pyx generic/vector_ut.pyx generic/list_ut.pyx |