Browse Source

Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 2 of 2.

Alexey Salmin 3 years ago
parent
commit
71af077a5d

+ 9 - 9
library/cpp/balloc/balloc.cpp

@@ -76,7 +76,7 @@ namespace NBalloc {
     static void Y_FORCE_INLINE Enable() {
         tls.Mode = ToBeEnabled;
     }
- 
+
     static bool Y_FORCE_INLINE IsDisabled() {
         return tls.Mode == Disabled;
     }
@@ -273,11 +273,11 @@ extern "C" void* realloc(void* oldPtr, size_t newSize) {
 }
 #endif
 
-// Only for testing purposes. Never use in production. 
+// Only for testing purposes. Never use in production.
 extern "C" bool IsOwnedByBalloc(void* ptr) {
-    return NBalloc::IsOwnedByBalloc(ptr); 
-} 
- 
+    return NBalloc::IsOwnedByBalloc(ptr);
+}
+
 extern "C" bool BallocDisabled() {
     return NBalloc::IsDisabled();
 }
@@ -286,10 +286,10 @@ extern "C" void DisableBalloc() {
     NBalloc::Disable();
 }
 
-extern "C" void EnableBalloc() { 
-    NBalloc::Enable(); 
-} 
- 
+extern "C" void EnableBalloc() {
+    NBalloc::Enable();
+}
+
 extern "C" void* memalign(size_t alignment, size_t size) {
     void* ptr;
     int res = posix_memalign(&ptr, alignment, size);

+ 6 - 6
library/cpp/balloc/malloc-info.cpp

@@ -5,18 +5,18 @@
 using namespace NMalloc;
 
 extern "C" void DisableBalloc();
-extern "C" void EnableBalloc(); 
+extern "C" void EnableBalloc();
 extern "C" bool BallocDisabled();
 
 namespace {
     bool SetAllocParam(const char* name, const char* value) {
         if (strcmp(name, "disable") == 0) {
             if (value == nullptr || strcmp(value, "false") != 0) {
-                // all values other than "false" are considred to be "true" for compatibility 
-                DisableBalloc(); 
-            } else { 
-                EnableBalloc(); 
-            } 
+                // all values other than "false" are considred to be "true" for compatibility
+                DisableBalloc();
+            } else {
+                EnableBalloc();
+            }
             return true;
         }
         return false;

+ 4 - 4
library/cpp/balloc/optional/operators.h

@@ -10,7 +10,7 @@ inline bool BallocEnabled() {
 inline void ThreadDisableBalloc() {
     ::NMalloc::MallocInfo().SetParam("disable", "true");
 }
- 
-inline void ThreadEnableBalloc() { 
-    ::NMalloc::MallocInfo().SetParam("disable", "false"); 
-} 
+
+inline void ThreadEnableBalloc() {
+    ::NMalloc::MallocInfo().SetParam("disable", "false");
+}

+ 30 - 30
library/cpp/cgiparam/cgiparam.h

@@ -88,13 +88,13 @@ public:
     void InsertEscaped(const TStringBuf name, const TStringBuf value);
 
 #if !defined(__GLIBCXX__)
-    template <typename TName, typename TValue> 
-    inline void InsertUnescaped(TName&& name, TValue&& value) { 
+    template <typename TName, typename TValue>
+    inline void InsertUnescaped(TName&& name, TValue&& value) {
         // TStringBuf use as TName or TValue is C++17 actually.
         // There is no pair constructor available in C++14 when required type
         // is not implicitly constructible from given type.
         // But libc++ pair allows this with C++14.
-        emplace(std::forward<TName>(name), std::forward<TValue>(value)); 
+        emplace(std::forward<TName>(name), std::forward<TValue>(value));
     }
 #else
     template <typename TName, typename TValue>
@@ -103,19 +103,19 @@ public:
     }
 #endif
 
-    // replace all values for a given key with new values 
-    template <typename TIter> 
-    void ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, const TIter valuesEnd); 
+    // replace all values for a given key with new values
+    template <typename TIter>
+    void ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, const TIter valuesEnd);
+
+    void ReplaceUnescaped(const TStringBuf key, std::initializer_list<TStringBuf> values) {
+        ReplaceUnescaped(key, values.begin(), values.end());
+    }
 
-    void ReplaceUnescaped(const TStringBuf key, std::initializer_list<TStringBuf> values) { 
-        ReplaceUnescaped(key, values.begin(), values.end()); 
-    } 
- 
-    void ReplaceUnescaped(const TStringBuf key, const TStringBuf value) { 
+    void ReplaceUnescaped(const TStringBuf key, const TStringBuf value) {
         ReplaceUnescaped(key, {value});
-    } 
- 
-    // join multiple values into a single one using a separator 
+    }
+
+    // join multiple values into a single one using a separator
     // if val is a [possibly empty] non-NULL string, append it as well
     void JoinUnescaped(const TStringBuf key, char sep, TStringBuf val = TStringBuf());
 
@@ -132,29 +132,29 @@ public:
         return it->second.data();
     }
 };
- 
-template <typename TIter> 
-void TCgiParameters::ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, const TIter valuesEnd) { 
-    const auto oldRange = equal_range(key); 
-    auto current = oldRange.first; 
- 
-    // reuse as many existing nodes as possible (probably none) 
+
+template <typename TIter>
+void TCgiParameters::ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, const TIter valuesEnd) {
+    const auto oldRange = equal_range(key);
+    auto current = oldRange.first;
+
+    // reuse as many existing nodes as possible (probably none)
     for (; valuesBegin != valuesEnd && current != oldRange.second; ++valuesBegin, ++current) {
-        current->second = *valuesBegin; 
-    } 
- 
-    // if there were more nodes than we need to insert then erase remaining ones 
+        current->second = *valuesBegin;
+    }
+
+    // if there were more nodes than we need to insert then erase remaining ones
     for (; current != oldRange.second; erase(current++)) {
-    } 
- 
-    // if there were less nodes than we need to insert then emplace the rest of the range 
+    }
+
+    // if there were less nodes than we need to insert then emplace the rest of the range
     if (valuesBegin != valuesEnd) {
         const TString keyStr = TString(key);
         for (; valuesBegin != valuesEnd; ++valuesBegin) {
             emplace_hint(oldRange.second, keyStr, TString(*valuesBegin));
         }
-    } 
-} 
+    }
+}
 
 /** TQuickCgiParam is a faster non-editable version of TCgiParameters.
  * Care should be taken when replacing:

+ 42 - 42
library/cpp/cgiparam/cgiparam_ut.cpp

@@ -132,56 +132,56 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) {
 
     Y_UNIT_TEST(TestReplaceUnescaped1) {
         TCgiParameters c;
-        c.ScanAddAll("many_keys=1&aaa=1&many_keys=2&bbb&many_keys=3"); 
-        c.ReplaceUnescaped("many_keys", "new_value"); 
- 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&many_keys=new_value"); 
-    } 
- 
+        c.ScanAddAll("many_keys=1&aaa=1&many_keys=2&bbb&many_keys=3");
+        c.ReplaceUnescaped("many_keys", "new_value");
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&many_keys=new_value");
+    }
+
     Y_UNIT_TEST(TestReplaceUnescaped2) {
-        TCgiParameters c; 
-        c.ScanAddAll("par=1&only_one=1&par=2&bbb&par=3"); 
-        c.ReplaceUnescaped("only_one", "new_value"); 
- 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "bbb=&only_one=new_value&par=1&par=2&par=3"); 
-    } 
- 
+        TCgiParameters c;
+        c.ScanAddAll("par=1&only_one=1&par=2&bbb&par=3");
+        c.ReplaceUnescaped("only_one", "new_value");
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "bbb=&only_one=new_value&par=1&par=2&par=3");
+    }
+
     Y_UNIT_TEST(TestReplaceUnescaped3) {
-        TCgiParameters c; 
+        TCgiParameters c;
         c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3");
-        c.ReplaceUnescaped("no_such_key", "new_value"); 
+        c.ReplaceUnescaped("no_such_key", "new_value");
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&no_such_key=new_value&par=1&par=2&par=3");
+    }
 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&no_such_key=new_value&par=1&par=2&par=3"); 
-    } 
- 
     Y_UNIT_TEST(TestReplaceUnescapedRange1) {
-        TCgiParameters c; 
-        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); 
-        c.ReplaceUnescaped("par", {"x", "y", "z"}); // 3 old values, 3 new values 
- 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); 
-    } 
- 
+        TCgiParameters c;
+        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3");
+        c.ReplaceUnescaped("par", {"x", "y", "z"}); // 3 old values, 3 new values
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z");
+    }
+
     Y_UNIT_TEST(TestReplaceUnescapedRange2) {
-        TCgiParameters c; 
-        c.ScanAddAll("par=1&aaa=1&par=2&bbb"); 
-        c.ReplaceUnescaped("par", {"x", "y", "z"}); // 2 old values, 3 new values 
- 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z"); 
-    } 
- 
+        TCgiParameters c;
+        c.ScanAddAll("par=1&aaa=1&par=2&bbb");
+        c.ReplaceUnescaped("par", {"x", "y", "z"}); // 2 old values, 3 new values
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y&par=z");
+    }
+
     Y_UNIT_TEST(TestReplaceUnescapedRange3) {
-        TCgiParameters c; 
-        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); 
-        c.ReplaceUnescaped("par", {"x", "y"}); // 3 old values, 2 new values 
- 
-        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y"); 
-    } 
- 
+        TCgiParameters c;
+        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3");
+        c.ReplaceUnescaped("par", {"x", "y"}); // 3 old values, 2 new values
+
+        UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=1&bbb=&par=x&par=y");
+    }
+
     Y_UNIT_TEST(TestNumOfValues) {
-        TCgiParameters c; 
-        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3"); 
- 
+        TCgiParameters c;
+        c.ScanAddAll("par=1&aaa=1&par=2&bbb&par=3");
+
         UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("par"), 3u);
     }
 

+ 2 - 2
library/cpp/containers/sorted_vector/sorted_vector.h

@@ -323,7 +323,7 @@ namespace NSorted {
         using TBase::erase;
     };
 
-    // The simplified map (a.k.a TFlatMap, flat_map), which is implemented by the sorted-vector. 
+    // The simplified map (a.k.a TFlatMap, flat_map), which is implemented by the sorted-vector.
     // This structure has the side-effect: if you keep a reference to an existing element
     // and then inserts a new one, the existing reference can be broken (due to reallocation).
     // Please keep this in mind when using this structure.
@@ -397,7 +397,7 @@ namespace NSorted {
         }
     };
 
-    // The simplified set (a.k.a TFlatSet, flat_set), which is implemented by the sorted-vector. 
+    // The simplified set (a.k.a TFlatSet, flat_set), which is implemented by the sorted-vector.
     // This structure has the same side-effect as TSimpleMap.
     // The value type must have TValueType(TKeyType) constructor in order to use [] operator
     template <typename TValueType, typename TKeyType = TValueType, class TKeyExtractor = TIdentity,

+ 1 - 1
library/cpp/deprecated/mapped_file/mapped_file.cpp

@@ -11,7 +11,7 @@ TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) {
     if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32))
         ythrow yexception() << "File '" << dbgName << "' mapping error: " << len << " too large";
 
-    Map_->Map(0, static_cast<size_t>(len)); 
+    Map_->Map(0, static_cast<size_t>(len));
 }
 
 TMappedFile::TMappedFile(const TFile& file, TFileMap::EOpenMode om, const char* dbgName)

+ 3 - 3
library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp

@@ -1,8 +1,8 @@
 #include <library/cpp/deprecated/mapped_file/mapped_file.h>
 #include <library/cpp/testing/unittest/registar.h>
 
-#include <util/system/fs.h> 
- 
+#include <util/system/fs.h>
+
 Y_UNIT_TEST_SUITE(TMappedFileTest) {
     static const char* FileName_("./mappped_file");
     Y_UNIT_TEST(TestFileMapEmpty) {
@@ -13,6 +13,6 @@ Y_UNIT_TEST_SUITE(TMappedFileTest) {
         map.init(FileName_);
         map.getData(0);
 
-        NFs::Remove(FileName_); 
+        NFs::Remove(FileName_);
     }
 };

+ 3 - 3
library/cpp/getopt/last_getopt_demo/demo.cpp

@@ -92,7 +92,7 @@ protected:
                      {"OPTIONS", "describe the communication options for the target resource"},
                      {"TRACE", "perform a message loop-back test"},
                      {"PATCH", "apply partial modifications to the specified resource"}}));
- 
+
         opts.AddLongOption('U', "user-agent")
             .RequiredArgument("agent-string")
             .DefaultValue("LastGetoptDemo/1.0.0")
@@ -202,8 +202,8 @@ protected:
                 << colors.Cyan()
                 << "    $ last_getopt_demo -b -U 'Wget/1.0.0' https://wordpress.org/latest.zip"
                 << colors.Reset());
-    } 
- 
+    }
+
     int DoRun(NLastGetopt::TOptsParseResult&& parsedOptions) override {
         using namespace NColorizer;
 

+ 1 - 1
library/cpp/getopt/print.cpp

@@ -31,7 +31,7 @@ namespace NLastGetoptPrivate {
     TString& ShortVersionString();
 
     struct TInit {
-        TInit() { 
+        TInit() {
             VersionString() = InitVersionString();
             ShortVersionString() = InitShortVersionString();
         }

Some files were not shown because too many files changed in this diff