aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorEvgeny Grechnikov <diamondaz@yandex.ru>2022-02-10 16:46:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:20 +0300
commitc73494e681a4e497ae191ada07a55a6bf55885ff (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util
parent6e38f52f898d7c077ddd319800b4014967a5ca76 (diff)
downloadydb-c73494e681a4e497ae191ada07a55a6bf55885ff.tar.gz
Restoring authorship annotation for Evgeny Grechnikov <diamondaz@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/wide.h10
-rw-r--r--util/generic/hash_set.h16
-rw-r--r--util/generic/hash_ut.cpp14
-rw-r--r--util/memory/pool.h4
-rw-r--r--util/memory/pool_ut.cpp26
-rw-r--r--util/random/fast.h8
-rw-r--r--util/random/fast_ut.cpp44
-rw-r--r--util/random/lcg_engine.cpp50
-rw-r--r--util/random/lcg_engine.h26
-rw-r--r--util/stream/format.h68
-rw-r--r--util/stream/format_ut.cpp54
-rw-r--r--util/string/cast.h20
-rw-r--r--util/string/cast_ut.cpp8
-rw-r--r--util/system/env.h4
-rw-r--r--util/system/mem_info.cpp138
-rw-r--r--util/system/mlock.cpp2
-rw-r--r--util/system/thread.i2
17 files changed, 247 insertions, 247 deletions
diff --git a/util/charset/wide.h b/util/charset/wide.h
index 9c163517cf..04e6928aab 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -82,7 +82,7 @@ inline wchar32 ReadSymbol(const wchar16* begin, const wchar16* end) noexcept {
Y_ASSERT(begin < end);
if (IsW16SurrogateLead(*begin)) {
if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1)))
- return ::NDetail::ReadSurrogatePair(begin);
+ return ::NDetail::ReadSurrogatePair(begin);
return BROKEN_RUNE;
} else if (IsW16SurrogateTail(*begin)) {
@@ -103,7 +103,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin) noexcept {
if (IsW16SurrogateLead(begin[0])) {
if (IsW16SurrogateTail(begin[1])) {
Y_ASSERT(begin[1] != 0);
- const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
+ const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
begin += 2;
return c;
}
@@ -126,7 +126,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) n
Y_ASSERT(begin < end);
if (IsW16SurrogateLead(begin[0])) {
if (begin + 1 != end && IsW16SurrogateTail(begin[1])) {
- const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
+ const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
begin += 2;
return c;
}
@@ -157,7 +157,7 @@ inline size_t WriteSymbol(wchar32 s, T& dest) noexcept {
return WriteSymbol(static_cast<wchar16>(BROKEN_RUNE), dest);
}
- ::NDetail::WriteSurrogatePair(s, dest);
+ ::NDetail::WriteSurrogatePair(s, dest);
return 2;
}
@@ -176,7 +176,7 @@ inline bool WriteSymbol(wchar32 s, wchar16*& dest, const wchar16* destEnd) noexc
if (dest + 2 > destEnd)
return false;
- ::NDetail::WriteSurrogatePair(s, dest);
+ ::NDetail::WriteSurrogatePair(s, dest);
} else {
*(dest++) = static_cast<wchar16>(s);
}
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h
index 593d24ff51..e8088cf23b 100644
--- a/util/generic/hash_set.h
+++ b/util/generic/hash_set.h
@@ -161,10 +161,10 @@ public:
return std::pair<iterator, bool>(p.first, p.second);
}
template <typename... Args>
- std::pair<iterator, bool> emplace(Args&&... args) {
- std::pair<mutable_iterator, bool> p = rep.emplace_unique(std::forward<Args>(args)...);
- return std::pair<iterator, bool>(p.first, p.second);
- }
+ std::pair<iterator, bool> emplace(Args&&... args) {
+ std::pair<mutable_iterator, bool> p = rep.emplace_unique(std::forward<Args>(args)...);
+ return std::pair<iterator, bool>(p.first, p.second);
+ }
iterator insert(const_iterator, const value_type& obj) { // insert_hint
std::pair<mutable_iterator, bool> p = rep.insert_unique(obj);
@@ -176,10 +176,10 @@ public:
return std::pair<iterator, bool>(p.first, p.second);
}
template <typename... Args>
- std::pair<iterator, bool> emplace_noresize(Args&&... args) {
- std::pair<mutable_iterator, bool> p = rep.emplace_unique_noresize(std::forward<Args>(args)...);
- return std::pair<iterator, bool>(p.first, p.second);
- }
+ std::pair<iterator, bool> emplace_noresize(Args&&... args) {
+ std::pair<mutable_iterator, bool> p = rep.emplace_unique_noresize(std::forward<Args>(args)...);
+ return std::pair<iterator, bool>(p.first, p.second);
+ }
template <class TheObj>
iterator insert_direct(const TheObj& obj, const insert_ctx& ins) {
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index de3cb3e588..0551d58770 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -45,7 +45,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestHMMapEmplace);
UNIT_TEST(TestHMMapEmplaceNoresize);
UNIT_TEST(TestHMMapEmplaceDirect);
- UNIT_TEST(TestHSetEmplace);
+ UNIT_TEST(TestHSetEmplace);
UNIT_TEST(TestHSetEmplaceNoresize);
UNIT_TEST(TestHSetEmplaceDirect);
UNIT_TEST(TestNonCopyable);
@@ -93,7 +93,7 @@ protected:
void TestEmplaceDirect();
void TestTryEmplace();
void TestTryEmplaceCopyKey();
- void TestHSetEmplace();
+ void TestHSetEmplace();
void TestHSetEmplaceNoresize();
void TestHSetEmplaceDirect();
void TestHMMapEmplace();
@@ -1007,11 +1007,11 @@ void THashTest::TestHMMapEmplaceDirect() {
UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
}
-void THashTest::TestHSetEmplace() {
+void THashTest::TestHSetEmplace() {
using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
hash_t hash;
UNIT_ASSERT(!hash.contains(0));
- hash.emplace(0);
+ hash.emplace(0);
UNIT_ASSERT(hash.contains(0));
UNIT_ASSERT(!hash.contains(1));
}
@@ -1021,11 +1021,11 @@ void THashTest::TestHSetEmplaceNoresize() {
hash_t hash;
hash.reserve(1);
UNIT_ASSERT(!hash.contains(0));
- hash.emplace_noresize(0);
+ hash.emplace_noresize(0);
UNIT_ASSERT(hash.contains(0));
UNIT_ASSERT(!hash.contains(1));
-}
-
+}
+
void THashTest::TestHSetEmplaceDirect() {
using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
hash_t hash;
diff --git a/util/memory/pool.h b/util/memory/pool.h
index cc51e96e70..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -189,8 +189,8 @@ public:
return ptr;
}
- template <typename T, typename... Args>
- inline T* New(Args&&... args) {
+ template <typename T, typename... Args>
+ inline T* New(Args&&... args) {
return new (Allocate<T>()) T(std::forward<Args>(args)...);
}
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index aa4ff9ca6c..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -135,9 +135,9 @@ private:
}
alloc.CheckAtEnd();
-
- struct TConstructorTest {
- int ConstructorType;
+
+ struct TConstructorTest {
+ int ConstructorType;
TConstructorTest()
: ConstructorType(1)
{
@@ -154,19 +154,19 @@ private:
: ConstructorType(4)
{
}
- };
-
- {
- TMemoryPool pool(123, TMemoryPool::TExpGrow::Instance(), &alloc);
+ };
+
+ {
+ TMemoryPool pool(123, TMemoryPool::TExpGrow::Instance(), &alloc);
THolder<TConstructorTest, TDestructor> data1{pool.New<TConstructorTest>()};
THolder<TConstructorTest, TDestructor> data2{pool.New<TConstructorTest>(42)};
THolder<TConstructorTest, TDestructor> data3{pool.New<TConstructorTest>("hello", "world")};
- UNIT_ASSERT_VALUES_EQUAL(data1->ConstructorType, 1);
- UNIT_ASSERT_VALUES_EQUAL(data2->ConstructorType, 2);
- UNIT_ASSERT_VALUES_EQUAL(data3->ConstructorType, 4);
- }
-
- alloc.CheckAtEnd();
+ UNIT_ASSERT_VALUES_EQUAL(data1->ConstructorType, 1);
+ UNIT_ASSERT_VALUES_EQUAL(data2->ConstructorType, 2);
+ UNIT_ASSERT_VALUES_EQUAL(data3->ConstructorType, 4);
+ }
+
+ alloc.CheckAtEnd();
}
inline void TestAlign() {
diff --git a/util/random/fast.h b/util/random/fast.h
index f86b56c625..ddc5711641 100644
--- a/util/random/fast.h
+++ b/util/random/fast.h
@@ -73,10 +73,10 @@ public:
}
inline void Advance(ui64 delta) noexcept {
- R1_.Advance(delta);
- R2_.Advance(delta);
- }
-
+ R1_.Advance(delta);
+ R2_.Advance(delta);
+ }
+
private:
TFastRng32Base R1_;
TFastRng32Base R2_;
diff --git a/util/random/fast_ut.cpp b/util/random/fast_ut.cpp
index a641a30071..60994a98b0 100644
--- a/util/random/fast_ut.cpp
+++ b/util/random/fast_ut.cpp
@@ -42,34 +42,34 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
UNIT_ASSERT_VALUES_EQUAL(rng.Uniform(100u), i);
}
}
-
+
Y_UNIT_TEST(TestAdvance) {
- TReallyFastRng32 rng1(17);
- TReallyFastRng32 rng2(17);
+ TReallyFastRng32 rng1(17);
+ TReallyFastRng32 rng2(17);
for (size_t i = 0; i < 100; i++) {
- rng1.GenRand();
+ rng1.GenRand();
}
- rng2.Advance(100);
- UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng2.GenRand());
-
- TFastRng64 rng3(0, 1, 2, 3);
- TFastRng64 rng4(0, 1, 2, 3);
+ rng2.Advance(100);
+ UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng2.GenRand());
+
+ TFastRng64 rng3(0, 1, 2, 3);
+ TFastRng64 rng4(0, 1, 2, 3);
for (size_t i = 0; i < 100; i++) {
- rng3.GenRand();
+ rng3.GenRand();
}
- rng4.Advance(100);
- UNIT_ASSERT_VALUES_EQUAL(rng3.GenRand(), rng4.GenRand());
- }
-
+ rng4.Advance(100);
+ UNIT_ASSERT_VALUES_EQUAL(rng3.GenRand(), rng4.GenRand());
+ }
+
Y_UNIT_TEST(TestAdvanceBoundaries) {
- TReallyFastRng32 rng1(17);
- TReallyFastRng32 rng2(17);
- TReallyFastRng32 rng3(17);
- rng2.Advance(0);
- rng3.Advance(1);
- UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng2.GenRand());
- UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng3.GenRand());
- }
+ TReallyFastRng32 rng1(17);
+ TReallyFastRng32 rng2(17);
+ TReallyFastRng32 rng3(17);
+ rng2.Advance(0);
+ rng3.Advance(1);
+ UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng2.GenRand());
+ UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng3.GenRand());
+ }
Y_UNIT_TEST(TestCopy) {
TReallyFastRng32 r1(1);
diff --git a/util/random/lcg_engine.cpp b/util/random/lcg_engine.cpp
index e875705bcf..e1469104fa 100644
--- a/util/random/lcg_engine.cpp
+++ b/util/random/lcg_engine.cpp
@@ -1,30 +1,30 @@
#include "lcg_engine.h"
-
-namespace NPrivate {
- template <typename T>
+
+namespace NPrivate {
+ template <typename T>
T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept {
- // seed[n+1] = A * seed[n] + B, A = lcgBase, B = lcgAddend
- // seed[n] = A**n * seed[0] + (A**n - 1) / (A - 1) * B
- // (initial value of n) = m * 2**k + (lower bits of n)
- T mask = 1;
- while (mask != (1ULL << (8 * sizeof(T) - 1)) && (mask << 1) <= delta) {
- mask <<= 1;
- }
- T apow = 1; // A**m
- T adiv = 0; // (A**m-1)/(A-1)
- for (; mask; mask >>= 1) {
- // m *= 2
- adiv *= apow + 1;
- apow *= apow;
- if (delta & mask) {
- // m++
- adiv += apow;
- apow *= lcgBase;
- }
- }
- return seed * apow + lcgAddend * adiv;
- }
-
+ // seed[n+1] = A * seed[n] + B, A = lcgBase, B = lcgAddend
+ // seed[n] = A**n * seed[0] + (A**n - 1) / (A - 1) * B
+ // (initial value of n) = m * 2**k + (lower bits of n)
+ T mask = 1;
+ while (mask != (1ULL << (8 * sizeof(T) - 1)) && (mask << 1) <= delta) {
+ mask <<= 1;
+ }
+ T apow = 1; // A**m
+ T adiv = 0; // (A**m-1)/(A-1)
+ for (; mask; mask >>= 1) {
+ // m *= 2
+ adiv *= apow + 1;
+ apow *= apow;
+ if (delta & mask) {
+ // m++
+ adiv += apow;
+ apow *= lcgBase;
+ }
+ }
+ return seed * apow + lcgAddend * adiv;
+ }
+
template ui32 LcgAdvance<ui32>(ui32, ui32, ui32, ui32) noexcept;
template ui64 LcgAdvance<ui64>(ui64, ui64, ui64, ui64) noexcept;
}
diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h
index 0de277cb66..08cc93c845 100644
--- a/util/random/lcg_engine.h
+++ b/util/random/lcg_engine.h
@@ -6,11 +6,11 @@
// common engine for lcg-based RNG's
// http://en.wikipedia.org/wiki/Linear_congruential_generator
-namespace NPrivate {
- template <typename T>
+namespace NPrivate {
+ template <typename T>
T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept;
-};
-
+};
+
template <typename T, T A, T C>
struct TFastLcgIterator {
static_assert(C % 2 == 1, "C must be odd");
@@ -18,10 +18,10 @@ struct TFastLcgIterator {
static constexpr T Iterate(T x) noexcept {
return x * A + C;
}
-
+
static inline T IterateMultiple(T x, T delta) noexcept {
- return ::NPrivate::LcgAdvance(x, A, C, delta);
- }
+ return ::NPrivate::LcgAdvance(x, A, C, delta);
+ }
};
template <typename T, T A>
@@ -36,9 +36,9 @@ struct TLcgIterator {
}
inline T IterateMultiple(T x, T delta) noexcept {
- return ::NPrivate::LcgAdvance(x, A, C, delta);
- }
-
+ return ::NPrivate::LcgAdvance(x, A, C, delta);
+ }
+
const T C;
};
@@ -59,8 +59,8 @@ struct TLcgRngBase: public TIterator, public TMixer {
}
inline void Advance(TStateType delta) noexcept {
- X = this->IterateMultiple(X, delta);
- }
-
+ X = this->IterateMultiple(X, delta);
+ }
+
TStateType X;
};
diff --git a/util/stream/format.h b/util/stream/format.h
index 057d5de71c..b033208a1b 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -38,11 +38,11 @@ namespace NFormatPrivate {
template <typename T>
struct TLeftPad {
- T Value;
+ T Value;
size_t Width;
char Padc;
- inline TLeftPad(const T& value, size_t width, char padc)
+ inline TLeftPad(const T& value, size_t width, char padc)
: Value(value)
, Width(width)
, Padc(padc)
@@ -54,7 +54,7 @@ namespace NFormatPrivate {
IOutputStream& operator<<(IOutputStream& o, const TLeftPad<T>& lp) {
TTempBuf buf;
TMemoryOutput ss(buf.Data(), buf.Size());
- ss << lp.Value;
+ ss << lp.Value;
size_t written = buf.Size() - ss.Avail();
if (lp.Width > written) {
WriteChars(o, lp.Padc, lp.Width - written);
@@ -65,11 +65,11 @@ namespace NFormatPrivate {
template <typename T>
struct TRightPad {
- T Value;
+ T Value;
size_t Width;
char Padc;
- inline TRightPad(const T& value, size_t width, char padc)
+ inline TRightPad(const T& value, size_t width, char padc)
: Value(value)
, Width(width)
, Padc(padc)
@@ -81,7 +81,7 @@ namespace NFormatPrivate {
IOutputStream& operator<<(IOutputStream& o, const TRightPad<T>& lp) {
TTempBuf buf;
TMemoryOutput ss(buf.Data(), buf.Size());
- ss << lp.Value;
+ ss << lp.Value;
size_t written = buf.Size() - ss.Avail();
o.Write(buf.Data(), written);
if (lp.Width > written) {
@@ -152,24 +152,24 @@ namespace NFormatPrivate {
}
return os;
}
-
+
template <typename T>
- struct TFloatPrecision {
+ struct TFloatPrecision {
using TdVal = std::remove_cv_t<T>;
static_assert(std::is_floating_point<TdVal>::value, "expect std::is_floating_point<TdVal>::value");
-
- TdVal Value;
- EFloatToStringMode Mode;
- int NDigits;
- };
-
+
+ TdVal Value;
+ EFloatToStringMode Mode;
+ int NDigits;
+ };
+
template <typename T>
IOutputStream& operator<<(IOutputStream& o, const TFloatPrecision<T>& prec) {
- char buf[512];
- size_t count = FloatToString(prec.Value, buf, sizeof(buf), prec.Mode, prec.NDigits);
- o << TStringBuf(buf, count);
- return o;
- }
+ char buf[512];
+ size_t count = FloatToString(prec.Value, buf, sizeof(buf), prec.Mode, prec.NDigits);
+ o << TStringBuf(buf, count);
+ return o;
+ }
struct THumanReadableDuration {
TDuration Value;
@@ -205,14 +205,14 @@ namespace NFormatPrivate {
*/
template <typename T>
static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept {
- return ::NFormatPrivate::TLeftPad<T>(value, width, padc);
+ return ::NFormatPrivate::TLeftPad<T>(value, width, padc);
}
template <typename T, int N>
static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N], const size_t width, const char padc = ' ') noexcept {
- return ::NFormatPrivate::TLeftPad<const T*>(value, width, padc);
-}
-
+ return ::NFormatPrivate::TLeftPad<const T*>(value, width, padc);
+}
+
/**
* Output manipulator similar to `std::setw` and `std::setfill`.
*
@@ -231,14 +231,14 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N
*/
template <typename T>
static constexpr ::NFormatPrivate::TRightPad<T> RightPad(const T& value, const size_t width, const char padc = ' ') noexcept {
- return ::NFormatPrivate::TRightPad<T>(value, width, padc);
+ return ::NFormatPrivate::TRightPad<T>(value, width, padc);
}
template <typename T, int N>
static constexpr ::NFormatPrivate::TRightPad<const T*> RightPad(const T (&value)[N], const size_t width, const char padc = ' ') noexcept {
- return ::NFormatPrivate::TRightPad<const T*>(value, width, padc);
-}
-
+ return ::NFormatPrivate::TRightPad<const T*>(value, width, padc);
+}
+
/**
* Output manipulator similar to `std::setbase(16)`.
*
@@ -402,7 +402,7 @@ static constexpr ::NFormatPrivate::THumanReadableSize HumanReadableSize(const do
void Time(IOutputStream& l);
void TimeHumanReadable(IOutputStream& l);
-
+
/**
* Output manipulator for adjusting precision of floating point values.
*
@@ -419,11 +419,11 @@ void TimeHumanReadable(IOutputStream& l);
* @param ndigits Number of significant digits (in `PREC_NDIGITS` and `PREC_POINT_DIGITS` mode).
* @see EFloatToStringMode
*/
-template <typename T>
+template <typename T>
static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const EFloatToStringMode mode, const int ndigits = 0) noexcept {
- return {value, mode, ndigits};
-}
-
+ return {value, mode, ndigits};
+}
+
/**
* Output manipulator for adjusting precision of floating point values.
*
@@ -440,5 +440,5 @@ static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const
*/
template <typename T>
static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const int ndigits) noexcept {
- return {value, PREC_NDIGITS, ndigits};
-}
+ return {value, PREC_NDIGITS, ndigits};
+}
diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp
index b58052e319..43245aeb48 100644
--- a/util/stream/format_ut.cpp
+++ b/util/stream/format_ut.cpp
@@ -30,21 +30,21 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
ss << "[" << Time << "] "
<< "qwqw" << TimeHumanReadable << Endl;
}
-
+
Y_UNIT_TEST(TestHexReference) {
- /*
- One possible implementation of Hex() stores a reference to the given object.
- This can lead to wrong results if the given object is a temporary
- which is valid only during constructor call. The following code tries to
- demonstrate this. If the implementation stores a reference,
- the test fails if compiled with g++44 in debug build
- (without optimizations), but performs correctly in release build.
- */
- THolder<TStringStream> ss(new TStringStream);
- THolder<int> ii(new int(0x1234567));
- (*ss) << Hex(*ii);
- UNIT_ASSERT_VALUES_EQUAL("0x01234567", ss->Str());
- }
+ /*
+ One possible implementation of Hex() stores a reference to the given object.
+ This can lead to wrong results if the given object is a temporary
+ which is valid only during constructor call. The following code tries to
+ demonstrate this. If the implementation stores a reference,
+ the test fails if compiled with g++44 in debug build
+ (without optimizations), but performs correctly in release build.
+ */
+ THolder<TStringStream> ss(new TStringStream);
+ THolder<int> ii(new int(0x1234567));
+ (*ss) << Hex(*ii);
+ UNIT_ASSERT_VALUES_EQUAL("0x01234567", ss->Str());
+ }
Y_UNIT_TEST(TestHexText) {
{
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL("0061 0062 0063 0438", ss.Str());
}
}
-
+
Y_UNIT_TEST(TestBin) {
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(2), nullptr)), "10");
UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2), nullptr)), "-10");
@@ -82,18 +82,18 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
}
Y_UNIT_TEST(TestPrec) {
- TStringStream ss;
- ss << Prec(1.2345678901234567, PREC_AUTO);
- UNIT_ASSERT_VALUES_EQUAL("1.2345678901234567", ss.Str());
-
- ss.Clear();
- ss << Prec(1.2345678901234567, 3);
- UNIT_ASSERT_VALUES_EQUAL("1.23", ss.Str());
-
- ss.Clear();
- ss << Prec(1.2345678901234567, PREC_POINT_DIGITS, 3);
- UNIT_ASSERT_VALUES_EQUAL("1.235", ss.Str());
- }
+ TStringStream ss;
+ ss << Prec(1.2345678901234567, PREC_AUTO);
+ UNIT_ASSERT_VALUES_EQUAL("1.2345678901234567", ss.Str());
+
+ ss.Clear();
+ ss << Prec(1.2345678901234567, 3);
+ UNIT_ASSERT_VALUES_EQUAL("1.23", ss.Str());
+
+ ss.Clear();
+ ss << Prec(1.2345678901234567, PREC_POINT_DIGITS, 3);
+ UNIT_ASSERT_VALUES_EQUAL("1.235", ss.Str());
+ }
Y_UNIT_TEST(TestHumanReadableSize1000) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_QUANTITY)), "0");
diff --git a/util/string/cast.h b/util/string/cast.h
index f5ef2aa184..90e925c194 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -29,7 +29,7 @@ inline size_t ToString(const T& t, char* buf, size_t len) {
/**
* Floating point to string conversion mode, values are enforced by `dtoa_impl.cpp`.
*/
-enum EFloatToStringMode {
+enum EFloatToStringMode {
/** 0.1f -> "0.1", 0.12345678f -> "0.12345678", ignores ndigits. */
PREC_AUTO = 0,
@@ -44,18 +44,18 @@ enum EFloatToStringMode {
/** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
* 0.1f for ndgigits=6 -> "0.1" */
PREC_POINT_DIGITS_STRIP_ZEROES = 4
-};
-
-size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
-size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
-
+};
+
+size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
+size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
+
template <typename T>
inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
- char buf[512]; // Max<double>() with mode = PREC_POINT_DIGITS has 309 digits before the decimal point
- size_t count = FloatToString(t, buf, sizeof(buf), mode, ndigits);
+ char buf[512]; // Max<double>() with mode = PREC_POINT_DIGITS has 309 digits before the decimal point
+ size_t count = FloatToString(t, buf, sizeof(buf), mode, ndigits);
return TString(buf, count);
-}
-
+}
+
namespace NPrivate {
template <class T, bool isSimple>
struct TToString {
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 44905181b9..033450c38c 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -253,11 +253,11 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
Y_UNIT_TEST(TestFloats) {
- // "%g" mode
+ // "%g" mode
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_NDIGITS, 6), "0.1"); // drop trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_NDIGITS, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_NDIGITS, 6), "1e-20");
- // "%f" mode
+ // "%f" mode
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_POINT_DIGITS, 6), "0.100000");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_POINT_DIGITS, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS, 6), "0.000000");
@@ -268,13 +268,13 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(12.34f, PREC_POINT_DIGITS_STRIP_ZEROES, 0), "12"); // rounding to integers drops '.'
UNIT_ASSERT_VALUES_EQUAL(FloatToString(10000.0f, PREC_POINT_DIGITS_STRIP_ZEROES, 0), "10000");
- // automatic selection of ndigits
+ // automatic selection of ndigits
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f), "0.1"); // drop trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f), "0.12345678"); // 8 valid digits
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1000.00006f), "1000.00006"); // 9 valid digits
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-45f), "1e-45"); // denormalized: 1 valid digit
UNIT_ASSERT_VALUES_EQUAL(FloatToString(-0.0f), "-0"); // sign must be preserved
- // version for double
+ // version for double
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1.0 / 10000), "0.0001"); // trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1.2345678901234567), "1.2345678901234567"); // no truncation
UNIT_ASSERT_VALUES_EQUAL(FloatToString(5e-324), "5e-324"); // denormalized
diff --git a/util/system/env.h b/util/system/env.h
index d7313d4944..e2ccdd1e95 100644
--- a/util/system/env.h
+++ b/util/system/env.h
@@ -11,7 +11,7 @@
* @return String that is associated with the matched environment variable or empty string if
* such variable is missing.
*
- * @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour
+ * @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour
* otherwise.
* @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
* @see SetEnv
@@ -24,7 +24,7 @@ TString GetEnv(const TString& key, const TString& def = TString());
* @key String identifying the name of the environment variable to set or change
* @value Value to assign
- * @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour
+ * @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour
* otherwise.
* @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
* @see GetEnv
diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp
index 8a39a27393..aa51ae3b16 100644
--- a/util/system/mem_info.cpp
+++ b/util/system/mem_info.cpp
@@ -21,79 +21,79 @@
#elif defined(__MACH__) && defined(__APPLE__)
#include <mach/mach.h>
#endif
-#elif defined(_win_)
+#elif defined(_win_)
#include <Windows.h>
#include <util/generic/ptr.h>
-
+
using NTSTATUS = LONG;
#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
#define STATUS_BUFFER_TOO_SMALL 0xC0000023
-
-typedef struct _UNICODE_STRING {
- USHORT Length;
- USHORT MaximumLength;
- PWSTR Buffer;
-} UNICODE_STRING, *PUNICODE_STRING;
+
+typedef struct _UNICODE_STRING {
+ USHORT Length;
+ USHORT MaximumLength;
+ PWSTR Buffer;
+} UNICODE_STRING, *PUNICODE_STRING;
typedef struct _CLIENT_ID {
- HANDLE UniqueProcess;
- HANDLE UniqueThread;
-} CLIENT_ID, *PCLIENT_ID;
+ HANDLE UniqueProcess;
+ HANDLE UniqueThread;
+} CLIENT_ID, *PCLIENT_ID;
using KWAIT_REASON = ULONG;
typedef struct _SYSTEM_THREAD_INFORMATION {
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER CreateTime;
- ULONG WaitTime;
- PVOID StartAddress;
- CLIENT_ID ClientId;
- LONG Priority;
- LONG BasePriority;
- ULONG ContextSwitches;
- ULONG ThreadState;
- KWAIT_REASON WaitReason;
-} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
+ LARGE_INTEGER KernelTime;
+ LARGE_INTEGER UserTime;
+ LARGE_INTEGER CreateTime;
+ ULONG WaitTime;
+ PVOID StartAddress;
+ CLIENT_ID ClientId;
+ LONG Priority;
+ LONG BasePriority;
+ ULONG ContextSwitches;
+ ULONG ThreadState;
+ KWAIT_REASON WaitReason;
+} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
typedef struct _SYSTEM_PROCESS_INFORMATION {
- ULONG NextEntryOffset;
- ULONG NumberOfThreads;
- LARGE_INTEGER SpareLi1;
- LARGE_INTEGER SpareLi2;
- LARGE_INTEGER SpareLi3;
- LARGE_INTEGER CreateTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER KernelTime;
- UNICODE_STRING ImageName;
- LONG BasePriority;
- HANDLE UniqueProcessId;
- HANDLE InheritedFromUniqueProcessId;
- ULONG HandleCount;
- ULONG SessionId;
- ULONG_PTR PageDirectoryBase;
- SIZE_T PeakVirtualSize;
- SIZE_T VirtualSize;
- DWORD PageFaultCount;
- SIZE_T PeakWorkingSetSize;
- SIZE_T WorkingSetSize;
- SIZE_T QuotaPeakPagedPoolUsage;
- SIZE_T QuotaPagedPoolUsage;
- SIZE_T QuotaPeakNonPagedPoolUsage;
- SIZE_T QuotaNonPagedPoolUsage;
- SIZE_T PagefileUsage;
- SIZE_T PeakPagefileUsage;
- SIZE_T PrivatePageCount;
- LARGE_INTEGER ReadOperationCount;
- LARGE_INTEGER WriteOperationCount;
- LARGE_INTEGER OtherOperationCount;
- LARGE_INTEGER ReadTransferCount;
- LARGE_INTEGER WriteTransferCount;
- LARGE_INTEGER OtherTransferCount;
- SYSTEM_THREAD_INFORMATION Threads[1];
-} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
-
-typedef enum _SYSTEM_INFORMATION_CLASS {
- SystemBasicInformation = 0,
- SystemProcessInformation = 5,
-} SYSTEM_INFORMATION_CLASS;
-
+ ULONG NextEntryOffset;
+ ULONG NumberOfThreads;
+ LARGE_INTEGER SpareLi1;
+ LARGE_INTEGER SpareLi2;
+ LARGE_INTEGER SpareLi3;
+ LARGE_INTEGER CreateTime;
+ LARGE_INTEGER UserTime;
+ LARGE_INTEGER KernelTime;
+ UNICODE_STRING ImageName;
+ LONG BasePriority;
+ HANDLE UniqueProcessId;
+ HANDLE InheritedFromUniqueProcessId;
+ ULONG HandleCount;
+ ULONG SessionId;
+ ULONG_PTR PageDirectoryBase;
+ SIZE_T PeakVirtualSize;
+ SIZE_T VirtualSize;
+ DWORD PageFaultCount;
+ SIZE_T PeakWorkingSetSize;
+ SIZE_T WorkingSetSize;
+ SIZE_T QuotaPeakPagedPoolUsage;
+ SIZE_T QuotaPagedPoolUsage;
+ SIZE_T QuotaPeakNonPagedPoolUsage;
+ SIZE_T QuotaNonPagedPoolUsage;
+ SIZE_T PagefileUsage;
+ SIZE_T PeakPagefileUsage;
+ SIZE_T PrivatePageCount;
+ LARGE_INTEGER ReadOperationCount;
+ LARGE_INTEGER WriteOperationCount;
+ LARGE_INTEGER OtherOperationCount;
+ LARGE_INTEGER ReadTransferCount;
+ LARGE_INTEGER WriteTransferCount;
+ LARGE_INTEGER OtherTransferCount;
+ SYSTEM_THREAD_INFORMATION Threads[1];
+} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
+
+typedef enum _SYSTEM_INFORMATION_CLASS {
+ SystemBasicInformation = 0,
+ SystemProcessInformation = 5,
+} SYSTEM_INFORMATION_CLASS;
+
#else
#endif
@@ -173,15 +173,15 @@ namespace NMemInfo {
Y_UNUSED(pid);
ythrow yexception() << "arm is not supported";
#endif
-#elif defined(_win_)
+#elif defined(_win_)
if (!pid) {
pid = GetCurrentProcessId();
}
-
+
NTSTATUS status;
TArrayHolder<char> buffer;
ULONG bufferSize;
-
+
// Query data for all processes and threads in the system.
// This is probably an overkill if the target process is normal not-privileged one,
// but allows to obtain information even about system processes that are not open-able directly.
@@ -201,7 +201,7 @@ namespace NMemInfo {
ythrow yexception() << "NtQuerySystemInformation failed with status code " << status;
}
}
-
+
SYSTEM_PROCESS_INFORMATION* process = (SYSTEM_PROCESS_INFORMATION*)buffer.Get();
while (process->UniqueProcessId != (HANDLE)(size_t)(pid)) {
if (!process->NextEntryOffset) {
@@ -210,7 +210,7 @@ namespace NMemInfo {
process = (SYSTEM_PROCESS_INFORMATION*)((char*)process + process->NextEntryOffset);
}
-
+
result.VMS = process->VirtualSize;
result.RSS = process->WorkingSetSize;
#endif
diff --git a/util/system/mlock.cpp b/util/system/mlock.cpp
index 2431ef73db..435338c98f 100644
--- a/util/system/mlock.cpp
+++ b/util/system/mlock.cpp
@@ -21,7 +21,7 @@ void LockMemory(const void* addr, size_t len) {
#if defined(_unix_)
const size_t pageSize = NSystemInfo::GetPageSize();
if (mlock(AlignDown(addr, pageSize), AlignUp(len, pageSize))) {
- ythrow yexception() << LastSystemErrorText();
+ ythrow yexception() << LastSystemErrorText();
}
#elif defined(_win_)
HANDLE hndl = GetCurrentProcess();
diff --git a/util/system/thread.i b/util/system/thread.i
index e93a3f4d62..8cba505473 100644
--- a/util/system/thread.i
+++ b/util/system/thread.i
@@ -3,7 +3,7 @@
#include "platform.h"
#if defined(_win_)
- #include "winint.h"
+ #include "winint.h"
#include <process.h>
typedef HANDLE THREADHANDLE;