aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-square <a-square@yandex-team.ru>2022-02-10 16:50:24 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:24 +0300
commita01c1f7b71b4422f01b11d9ea45bfd88e228c968 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8
parent34f3f9bd7972f67d913075206081554a3e39a0de (diff)
downloadydb-a01c1f7b71b4422f01b11d9ea45bfd88e228c968.tar.gz
Restoring authorship annotation for <a-square@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--library/cpp/json/json_writer.h32
-rw-r--r--library/cpp/json/ut/json_writer_ut.cpp4
-rw-r--r--util/digest/sequence_ut.cpp16
-rw-r--r--util/generic/buffer.h6
-rw-r--r--util/generic/flags.h2
-rw-r--r--util/str_stl.h8
-rw-r--r--util/stream/buffered.cpp58
-rw-r--r--util/stream/buffered.h12
-rw-r--r--util/string/ascii.cpp12
-rw-r--r--util/string/ascii.h22
-rw-r--r--util/string/ascii_ut.cpp6
-rw-r--r--util/system/compiler.cpp8
-rw-r--r--util/system/compiler.h118
13 files changed, 152 insertions, 152 deletions
diff --git a/library/cpp/json/json_writer.h b/library/cpp/json/json_writer.h
index 006bfe5325..c7f5c9499a 100644
--- a/library/cpp/json/json_writer.h
+++ b/library/cpp/json/json_writer.h
@@ -156,22 +156,22 @@ namespace NJson {
// nothing to do
}
- void WriteKey(const TStringBuf key) {
- Buf.WriteKey(key);
- }
-
- void WriteKey(const unsigned char* key) {
- WriteKey((const char*)key);
- }
-
- void WriteKey(const char* key) {
- WriteKey(TStringBuf{key});
- }
-
- void WriteKey(const TString& key) {
- WriteKey(TStringBuf{key});
- }
-
+ void WriteKey(const TStringBuf key) {
+ Buf.WriteKey(key);
+ }
+
+ void WriteKey(const unsigned char* key) {
+ WriteKey((const char*)key);
+ }
+
+ void WriteKey(const char* key) {
+ WriteKey(TStringBuf{key});
+ }
+
+ void WriteKey(const TString& key) {
+ WriteKey(TStringBuf{key});
+ }
+
void WriteKey(const std::string& key) {
WriteKey(TStringBuf{key});
}
diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp
index e43d9d2caa..ca11d34dad 100644
--- a/library/cpp/json/ut/json_writer_ut.cpp
+++ b/library/cpp/json/ut/json_writer_ut.cpp
@@ -16,8 +16,8 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) {
TJsonWriter json(&out, false);
json.OpenMap();
json.Write("key1", (ui16)1);
- json.WriteKey("key2");
- json.Write((i32)2);
+ json.WriteKey("key2");
+ json.Write((i32)2);
json.Write("key3", (ui64)3);
UNIT_ASSERT(out.Empty());
diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp
index 465d73bf7f..87d6102ee5 100644
--- a/util/digest/sequence_ut.cpp
+++ b/util/digest/sequence_ut.cpp
@@ -1,7 +1,7 @@
#include "sequence.h"
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/map.h>
+#include <util/generic/map.h>
#include <util/generic/vector.h>
class TRangeHashTest: public TTestBase {
@@ -9,7 +9,7 @@ class TRangeHashTest: public TTestBase {
UNIT_TEST(TestStrokaInt)
UNIT_TEST(TestIntVector)
UNIT_TEST(TestOneElement)
- UNIT_TEST(TestMap);
+ UNIT_TEST(TestMap);
UNIT_TEST(TestCollectionIndependancy);
UNIT_TEST_SUITE_END();
@@ -31,12 +31,12 @@ private:
UNIT_ASSERT_UNEQUAL(THash<int>()(testVal), TRangeHash<>()(testVec));
}
- inline void TestMap() {
- const size_t canonicalHash = static_cast<size_t>(ULL(4415387926488545605));
- TMap<TString, int> testMap{{"foo", 123}, {"bar", 456}};
- UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testMap));
- }
-
+ inline void TestMap() {
+ const size_t canonicalHash = static_cast<size_t>(ULL(4415387926488545605));
+ TMap<TString, int> testMap{{"foo", 123}, {"bar", 456}};
+ UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testMap));
+ }
+
inline void TestCollectionIndependancy() {
TVector<char> testVec = {'a', 'b', 'c'};
TString testStroka = "abc";
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index c94d2e8637..9576467404 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -29,9 +29,9 @@ public:
TBuffer& operator=(TBuffer&& b) noexcept;
TBuffer& operator=(const TBuffer& b) {
- if (this != &b) {
- Assign(b.Data(), b.Size());
- }
+ if (this != &b) {
+ Assign(b.Data(), b.Size());
+ }
return *this;
}
diff --git a/util/generic/flags.h b/util/generic/flags.h
index 4af19104b1..a1f5921d42 100644
--- a/util/generic/flags.h
+++ b/util/generic/flags.h
@@ -39,7 +39,7 @@ public:
using TEnum = Enum;
using TInt = std::underlying_type_t<Enum>;
- constexpr TFlags(std::nullptr_t = 0)
+ constexpr TFlags(std::nullptr_t = 0)
: Value_(0)
{
}
diff --git a/util/str_stl.h b/util/str_stl.h
index f5c9d732ca..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -168,10 +168,10 @@ namespace NHashPrivate {
struct TPairHash<TFirst, TSecond, true> {
template <class T>
inline size_t operator()(const T& pair) const {
- // maps have TFirst = const TFoo, which would make for an undefined specialization
- using TFirstClean = std::remove_cv_t<TFirst>;
- using TSecondClean = std::remove_cv_t<TSecond>;
- return CombineHashes(THash<TFirstClean>()(pair.first), THash<TSecondClean>()(pair.second));
+ // maps have TFirst = const TFoo, which would make for an undefined specialization
+ using TFirstClean = std::remove_cv_t<TFirst>;
+ using TSecondClean = std::remove_cv_t<TSecond>;
+ return CombineHashes(THash<TFirstClean>()(pair.first), THash<TSecondClean>()(pair.second));
}
};
}
diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp
index 9854490add..a00e592e1c 100644
--- a/util/stream/buffered.cpp
+++ b/util/stream/buffered.cpp
@@ -36,32 +36,32 @@ public:
}
inline size_t Skip(size_t len) {
- size_t totalSkipped = 0;
- while (len) {
- const size_t skipped = DoSkip(len);
- if (skipped == 0) {
- break;
- }
-
- totalSkipped += skipped;
- len -= skipped;
+ size_t totalSkipped = 0;
+ while (len) {
+ const size_t skipped = DoSkip(len);
+ if (skipped == 0) {
+ break;
+ }
+
+ totalSkipped += skipped;
+ len -= skipped;
}
-
- return totalSkipped;
+
+ return totalSkipped;
+ }
+
+ inline size_t DoSkip(size_t len) {
+ if (MemInput_.Exhausted()) {
+ if (len > BufLen() / 2) {
+ return Slave_->Skip(len);
+ }
+
+ MemInput_.Reset(Buf(), Slave_->Read(Buf(), BufLen()));
+ }
+
+ return MemInput_.Skip(len);
}
- inline size_t DoSkip(size_t len) {
- if (MemInput_.Exhausted()) {
- if (len > BufLen() / 2) {
- return Slave_->Skip(len);
- }
-
- MemInput_.Reset(Buf(), Slave_->Read(Buf(), BufLen()));
- }
-
- return MemInput_.Skip(len);
- }
-
inline size_t ReadTo(TString& st, char to) {
st.clear();
@@ -122,9 +122,9 @@ TBufferedInput::TBufferedInput(IInputStream* slave, size_t buflen)
{
}
-TBufferedInput::TBufferedInput(TBufferedInput&&) noexcept = default;
-TBufferedInput& TBufferedInput::operator=(TBufferedInput&&) noexcept = default;
-
+TBufferedInput::TBufferedInput(TBufferedInput&&) noexcept = default;
+TBufferedInput& TBufferedInput::operator=(TBufferedInput&&) noexcept = default;
+
TBufferedInput::~TBufferedInput() = default;
size_t TBufferedInput::DoRead(void* buf, size_t len) {
@@ -356,9 +356,9 @@ TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen)
{
}
-TBufferedOutputBase::TBufferedOutputBase(TBufferedOutputBase&&) noexcept = default;
-TBufferedOutputBase& TBufferedOutputBase::operator=(TBufferedOutputBase&&) noexcept = default;
-
+TBufferedOutputBase::TBufferedOutputBase(TBufferedOutputBase&&) noexcept = default;
+TBufferedOutputBase& TBufferedOutputBase::operator=(TBufferedOutputBase&&) noexcept = default;
+
TBufferedOutputBase::~TBufferedOutputBase() {
try {
Finish();
diff --git a/util/stream/buffered.h b/util/stream/buffered.h
index f46318401f..0847186141 100644
--- a/util/stream/buffered.h
+++ b/util/stream/buffered.h
@@ -23,10 +23,10 @@
class TBufferedInput: public IZeroCopyInput {
public:
TBufferedInput(IInputStream* slave, size_t buflen = 8192);
-
- TBufferedInput(TBufferedInput&&) noexcept;
- TBufferedInput& operator=(TBufferedInput&&) noexcept;
-
+
+ TBufferedInput(TBufferedInput&&) noexcept;
+ TBufferedInput& operator=(TBufferedInput&&) noexcept;
+
~TBufferedInput() override;
/**
@@ -79,8 +79,8 @@ public:
*/
TBufferedOutputBase(IOutputStream* slave, size_t buflen);
- TBufferedOutputBase(TBufferedOutputBase&&) noexcept;
- TBufferedOutputBase& operator=(TBufferedOutputBase&&) noexcept;
+ TBufferedOutputBase(TBufferedOutputBase&&) noexcept;
+ TBufferedOutputBase& operator=(TBufferedOutputBase&&) noexcept;
~TBufferedOutputBase() override;
diff --git a/util/string/ascii.cpp b/util/string/ascii.cpp
index c092e29965..95edb95cc8 100644
--- a/util/string/ascii.cpp
+++ b/util/string/ascii.cpp
@@ -7,12 +7,12 @@
extern const unsigned char NPrivate::ASCII_CLASS[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
- 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
- 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x80, 0x80, 0x80, 0x80, 0x00,
+ 0x01, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+ 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+ 0x80, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
+ 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x80, 0x80, 0x80, 0x80, 0x80,
+ 0x80, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x80, 0x80, 0x80, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
diff --git a/util/string/ascii.h b/util/string/ascii.h
index 602938811d..10344384d3 100644
--- a/util/string/ascii.h
+++ b/util/string/ascii.h
@@ -19,8 +19,8 @@ namespace NPrivate {
CC_DIGIT = 8,
CC_ALPHA = 16,
CC_ALNUM = 32,
- CC_ISHEX = 64,
- CC_PUNCT = 128,
+ CC_ISHEX = 64,
+ CC_PUNCT = 128,
};
extern const unsigned char ASCII_CLASS[256];
@@ -92,10 +92,10 @@ inline bool IsAsciiHex(unsigned char c) {
return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_ISHEX;
}
-inline bool IsAsciiPunct(unsigned char c) {
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_PUNCT;
-}
-
+inline bool IsAsciiPunct(unsigned char c) {
+ return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_PUNCT;
+}
+
// some overloads
template <class T>
@@ -133,11 +133,11 @@ inline bool IsAsciiHex(T c) {
return ::NPrivate::RangeOk(c) && IsAsciiHex(static_cast<unsigned char>(c));
}
-template <class T>
-inline bool IsAsciiPunct(T c) {
- return ::NPrivate::RangeOk(c) && IsAsciiPunct(static_cast<unsigned char>(c));
-}
-
+template <class T>
+inline bool IsAsciiPunct(T c) {
+ return ::NPrivate::RangeOk(c) && IsAsciiPunct(static_cast<unsigned char>(c));
+}
+
// some extra helpers
inline ui8 AsciiToLower(ui8 c) noexcept {
return ::NPrivate::ASCII_LOWER[c];
diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp
index 17ac6029d9..89069fee50 100644
--- a/util/string/ascii_ut.cpp
+++ b/util/string/ascii_ut.cpp
@@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
UNIT_ASSERT_VALUES_EQUAL((bool)isupper(i), IsAsciiUpper((char)i));
UNIT_ASSERT_VALUES_EQUAL((bool)islower(i), IsAsciiLower((char)i));
UNIT_ASSERT_VALUES_EQUAL((bool)isdigit(i), IsAsciiDigit((char)i));
- UNIT_ASSERT_VALUES_EQUAL((bool)ispunct(i), IsAsciiPunct((char)i));
+ UNIT_ASSERT_VALUES_EQUAL((bool)ispunct(i), IsAsciiPunct((char)i));
}
}
@@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
UNIT_ASSERT(!IsAsciiUpper(i));
UNIT_ASSERT(!IsAsciiLower(i));
UNIT_ASSERT(!IsAsciiDigit(i));
- UNIT_ASSERT(!IsAsciiPunct(i));
+ UNIT_ASSERT(!IsAsciiPunct(i));
}
for (int i = -1000; i < 0; ++i) {
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
UNIT_ASSERT(!IsAsciiUpper(i));
UNIT_ASSERT(!IsAsciiLower(i));
UNIT_ASSERT(!IsAsciiDigit(i));
- UNIT_ASSERT(!IsAsciiPunct(i));
+ UNIT_ASSERT(!IsAsciiPunct(i));
}
}
diff --git a/util/system/compiler.cpp b/util/system/compiler.cpp
index a44bc4f011..d4b3cca0af 100644
--- a/util/system/compiler.cpp
+++ b/util/system/compiler.cpp
@@ -1,9 +1,9 @@
#include "compiler.h"
-#include <cstdlib>
-
+#include <cstdlib>
+
[[noreturn]] Y_HIDDEN void _YandexAbort() {
- std::abort();
-}
+ std::abort();
+}
void UseCharPointerImpl(volatile const char*) {
}
diff --git a/util/system/compiler.h b/util/system/compiler.h
index 35126830cb..b373edcc46 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -197,83 +197,83 @@ constexpr Y_FORCE_INLINE int Y_UNUSED(Types&&...) {
};
#endif
-/**
- * @def Y_ASSUME
- *
- * Macro that tells the compiler that it can generate optimized code
- * as if the given expression will always evaluate true.
- * The behavior is undefined if it ever evaluates false.
- *
- * @code
- * // factored into a function so that it's testable
- * inline int Avg(int x, int y) {
- * if (x >= 0 && y >= 0) {
- * return (static_cast<unsigned>(x) + static_cast<unsigned>(y)) >> 1;
- * } else {
- * // a slower implementation
- * }
- * }
- *
- * // we know that xs and ys are non-negative from domain knowledge,
- * // but we can't change the types of xs and ys because of API constrains
+/**
+ * @def Y_ASSUME
+ *
+ * Macro that tells the compiler that it can generate optimized code
+ * as if the given expression will always evaluate true.
+ * The behavior is undefined if it ever evaluates false.
+ *
+ * @code
+ * // factored into a function so that it's testable
+ * inline int Avg(int x, int y) {
+ * if (x >= 0 && y >= 0) {
+ * return (static_cast<unsigned>(x) + static_cast<unsigned>(y)) >> 1;
+ * } else {
+ * // a slower implementation
+ * }
+ * }
+ *
+ * // we know that xs and ys are non-negative from domain knowledge,
+ * // but we can't change the types of xs and ys because of API constrains
* int Foo(const TVector<int>& xs, const TVector<int>& ys) {
* TVector<int> avgs;
- * avgs.resize(xs.size());
- * for (size_t i = 0; i < xs.size(); ++i) {
- * auto x = xs[i];
- * auto y = ys[i];
- * Y_ASSUME(x >= 0);
- * Y_ASSUME(y >= 0);
- * xs[i] = Avg(x, y);
- * }
- * }
- * @endcode
- */
-#if defined(__GNUC__)
+ * avgs.resize(xs.size());
+ * for (size_t i = 0; i < xs.size(); ++i) {
+ * auto x = xs[i];
+ * auto y = ys[i];
+ * Y_ASSUME(x >= 0);
+ * Y_ASSUME(y >= 0);
+ * xs[i] = Avg(x, y);
+ * }
+ * }
+ * @endcode
+ */
+#if defined(__GNUC__)
#define Y_ASSUME(condition) ((condition) ? (void)0 : __builtin_unreachable())
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_ASSUME(condition) __assume(condition)
-#else
+#else
#define Y_ASSUME(condition) Y_UNUSED(condition)
-#endif
-
+#endif
+
#ifdef __cplusplus
[[noreturn]]
#endif
Y_HIDDEN void
_YandexAbort();
-
-/**
- * @def Y_UNREACHABLE
- *
- * Macro that marks the rest of the code branch unreachable.
- * The behavior is undefined if it's ever reached.
- *
- * @code
- * switch (i % 3) {
- * case 0:
- * return foo;
- * case 1:
- * return bar;
- * case 2:
- * return baz;
- * default:
- * Y_UNREACHABLE();
- * }
- * @endcode
- */
+
+/**
+ * @def Y_UNREACHABLE
+ *
+ * Macro that marks the rest of the code branch unreachable.
+ * The behavior is undefined if it's ever reached.
+ *
+ * @code
+ * switch (i % 3) {
+ * case 0:
+ * return foo;
+ * case 1:
+ * return bar;
+ * case 2:
+ * return baz;
+ * default:
+ * Y_UNREACHABLE();
+ * }
+ * @endcode
+ */
#if defined(__GNUC__)
#define Y_UNREACHABLE() __builtin_unreachable()
#elif defined(_MSC_VER)
#define Y_UNREACHABLE() __assume(false)
-#else
+#else
#define Y_UNREACHABLE() _YandexAbort()
-#endif
-
+#endif
+
#if defined(undefined_sanitizer_enabled)
#define _ubsan_enabled_
#endif
-
+
#ifdef __clang__
#if __has_feature(thread_sanitizer)