diff options
author | risenberg <risenberg@yandex-team.ru> | 2022-02-10 16:49:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:48 +0300 |
commit | 99ac40630808727955ac0448822228528f1ea92d (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library | |
parent | ec551e975caf33bd88e2803b55464cad608e2441 (diff) | |
download | ydb-99ac40630808727955ac0448822228528f1ea92d.tar.gz |
Restoring authorship annotation for <risenberg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/containers/comptrie/chunked_helpers_trie.h | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.h | 4 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.inl | 12 | ||||
-rw-r--r-- | library/cpp/getopt/small/opt.cpp | 2 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 6 | ||||
-rw-r--r-- | library/cpp/lfalloc/lf_allocX64.h | 10 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size.cpp | 46 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size.h | 16 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size_ut.cpp | 38 |
9 files changed, 68 insertions, 68 deletions
diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cb6d7dd8f3..cfa35f5ba2 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -166,7 +166,7 @@ public: void Save(IOutputStream& out, bool minimize = false) const { if (minimize) { - CompactTrieMinimize<TBuilder>(out, Builder, false); + CompactTrieMinimize<TBuilder>(out, Builder, false); } else { Builder.Save(out); } diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index 5754b3e70b..cf7d2e39a3 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -120,9 +120,9 @@ protected: template <class TPacker> size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); -template <class TTrieBuilder> +template <class TTrieBuilder> size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); - + //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. // The trie becomes about 2% larger, but the access became about 25% faster in our experiments. diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index 3f0ba675a4..f273fa6571 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -1065,13 +1065,13 @@ size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalengt using namespace NCompactTrie; return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); } - -template <class TTrieBuilder> + +template <class TTrieBuilder> size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { - TBufferStream buftmp; - size_t len = builder.Save(buftmp); - return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); -} + TBufferStream buftmp; + size_t len = builder.Save(buftmp); + return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); +} //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 819cbc3633..744501765c 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -20,7 +20,7 @@ void Opt::Init(int argc, char* argv[], const char* optString, const Ion* longOpt Ions_ = longOptions; Err = true; GotError_ = false; - Ind = argc; + Ind = argc; Opts_.Reset(new TOptsNoDefault(optString)); for (const Ion* o = longOptions; o != nullptr && o->name != nullptr; ++o) { diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 11bbc9abd4..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -409,16 +409,16 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { r += "<html>Hello</html>"; TStringInput stringInput(r); THttpInput input(&stringInput); - + const THttpHeaders& httpHeaders = input.Headers(); UNIT_ASSERT_VALUES_EQUAL(httpHeaders.Count(), 3u); - + THttpHeaders::TConstIterator it = httpHeaders.Begin(); UNIT_ASSERT_VALUES_EQUAL(it->ToString(), TString(headerLine1)); UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString::Join(headerLine2, headerLine3)); UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4)); } - + Y_UNIT_TEST(ContentLengthRemoval) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); THttpInput i(&request); diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index cb9dfe2f1d..fd2a906d6f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -300,14 +300,14 @@ enum EMMapMode { MM_NORMAL, // memory for small allocs MM_HUGE // memory for large allocs }; - + #ifndef _MSC_VER -inline void VerifyMmapResult(void* result) { +inline void VerifyMmapResult(void* result) { if (Y_UNLIKELY(result == MAP_FAILED)) NMalloc::AbortFromCorruptedAllocator("negative size requested? or just out of mem"); -} +} #endif - + #if !defined(_MSC_VER) && !defined(_freebsd_) && defined(_64_) static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { char* volatile* areaPtr; @@ -349,7 +349,7 @@ static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { continue; char* largeBlock = (char*)mmap(prevAllocPtr, sz, mapProt, mapFlags, -1, 0); - VerifyMmapResult(largeBlock); + VerifyMmapResult(largeBlock); if (largeBlock == prevAllocPtr) return largeBlock; if (largeBlock) diff --git a/library/cpp/string_utils/parse_size/parse_size.cpp b/library/cpp/string_utils/parse_size/parse_size.cpp index a2ed797b36..39188d560b 100644 --- a/library/cpp/string_utils/parse_size/parse_size.cpp +++ b/library/cpp/string_utils/parse_size/parse_size.cpp @@ -3,36 +3,36 @@ #include <util/generic/yexception.h> #include <util/generic/ylimits.h> #include <util/string/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> -namespace { +namespace { enum ESuffixShifts { ESS_KILO_BYTES = 10, ESS_MEGA_BYTES = 20, ESS_GIGA_BYTES = 30, ESS_TERA_BYTES = 40, }; - + bool TryShiftValue(ui64& value, ui64 shift) { if (value > (Max<ui64>() >> shift)) { return false; } - + value <<= shift; return true; - } - + } + ui64 ShiftValue(ui64 value, ui64 shift) { if (!TryShiftValue(value, shift)) { ythrow yexception() << "value overflow '" << value << " << " << shift << "'"; } else { return value; } - } - -} - -namespace NSize { + } + +} + +namespace NSize { ui64 ParseSize(TStringBuf str) { if (! str.size()) ythrow yexception() << "Wrong size " << str; @@ -56,7 +56,7 @@ namespace NSize { default: ythrow yexception() << "Unknown suffix " << str; } - + ui64 value = FromString<ui64>(str.substr(0, str.size() - 1)); if (!TryShiftValue(value, shift)) { @@ -77,19 +77,19 @@ namespace NSize { TSize FromGigaBytes(ui64 value) { return TSize(ShiftValue(value, ESS_GIGA_BYTES)); } - + TSize FromTeraBytes(ui64 value) { return TSize(ShiftValue(value, ESS_TERA_BYTES)); } - -} - + +} + +template <> +NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { + return NSize::TSize(NSize::ParseSize(TStringBuf(data, len))); +} + template <> -NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { - return NSize::TSize(NSize::ParseSize(TStringBuf(data, len))); -} - -template <> void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { - os << size.GetValue(); -} + os << size.GetValue(); +} diff --git a/library/cpp/string_utils/parse_size/parse_size.h b/library/cpp/string_utils/parse_size/parse_size.h index 61db957b12..ad235ef02f 100644 --- a/library/cpp/string_utils/parse_size/parse_size.h +++ b/library/cpp/string_utils/parse_size/parse_size.h @@ -2,9 +2,9 @@ #include <util/generic/strbuf.h> -namespace NSize { +namespace NSize { ui64 ParseSize(TStringBuf size); - + // Convenient disk size representation with string parsing and integer comparison class TSize { public: @@ -12,22 +12,22 @@ namespace NSize { : Value(value) { } - + ui64 GetValue() const { return Value; } - + operator ui64() const { return Value; } - + private: ui64 Value; }; - + TSize FromKiloBytes(ui64 value); TSize FromMegaBytes(ui64 value); TSize FromGigaBytes(ui64 value); TSize FromTeraBytes(ui64 value); - -} + +} diff --git a/library/cpp/string_utils/parse_size/parse_size_ut.cpp b/library/cpp/string_utils/parse_size/parse_size_ut.cpp index 7aae60f9d5..8fff4f56b2 100644 --- a/library/cpp/string_utils/parse_size/parse_size_ut.cpp +++ b/library/cpp/string_utils/parse_size/parse_size_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -using namespace NSize; - +using namespace NSize; + class TParseSizeTest: public TTestBase { UNIT_TEST_SUITE(TParseSizeTest); @@ -12,9 +12,9 @@ class TParseSizeTest: public TTestBase { UNIT_TEST(TestMegaBytes); UNIT_TEST(TestGigaBytes); UNIT_TEST(TestTeraBytes); - UNIT_TEST(TestOverflow); - UNIT_TEST(TestStaticCreators); - UNIT_TEST(TestToString); + UNIT_TEST(TestOverflow); + UNIT_TEST(TestStaticCreators); + UNIT_TEST(TestToString); UNIT_TEST_SUITE_END(); @@ -43,21 +43,21 @@ private: UNIT_ASSERT(ParseSize("10t") == 1024ul * 1024ul * 1024ul * 1024ul * 10ul); } - void TestStaticCreators() { - UNIT_ASSERT_EQUAL(FromKiloBytes(10), 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromMegaBytes(10), 1024ul * 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromGigaBytes(10), 1024ul * 1024ul * 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromTeraBytes(10), 1024ul * 1024ul * 1024ul * 1024ul * 10ul); - } - - void TestOverflow() { - UNIT_ASSERT_EXCEPTION(ParseSize("20000000000G"), yexception); - UNIT_ASSERT_EXCEPTION(FromGigaBytes(20000000000ull), yexception); - } - - void TestToString() { + void TestStaticCreators() { + UNIT_ASSERT_EQUAL(FromKiloBytes(10), 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromMegaBytes(10), 1024ul * 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromGigaBytes(10), 1024ul * 1024ul * 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromTeraBytes(10), 1024ul * 1024ul * 1024ul * 1024ul * 10ul); + } + + void TestOverflow() { + UNIT_ASSERT_EXCEPTION(ParseSize("20000000000G"), yexception); + UNIT_ASSERT_EXCEPTION(FromGigaBytes(20000000000ull), yexception); + } + + void TestToString() { UNIT_ASSERT_VALUES_EQUAL(ToString(FromKiloBytes(1)), TString("1024")); - } + } }; UNIT_TEST_SUITE_REGISTRATION(TParseSizeTest); |