Browse Source

Restoring authorship annotation for <dprokoptsev@yandex-team.ru>. Commit 1 of 2.

dprokoptsev 3 years ago
parent
commit
94e596fdab

+ 2 - 2
library/cpp/testing/unittest/registar.h

@@ -981,7 +981,7 @@ public:                       \
         UNIT_TEST_SUITE_REGISTRATION(TCurrentTest)                                                                      \
     }                                                                                                                   \
     namespace NTestSuite##N
-
+ 
 #define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase)
 #define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase)
 #define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F)
@@ -1006,7 +1006,7 @@ public:                       \
         }                                                   \
     };                                                      \
     static const TTestRegistration##N testRegistration##N;
-
+ 
 #define Y_UNIT_TEST_IMPL(N, FF, F)      \
     Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
     void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED)

+ 2 - 2
util/charset/wide_ut.cpp

@@ -517,13 +517,13 @@ void TConversionTest::TestUTF8ToWide() {
 
 void TConversionTest::TestWideToUTF8() {
     TString s = WideToUTF8(UnicodeText_);
-    size_t len = 0;
+    size_t len = 0; 
     for (TUtf16String::const_iterator i = UnicodeText_.begin(), ie = UnicodeText_.end(); i != ie; ++i) {
         len += UTF8RuneLenByUCS(*i);
     }
 
     UNIT_ASSERT(s.size() == Utf8Text_.size());
-    UNIT_ASSERT(s.size() == len);
+    UNIT_ASSERT(s.size() == len); 
 
     for (int i = 0; i < static_cast<int>(s.size()); ++i) {
         UNIT_ASSERT_VALUES_EQUAL(s[i], Utf8Text_[i]);

+ 3 - 3
util/generic/maybe.h

@@ -1,5 +1,5 @@
 #pragma once
-
+ 
 #include <utility>
 
 #include "maybe_traits.h"
@@ -36,7 +36,7 @@ constexpr bool operator==(TNothing, TNothing) noexcept {
 
 template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/>
 class TMaybe: private TMaybeBase<T> {
-public:
+public: 
     using TInPlace = NMaybe::TInPlace;
 
 private:
@@ -446,7 +446,7 @@ private:
         new (Data()) T(std::forward<Args>(args)...);
         this->Defined_ = true;
     }
-};
+}; 
 
 template <class T>
 using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>;

+ 2 - 2
util/generic/string.h

@@ -311,9 +311,9 @@ public:
         return &*MutRef().begin();
     }
 
-    iterator vend() {
+    iterator vend() { 
         return &*MutRef().end();
-    }
+    } 
 
     reverse_iterator rbegin() {
         return reverse_iterator(vend());

+ 5 - 5
util/memory/segmented_string_pool.h

@@ -98,12 +98,12 @@ public:
     size_t get_segment_size() const {
         return segment_size;
     }
-    bool contains(const T* ptr) const {
-        for (seg_const_iterator i = segs.begin(), ie = segs.end(); i != ie; ++i)
+    bool contains(const T* ptr) const { 
+        for (seg_const_iterator i = segs.begin(), ie = segs.end(); i != ie; ++i) 
             if ((char*)ptr >= (char*)i->data && (char*)ptr < (char*)i->data + i->freepos)
-                return true;
-        return false;
-    }
+                return true; 
+        return false; 
+    } 
     size_t size() const {
         size_t r = 0;
         for (seg_const_iterator i = segs.begin(); i != segs.end(); ++i)

+ 14 - 14
util/stream/aligned.h

@@ -1,8 +1,8 @@
 #pragma once
-
+ 
 #include "input.h"
 #include "output.h"
-
+ 
 #include <util/system/yassert.h>
 #include <util/generic/bitops.h>
 
@@ -16,12 +16,12 @@
  * aligned data easier.
  */
 class TAlignedInput: public IInputStream {
-public:
+public: 
     TAlignedInput(IInputStream* s)
         : Stream_(s)
         , Position_(0)
-    {
-    }
+    { 
+    } 
 
     /**
      * Ensures alignment of the position in the input stream by skipping
@@ -39,7 +39,7 @@ public:
                 len -= DoSkip(len);
             } while (len);
         }
-    }
+    } 
 
 private:
     size_t DoRead(void* ptr, size_t len) override;
@@ -50,19 +50,19 @@ private:
 private:
     IInputStream* Stream_;
     ui64 Position_;
-};
-
+}; 
+ 
 /**
  * Proxy output stream that provides additional functions that make writing
  * aligned data easier.
  */
 class TAlignedOutput: public IOutputStream {
-public:
+public: 
     TAlignedOutput(IOutputStream* s)
         : Stream_(s)
         , Position_(0)
-    {
-    }
+    { 
+    } 
 
     TAlignedOutput(TAlignedOutput&&) noexcept = default;
     TAlignedOutput& operator=(TAlignedOutput&&) noexcept = default;
@@ -86,7 +86,7 @@ public:
         if (Position_ & (alignment - 1)) {
             DoWrite(unused, alignment - (Position_ & (alignment - 1)));
         }
-    }
+    } 
 
 private:
     void DoWrite(const void* ptr, size_t len) override;
@@ -94,6 +94,6 @@ private:
 private:
     IOutputStream* Stream_;
     ui64 Position_;
-};
-
+}; 
+ 
 /** @} */

+ 11 - 11
util/string/vector.h

@@ -68,19 +68,19 @@ SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* de
 
 template <class TIter>
 inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
-    if (begin == end)
+    if (begin == end) 
         return TString();
 
     TString result = ToString(*begin);
 
-    for (++begin; begin != end; ++begin) {
-        result.append(delim);
+    for (++begin; begin != end; ++begin) { 
+        result.append(delim); 
         result.append(ToString(*begin));
-    }
-
-    return result;
-}
+    } 
 
+    return result; 
+} 
+ 
 template <class TIter>
 inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
     if (begin == end)
@@ -99,13 +99,13 @@ inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim)
 /// Concatenates elements of given TVector<TString>.
 inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
     return JoinStrings(v.begin(), v.end(), delim);
-}
-
+} 
+ 
 inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
     Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
     return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
-}
-
+} 
+ 
 template <typename T>
 inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
     return JoinStrings(v.begin(), v.end(), delim);

+ 2 - 2
util/system/filemap.cpp

@@ -240,7 +240,7 @@ public:
                                    (Mode_ & oAccessMask) == oRdOnly ? FILE_MAP_READ : (Mode_ & oAccessMask) == oCopyOnWr ? FILE_MAP_COPY
                                                                                                                          : FILE_MAP_WRITE,
                                    Hi32(base), Lo32(base), size);
-#else
+#else 
     #if defined(_unix_)
         if (Mode_ & oNotGreedy) {
     #endif
@@ -272,7 +272,7 @@ public:
     inline bool Unmap(void* ptr, size_t) {
         return ::UnmapViewOfFile(ptr) != FALSE;
     }
-#else
+#else 
     inline bool Unmap(void* ptr, size_t size) {
     #if defined(_unix_)
         if (Mode_ & oNotGreedy) {

+ 35 - 35
util/system/filemap_ut.cpp

@@ -1,8 +1,8 @@
 #include <library/cpp/testing/unittest/registar.h>
 
-#ifdef _unix_
+#ifdef _unix_ 
     #include <sys/resource.h>
-#endif
+#endif 
 
 #include "filemap.h"
 
@@ -135,82 +135,82 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
         unsigned page[4096 / sizeof(unsigned)];
 
     #if defined(_unix_)
-        // Temporary limit allowed virtual memory size to 1Gb
-        struct rlimit rlim;
+        // Temporary limit allowed virtual memory size to 1Gb 
+        struct rlimit rlim; 
 
         if (getrlimit(RLIMIT_AS, &rlim)) {
-            throw TSystemError() << "Cannot get rlimit for virtual memory";
+            throw TSystemError() << "Cannot get rlimit for virtual memory"; 
         }
 
         rlim_t Limit = 1 * 1024 * 1024 * 1024;
 
-        if (rlim.rlim_cur > Limit) {
-            rlim.rlim_cur = Limit;
+        if (rlim.rlim_cur > Limit) { 
+            rlim.rlim_cur = Limit; 
 
             if (setrlimit(RLIMIT_AS, &rlim)) {
-                throw TSystemError() << "Cannot set rlimit for virtual memory to 1Gb";
+                throw TSystemError() << "Cannot set rlimit for virtual memory to 1Gb"; 
             }
-        }
+        } 
     #endif
-        // Make a 128M test file
-        try {
-            TFile file(FileName_, CreateAlways | WrOnly);
+        // Make a 128M test file 
+        try { 
+            TFile file(FileName_, CreateAlways | WrOnly); 
 
             for (unsigned pages = 128 * 1024 * 1024 / sizeof(page), i = 0; pages--; i++) {
                 std::fill(page, page + sizeof(page) / sizeof(*page), i);
-                file.Write(page, sizeof(page));
-            }
+                file.Write(page, sizeof(page)); 
+            } 
 
-            file.Close();
+            file.Close(); 
 
-            // Make 16 maps of our file, which would require 16*128M = 2Gb and exceed our 1Gb limit
+            // Make 16 maps of our file, which would require 16*128M = 2Gb and exceed our 1Gb limit 
             TVector<THolder<TFileMap>> maps;
 
-            for (int i = 0; i < 16; ++i) {
+            for (int i = 0; i < 16; ++i) { 
                 maps.emplace_back(MakeHolder<TFileMap>(FileName_, TMemoryMapCommon::oRdOnly | TMemoryMapCommon::oNotGreedy));
-                maps.back()->Map(i * sizeof(page), sizeof(page));
-            }
+                maps.back()->Map(i * sizeof(page), sizeof(page)); 
+            } 
 
-            // Oh, good, we're not dead yet
-            for (int i = 0; i < 16; ++i) {
-                TFileMap& map = *maps[i];
+            // Oh, good, we're not dead yet 
+            for (int i = 0; i < 16; ++i) { 
+                TFileMap& map = *maps[i]; 
 
                 UNIT_ASSERT_EQUAL(map.Length(), 128 * 1024 * 1024);
-                UNIT_ASSERT_EQUAL(map.MappedSize(), sizeof(page));
+                UNIT_ASSERT_EQUAL(map.MappedSize(), sizeof(page)); 
 
                 const int* mappedPage = (const int*)map.Ptr();
 
                 for (size_t j = 0; j < sizeof(page) / sizeof(*page); ++j) {
-                    UNIT_ASSERT_EQUAL(mappedPage[j], i);
+                    UNIT_ASSERT_EQUAL(mappedPage[j], i); 
                 }
-            }
+            } 
 
     #if defined(_unix_)
-            // Restore limits and cleanup
-            rlim.rlim_cur = rlim.rlim_max;
+            // Restore limits and cleanup 
+            rlim.rlim_cur = rlim.rlim_max; 
 
             if (setrlimit(RLIMIT_AS, &rlim)) {
-                throw TSystemError() << "Cannot restore rlimit for virtual memory";
+                throw TSystemError() << "Cannot restore rlimit for virtual memory"; 
             }
     #endif
-            maps.clear();
+            maps.clear(); 
             NFs::Remove(FileName_);
         } catch (...) {
     // TODO: RAII'ize all this stuff
     #if defined(_unix_)
-            rlim.rlim_cur = rlim.rlim_max;
+            rlim.rlim_cur = rlim.rlim_max; 
 
             if (setrlimit(RLIMIT_AS, &rlim)) {
-                throw TSystemError() << "Cannot restore rlimit for virtual memory";
+                throw TSystemError() << "Cannot restore rlimit for virtual memory"; 
             }
     #endif
             NFs::Remove(FileName_);
 
-            throw;
-        }
-    }
+            throw; 
+        } 
+    } 
 #endif
-
+ 
     Y_UNIT_TEST(TestFileMappedArray) {
         {
             TFileMappedArray<ui32> mappedArray;

+ 5 - 5
util/ysaveload.h

@@ -398,16 +398,16 @@ template <class T, size_t N>
 class TSerializer<std::array<T, N>>: public TStdArraySerializer<std::array<T, N>> {
 };
 
-template <class A, class B>
+template <class A, class B> 
 class TSerializer<std::pair<A, B>> {
     using TPair = std::pair<A, B>;
-
+ 
 public:
     static inline void Save(IOutputStream* rh, const TPair& p) {
         ::Save(rh, p.first);
         ::Save(rh, p.second);
     }
-
+ 
     static inline void Load(IInputStream* rh, TPair& p) {
         ::Load(rh, p.first);
         ::Load(rh, p.second);
@@ -418,8 +418,8 @@ public:
         ::Load(rh, p.first, pool);
         ::Load(rh, p.second, pool);
     }
-};
-
+}; 
+ 
 template <class T>
 struct TTupleSerializer {
     template <class F, class Tuple, size_t... Indices>