diff options
author | qkrorlqr <qkrorlqr@yandex-team.ru> | 2022-02-10 16:47:21 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:21 +0300 |
commit | eec632e483ae34bc211138c67434b1e0e6054ced (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /library | |
parent | 9b89266638b10d40309e31dcb7caa2fc52b2aefd (diff) | |
download | ydb-eec632e483ae34bc211138c67434b1e0e6054ced.tar.gz |
Restoring authorship annotation for <qkrorlqr@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
23 files changed, 332 insertions, 332 deletions
diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp index 791067bed9..5f63b5af58 100644 --- a/library/cpp/actors/core/log.cpp +++ b/library/cpp/actors/core/log.cpp @@ -13,25 +13,25 @@ static_assert(int(NActors::NLog::PRI_INFO) == int(::TLOG_INFO), "expect int(NAct static_assert(int(NActors::NLog::PRI_DEBUG) == int(::TLOG_DEBUG), "expect int(NActors::NLog::PRI_DEBUG) == int(::TLOG_DEBUG)"); static_assert(int(NActors::NLog::PRI_TRACE) == int(::TLOG_RESOURCES), "expect int(NActors::NLog::PRI_TRACE) == int(::TLOG_RESOURCES)"); -namespace { - struct TRecordWithNewline { - ELogPriority Priority; - TTempBuf Buf; - - TRecordWithNewline(const TLogRecord& rec) - : Priority(rec.Priority) - , Buf(rec.Len + 1) - { - Buf.Append(rec.Data, rec.Len); - *Buf.Proceed(1) = '\n'; - } - - operator TLogRecord() const { - return TLogRecord(Priority, Buf.Data(), Buf.Filled()); - } - }; -} - +namespace { + struct TRecordWithNewline { + ELogPriority Priority; + TTempBuf Buf; + + TRecordWithNewline(const TLogRecord& rec) + : Priority(rec.Priority) + , Buf(rec.Len + 1) + { + Buf.Append(rec.Data, rec.Len); + *Buf.Proceed(1) = '\n'; + } + + operator TLogRecord() const { + return TLogRecord(Priority, Buf.Data(), Buf.Filled()); + } + }; +} + namespace NActors { class TLoggerCounters : public ILoggerMetrics { @@ -685,8 +685,8 @@ namespace NActors { bool isOk = false; do { try { - TRecordWithNewline r(rec); - Cerr.Write(r.Buf.Data(), r.Buf.Filled()); + TRecordWithNewline r(rec); + Cerr.Write(r.Buf.Data(), r.Buf.Filled()); isOk = true; } catch (TSystemError err) { // Interrupted system call @@ -711,7 +711,7 @@ namespace NActors { // Append newline after every record void WriteData(const TLogRecord& rec) override { - TFileLogBackend::WriteData(TRecordWithNewline(rec)); + TFileLogBackend::WriteData(TRecordWithNewline(rec)); } }; diff --git a/library/cpp/charset/wide.h b/library/cpp/charset/wide.h index 5e8a2380be..32d30e849e 100644 --- a/library/cpp/charset/wide.h +++ b/library/cpp/charset/wide.h @@ -8,7 +8,7 @@ #include <util/charset/utf8.h> #include <util/charset/wide.h> #include <util/generic/string.h> -#include <util/generic/algorithm.h> +#include <util/generic/algorithm.h> #include <util/generic/yexception.h> #include <util/memory/tempbuf.h> #include <util/system/yassert.h> diff --git a/library/cpp/http/misc/httpcodes.cpp b/library/cpp/http/misc/httpcodes.cpp index 0a5a9e9aa2..ad8c80ac1e 100644 --- a/library/cpp/http/misc/httpcodes.cpp +++ b/library/cpp/http/misc/httpcodes.cpp @@ -126,7 +126,7 @@ TStringBuf HttpCodeStrEx(int code) noexcept { return TStringBuf("507 Insufficient storage"); case HTTP_LOOP_DETECTED: return TStringBuf("508 Loop Detected"); - case HTTP_BANDWIDTH_LIMIT_EXCEEDED: + case HTTP_BANDWIDTH_LIMIT_EXCEEDED: return TStringBuf("509 Bandwidth Limit Exceeded"); case HTTP_NOT_EXTENDED: return TStringBuf("510 Not Extended"); diff --git a/library/cpp/http/misc/httpcodes.h b/library/cpp/http/misc/httpcodes.h index 59ba614a65..cbfbaa1188 100644 --- a/library/cpp/http/misc/httpcodes.h +++ b/library/cpp/http/misc/httpcodes.h @@ -67,7 +67,7 @@ enum HttpCodes { HTTP_VARIANT_ALSO_NEGOTIATES = 506, HTTP_INSUFFICIENT_STORAGE = 507, HTTP_LOOP_DETECTED = 508, - HTTP_BANDWIDTH_LIMIT_EXCEEDED = 509, + HTTP_BANDWIDTH_LIMIT_EXCEEDED = 509, HTTP_NOT_EXTENDED = 510, HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511, HTTP_UNASSIGNED_512 = 512, diff --git a/library/cpp/json/easy_parse/json_easy_parser_impl.h b/library/cpp/json/easy_parse/json_easy_parser_impl.h index 25016ec94a..ec55d838b3 100644 --- a/library/cpp/json/easy_parse/json_easy_parser_impl.h +++ b/library/cpp/json/easy_parse/json_easy_parser_impl.h @@ -1,7 +1,7 @@ #pragma once -#include <util/generic/string.h> - +#include <util/generic/string.h> + namespace NJson { namespace NImpl { enum EType { diff --git a/library/cpp/json/json_reader.cpp b/library/cpp/json/json_reader.cpp index b50b591e24..072c8deafe 100644 --- a/library/cpp/json/json_reader.cpp +++ b/library/cpp/json/json_reader.cpp @@ -1,13 +1,13 @@ #include "json_reader.h" -#include "rapidjson_helpers.h" - +#include "rapidjson_helpers.h" + #include <contrib/libs/rapidjson/include/rapidjson/error/en.h> #include <contrib/libs/rapidjson/include/rapidjson/error/error.h> -#include <contrib/libs/rapidjson/include/rapidjson/reader.h> +#include <contrib/libs/rapidjson/include/rapidjson/reader.h> -#include <util/generic/stack.h> -#include <util/string/cast.h> +#include <util/generic/stack.h> +#include <util/string/cast.h> #include <util/system/yassert.h> #include <util/string/builder.h> @@ -155,17 +155,17 @@ namespace NJson { namespace { struct TJsonValueBuilder { -#ifdef NDEBUG +#ifdef NDEBUG using TItem = TJsonValue*; - + inline TJsonValue& Access(TItem& item) const { return *item; } -#else +#else struct TItem { TJsonValue* V; size_t DuplicateKeyCount; - + TItem(TJsonValue* v) : V(v) , DuplicateKeyCount(0) @@ -175,19 +175,19 @@ namespace NJson { inline TJsonValue& Access(TItem& item) const { return *item.V; - } -#endif - + } +#endif + NJson::TJsonValue& V; - + TStack<TItem> S; - + TJsonValueBuilder(NJson::TJsonValue& v) : V(v) { S.emplace(&V); } - + template <class T> void Set(const T& t) { if (Access(S.top()).IsArray()) { @@ -196,23 +196,23 @@ namespace NJson { Access(S.top()) = t; S.pop(); } - } - + } + bool Null() { Set(NJson::JSON_NULL); return true; } - + bool Bool(bool b) { Set(b); return true; } - + bool Int(int i) { Set(i); return true; } - + template <class U> bool ProcessUint(U u) { if (Y_LIKELY(u <= static_cast<ui64>(Max<i64>()))) { @@ -221,26 +221,26 @@ namespace NJson { Set(u); } return true; - } - + } + bool Uint(unsigned u) { return ProcessUint(u); } - + bool Int64(i64 i) { Set(i); return true; } - + bool Uint64(ui64 u) { return ProcessUint(u); } - + bool Double(double d) { Set(d); return true; } - + bool RawNumber(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(false && "this method should never be called"); Y_UNUSED(str); @@ -248,13 +248,13 @@ namespace NJson { Y_UNUSED(copy); return true; } - + bool String(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(copy); Set(TStringBuf(str, length)); return true; } - + bool StartObject() { if (Access(S.top()).IsArray()) { S.emplace(&Access(S.top()).AppendValue(NJson::JSON_MAP)); @@ -262,35 +262,35 @@ namespace NJson { Access(S.top()).SetType(NJson::JSON_MAP); } return true; - } - + } + bool Key(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(copy); auto& value = Access(S.top())[TStringBuf(str, length)]; - if (Y_UNLIKELY(value.GetType() != JSON_UNDEFINED)) { -#ifndef NDEBUG + if (Y_UNLIKELY(value.GetType() != JSON_UNDEFINED)) { +#ifndef NDEBUG ++S.top().DuplicateKeyCount; -#endif +#endif value.SetType(JSON_UNDEFINED); } S.emplace(&value); return true; - } - + } + inline int GetDuplicateKeyCount() const { -#ifdef NDEBUG +#ifdef NDEBUG return 0; -#else +#else return S.top().DuplicateKeyCount; -#endif +#endif } - + bool EndObject(rapidjson::SizeType memberCount) { Y_ASSERT(memberCount == Access(S.top()).GetMap().size() + GetDuplicateKeyCount()); S.pop(); return true; } - + bool StartArray() { if (Access(S.top()).IsArray()) { S.emplace(&Access(S.top()).AppendValue(NJson::JSON_ARRAY)); @@ -344,9 +344,9 @@ namespace NJson { return reader.Parse<rapidjson::kParseEscapedApostropheFlag>(is, handler); default: return reader.Parse<rapidjson::kParseNoFlags>(is, handler); - } - } - + } + } + template <class TRapidJsonCompliantInputStream, class THandler> bool ReadJson(TRapidJsonCompliantInputStream& is, const TJsonReaderConfig* config, THandler& handler, bool throwOnError) { rapidjson::Reader reader; @@ -361,9 +361,9 @@ namespace NJson { } } - return true; - } - + return true; + } + template <class TRapidJsonCompliantInputStream> bool ReadJsonTree(TRapidJsonCompliantInputStream& is, const TJsonReaderConfig* config, TJsonValue* out, bool throwOnError) { out->SetType(NJson::JSON_NULL); @@ -371,57 +371,57 @@ namespace NJson { TJsonValueBuilder handler(*out); return ReadJson(is, config, handler, throwOnError); - } - + } + template <class TData> bool ReadJsonTreeImpl(TData* in, const TJsonReaderConfig* config, TJsonValue* out, bool throwOnError) { std::conditional_t<std::is_same<TData, TStringBuf>::value, TStringBufStreamWrapper, TInputStreamWrapper> is(*in); return ReadJsonTree(is, config, out, throwOnError); } - + template <class TData> bool ReadJsonTreeImpl(TData* in, bool allowComments, TJsonValue* out, bool throwOnError) { TJsonReaderConfig config; config.AllowComments = allowComments; return ReadJsonTreeImpl(in, &config, out, throwOnError); } - + template <class TData> bool ReadJsonTreeImpl(TData* in, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(in, false, out, throwOnError); - } + } } //namespace - + bool ReadJsonTree(TStringBuf in, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(&in, out, throwOnError); - } - + } + bool ReadJsonTree(TStringBuf in, bool allowComments, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(&in, allowComments, out, throwOnError); } - + bool ReadJsonTree(TStringBuf in, const TJsonReaderConfig* config, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(&in, config, out, throwOnError); - } - + } + bool ReadJsonTree(IInputStream* in, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(in, out, throwOnError); - } - + } + bool ReadJsonTree(IInputStream* in, bool allowComments, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(in, allowComments, out, throwOnError); - } - + } + bool ReadJsonTree(IInputStream* in, const TJsonReaderConfig* config, TJsonValue* out, bool throwOnError) { return ReadJsonTreeImpl(in, config, out, throwOnError); - } - + } + bool ReadJsonFastTree(TStringBuf in, TJsonValue* out, bool throwOnError, bool notClosedBracketIsError) { TParserCallbacks cb(*out, throwOnError, notClosedBracketIsError); - + return ReadJsonFast(in, &cb); } - + TJsonValue ReadJsonFastTree(TStringBuf in, bool notClosedBracketIsError) { TJsonValue value; // There is no way to report an error apart from throwing an exception when we return result by value. @@ -432,7 +432,7 @@ namespace NJson { namespace { struct TJsonCallbacksWrapper { TJsonCallbacks& Impl; - + TJsonCallbacksWrapper(TJsonCallbacks& impl) : Impl(impl) { @@ -462,67 +462,67 @@ namespace NJson { bool Uint(unsigned u) { return ProcessUint(u); } - + bool Int64(i64 i) { return Impl.OnInteger(i); } - + bool Uint64(ui64 u) { return ProcessUint(u); } - + bool Double(double d) { return Impl.OnDouble(d); } - + bool RawNumber(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(false && "this method should never be called"); Y_UNUSED(str); Y_UNUSED(length); Y_UNUSED(copy); return true; - } - + } + bool String(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(copy); return Impl.OnString(TStringBuf(str, length)); } - + bool StartObject() { return Impl.OnOpenMap(); } - + bool Key(const char* str, rapidjson::SizeType length, bool copy) { Y_ASSERT(copy); return Impl.OnMapKey(TStringBuf(str, length)); } - + bool EndObject(rapidjson::SizeType memberCount) { Y_UNUSED(memberCount); return Impl.OnCloseMap(); } - + bool StartArray() { return Impl.OnOpenArray(); } - + bool EndArray(rapidjson::SizeType elementCount) { Y_UNUSED(elementCount); return Impl.OnCloseArray(); } }; } - + bool ReadJson(IInputStream* in, TJsonCallbacks* cbs) { return ReadJson(in, false, cbs); } - + bool ReadJson(IInputStream* in, bool allowComments, TJsonCallbacks* cbs) { TJsonReaderConfig config; config.AllowComments = allowComments; return ReadJson(in, &config, cbs); } - + bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* cbs) { TJsonReaderConfig config; config.AllowComments = allowComments; @@ -533,35 +533,35 @@ namespace NJson { bool ReadJson(IInputStream* in, const TJsonReaderConfig* config, TJsonCallbacks* cbs) { TJsonCallbacksWrapper wrapper(*cbs); TInputStreamWrapper is(*in); - + rapidjson::Reader reader; auto result = Read(*config, reader, is, wrapper); - + if (result.IsError()) { cbs->OnError(result.Offset(), PrintError(result)); - + return false; - } - + } + return cbs->OnEnd(); } - + TJsonValue ReadJsonTree(IInputStream* in, bool throwOnError) { TJsonValue out; ReadJsonTree(in, &out, throwOnError); return out; } - + TJsonValue ReadJsonTree(IInputStream* in, bool allowComments, bool throwOnError) { TJsonValue out; ReadJsonTree(in, allowComments, &out, throwOnError); return out; } - + TJsonValue ReadJsonTree(IInputStream* in, const TJsonReaderConfig* config, bool throwOnError) { TJsonValue out; ReadJsonTree(in, config, &out, throwOnError); return out; - } - -} + } + +} diff --git a/library/cpp/json/json_reader.h b/library/cpp/json/json_reader.h index 437bf18bad..b673788330 100644 --- a/library/cpp/json/json_reader.h +++ b/library/cpp/json/json_reader.h @@ -64,12 +64,12 @@ namespace NJson { TJsonCallbacks c(throwOnError); return ReadJson(in, config, &c); } - + inline bool ValidateJson(TStringBuf in, const TJsonReaderConfig& config = TJsonReaderConfig(), bool throwOnError = false) { TMemoryInput min(in.data(), in.size()); return ValidateJson(&min, &config, throwOnError); } - + inline bool ValidateJsonThrow(IInputStream* in, const TJsonReaderConfig* config) { return ValidateJson(in, config, true); } diff --git a/library/cpp/json/rapidjson_helpers.cpp b/library/cpp/json/rapidjson_helpers.cpp index 9f42b55b75..2e8159a103 100644 --- a/library/cpp/json/rapidjson_helpers.cpp +++ b/library/cpp/json/rapidjson_helpers.cpp @@ -1 +1 @@ -#include "rapidjson_helpers.h" +#include "rapidjson_helpers.h" diff --git a/library/cpp/json/rapidjson_helpers.h b/library/cpp/json/rapidjson_helpers.h index 314623425e..aeb96ff670 100644 --- a/library/cpp/json/rapidjson_helpers.h +++ b/library/cpp/json/rapidjson_helpers.h @@ -1,104 +1,104 @@ -#pragma once - -#include <util/generic/strbuf.h> -#include <util/stream/input.h> - -namespace NJson { - struct TReadOnlyStreamBase { - using Ch = char; - - Ch* PutBegin() { - Y_ASSERT(false); - return nullptr; - } - - void Put(Ch) { - Y_ASSERT(false); - } - - void Flush() { - Y_ASSERT(false); - } - - size_t PutEnd(Ch*) { - Y_ASSERT(false); - return 0; - } - }; - +#pragma once + +#include <util/generic/strbuf.h> +#include <util/stream/input.h> + +namespace NJson { + struct TReadOnlyStreamBase { + using Ch = char; + + Ch* PutBegin() { + Y_ASSERT(false); + return nullptr; + } + + void Put(Ch) { + Y_ASSERT(false); + } + + void Flush() { + Y_ASSERT(false); + } + + size_t PutEnd(Ch*) { + Y_ASSERT(false); + return 0; + } + }; + struct TInputStreamWrapper : TReadOnlyStreamBase { - Ch Peek() const { - if (!Eof) { - if (Pos >= Sz) { - if (Sz < BUF_SIZE) { - Sz += Helper.Read(Buf + Sz, BUF_SIZE - Sz); - } else { - Sz = Helper.Read(Buf, BUF_SIZE); - Pos = 0; - } - } - - if (Pos < Sz) { - return Buf[Pos]; - } - } - - Eof = true; - return 0; - } - - Ch Take() { - auto c = Peek(); - ++Pos; - ++Count; - return c; - } - - size_t Tell() const { - return Count; - } - + Ch Peek() const { + if (!Eof) { + if (Pos >= Sz) { + if (Sz < BUF_SIZE) { + Sz += Helper.Read(Buf + Sz, BUF_SIZE - Sz); + } else { + Sz = Helper.Read(Buf, BUF_SIZE); + Pos = 0; + } + } + + if (Pos < Sz) { + return Buf[Pos]; + } + } + + Eof = true; + return 0; + } + + Ch Take() { + auto c = Peek(); + ++Pos; + ++Count; + return c; + } + + size_t Tell() const { + return Count; + } + TInputStreamWrapper(IInputStream& helper) - : Helper(helper) - , Eof(false) - , Sz(0) - , Pos(0) - , Count(0) - { - } - - static const size_t BUF_SIZE = 1 << 12; - + : Helper(helper) + , Eof(false) + , Sz(0) + , Pos(0) + , Count(0) + { + } + + static const size_t BUF_SIZE = 1 << 12; + IInputStream& Helper; - mutable char Buf[BUF_SIZE]; - mutable bool Eof; - mutable size_t Sz; - mutable size_t Pos; - size_t Count; - }; - + mutable char Buf[BUF_SIZE]; + mutable bool Eof; + mutable size_t Sz; + mutable size_t Pos; + size_t Count; + }; + struct TStringBufStreamWrapper : TReadOnlyStreamBase { - Ch Peek() const { + Ch Peek() const { return Pos < Data.size() ? Data[Pos] : 0; - } - - Ch Take() { - auto c = Peek(); - ++Pos; - return c; - } - - size_t Tell() const { - return Pos; - } - - TStringBufStreamWrapper(TStringBuf data) - : Data(data) - , Pos(0) - { - } - - TStringBuf Data; - size_t Pos; - }; -} + } + + Ch Take() { + auto c = Peek(); + ++Pos; + return c; + } + + size_t Tell() const { + return Pos; + } + + TStringBufStreamWrapper(TStringBuf data) + : Data(data) + , Pos(0) + { + } + + TStringBuf Data; + size_t Pos; + }; +} diff --git a/library/cpp/json/ut/json_reader_ut.cpp b/library/cpp/json/ut/json_reader_ut.cpp index 48bd0b9bbf..cd31afa0b8 100644 --- a/library/cpp/json/ut/json_reader_ut.cpp +++ b/library/cpp/json/ut/json_reader_ut.cpp @@ -383,19 +383,19 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } catch (...) { } } // TJsonMemoryLeakTest - - Y_UNIT_TEST(TJsonDuplicateKeysWithNullValuesTest) { - const TString json = "{\"\":null,\"\":\"\"}"; - - TStringInput in(json); - NJson::TJsonValue v; - UNIT_ASSERT(ReadJsonTree(&in, &v)); - UNIT_ASSERT(v.IsMap()); - UNIT_ASSERT_VALUES_EQUAL(1, v.GetMap().size()); - UNIT_ASSERT_VALUES_EQUAL("", v.GetMap().begin()->first); - UNIT_ASSERT(v.GetMap().begin()->second.IsString()); - UNIT_ASSERT_VALUES_EQUAL("", v.GetMap().begin()->second.GetString()); - } + + Y_UNIT_TEST(TJsonDuplicateKeysWithNullValuesTest) { + const TString json = "{\"\":null,\"\":\"\"}"; + + TStringInput in(json); + NJson::TJsonValue v; + UNIT_ASSERT(ReadJsonTree(&in, &v)); + UNIT_ASSERT(v.IsMap()); + UNIT_ASSERT_VALUES_EQUAL(1, v.GetMap().size()); + UNIT_ASSERT_VALUES_EQUAL("", v.GetMap().begin()->first); + UNIT_ASSERT(v.GetMap().begin()->second.IsString()); + UNIT_ASSERT_VALUES_EQUAL("", v.GetMap().begin()->second.GetString()); + } } diff --git a/library/cpp/json/ya.make b/library/cpp/json/ya.make index 04fecc5410..d58eead8ec 100644 --- a/library/cpp/json/ya.make +++ b/library/cpp/json/ya.make @@ -9,11 +9,11 @@ SRCS( json_writer.cpp json_reader.cpp json_prettifier.cpp - rapidjson_helpers.cpp + rapidjson_helpers.cpp ) PEERDIR( - contrib/libs/rapidjson + contrib/libs/rapidjson library/cpp/json/common library/cpp/json/fast_sax library/cpp/json/writer diff --git a/library/cpp/lwtrace/log_shuttle.h b/library/cpp/lwtrace/log_shuttle.h index 49d329c0c2..729a38615f 100644 --- a/library/cpp/lwtrace/log_shuttle.h +++ b/library/cpp/lwtrace/log_shuttle.h @@ -5,8 +5,8 @@ #include <library/cpp/lwtrace/protos/lwtrace.pb.h> -#include <util/system/spinlock.h> - +#include <util/system/spinlock.h> + namespace NLWTrace { template <class TDepot> class TRunLogShuttleActionExecutor; @@ -51,7 +51,7 @@ namespace NLWTrace { TExecutor* Executor; bool Ignore = false; size_t MaxTrackLength; - TAdaptiveLock Lock; + TAdaptiveLock Lock; TAtomic ForkFailed = 0; public: @@ -156,21 +156,21 @@ namespace NLWTrace { template <class TDepot> bool TLogShuttle<TDepot>::DoAddProbe(TProbe* probe, const TParams& params, ui64 timestamp) { - with_lock (Lock) { - if (TrackLog.Items.size() >= MaxTrackLength) { - TrackLog.Truncated = true; - return true; - } - TrackLog.Items.emplace_back(); - TTrackLog::TItem* item = &TrackLog.Items.back(); - item->ThreadId = 0; // TODO[serxa]: check if it is fast to run TThread::CurrentThreadId(); - item->Probe = probe; - if ((item->SavedParamsCount = probe->Event.Signature.ParamCount) > 0) { - probe->Event.Signature.CloneParams(item->Params, params); - } + with_lock (Lock) { + if (TrackLog.Items.size() >= MaxTrackLength) { + TrackLog.Truncated = true; + return true; + } + TrackLog.Items.emplace_back(); + TTrackLog::TItem* item = &TrackLog.Items.back(); + item->ThreadId = 0; // TODO[serxa]: check if it is fast to run TThread::CurrentThreadId(); + item->Probe = probe; + if ((item->SavedParamsCount = probe->Event.Signature.ParamCount) > 0) { + probe->Event.Signature.CloneParams(item->Params, params); + } item->TimestampCycles = timestamp ? timestamp : GetCycleCount(); } - + return true; } diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp index 3812ea2d5b..3c974c85a0 100644 --- a/library/cpp/lwtrace/trace.cpp +++ b/library/cpp/lwtrace/trace.cpp @@ -548,8 +548,8 @@ namespace NLWTrace { TArgumentDescription arg0 = arguments.at(0); TArgumentDescription arg1 = arguments.at(1); - const char* tName0 = arg0.ParamIdx == size_t(-1) ? nullptr : probe->Event.Signature.ParamTypes[arg0.ParamIdx]; - const char* tName1 = arg1.ParamIdx == size_t(-1) ? nullptr : probe->Event.Signature.ParamTypes[arg1.ParamIdx]; + const char* tName0 = arg0.ParamIdx == size_t(-1) ? nullptr : probe->Event.Signature.ParamTypes[arg0.ParamIdx]; + const char* tName1 = arg1.ParamIdx == size_t(-1) ? nullptr : probe->Event.Signature.ParamTypes[arg1.ParamIdx]; TString var0 = op.GetArgument(0).GetVariable(); TString var1 = op.GetArgument(1).GetVariable(); diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index c0474e9f39..575c09cee4 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -2,7 +2,7 @@ #include <util/generic/string.h> #include <util/string/ascii.h> -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <cstdlib> #include <util/generic/noncopyable.h> @@ -218,7 +218,7 @@ int TRegExBase::Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatc return Impl->Exec(str, pmatch, eflags, nmatches); } -int TRegExBase::GetCompileOptions() const { +int TRegExBase::GetCompileOptions() const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; return Impl->CompileOptions; diff --git a/library/cpp/regex/pcre/regexp.h b/library/cpp/regex/pcre/regexp.h index 12c85ed58b..bc610bd2f3 100644 --- a/library/cpp/regex/pcre/regexp.h +++ b/library/cpp/regex/pcre/regexp.h @@ -29,7 +29,7 @@ public: int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches = NMATCHES) const; void Compile(const TString& regExpr, int cflags = REG_EXTENDED); bool IsCompiled() const; - int GetCompileOptions() const; + int GetCompileOptions() const; TString GetRegExpr() const; }; diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 91ea95d040..5184e801cc 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -22,26 +22,26 @@ struct TRegTest { }; struct TSubstTest: public TRegTest { - const char* Replacement; - const char* Replacement2; - - TSubstTest(const char* re, const char* text, const char* res, const char* repl, const char* repl2) - : TRegTest(re, text, res, REG_EXTENDED, REGEXP_GLOBAL) - , Replacement(repl) - , Replacement2(repl2) + const char* Replacement; + const char* Replacement2; + + TSubstTest(const char* re, const char* text, const char* res, const char* repl, const char* repl2) + : TRegTest(re, text, res, REG_EXTENDED, REGEXP_GLOBAL) + , Replacement(repl) + , Replacement2(repl2) { } -}; - +}; + const TRegTest REGTEST_DATA[] = { TRegTest("test", "its a test and test string.", "6 10", REG_EXTENDED, 0), TRegTest("test", "its a test and test string.", "6 10 15 19", REG_EXTENDED, REGEXP_GLOBAL), TRegTest("test|[an]{0,0}", "test and test an test string tes", "0 4 4 4 5 5 6 6 7 7 8 8 9 13 13 13 14 14 15 15 16 16 17 21 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32", REG_EXTENDED, REGEXP_GLOBAL), TRegTest("test[an]{1,}", "test and test an test string tes", "NM", REG_EXTENDED, REGEXP_GLOBAL)}; -const TSubstTest SUBSTTEST_DATA[] = { - TSubstTest("([a-zA-Z]*[0-9]+) (_[a-z]+)", "Xxx123 534 ___124 bsd _A ZXC _L 141 _sd dsfg QWE123 _bbb", "141 XXX/_sd", "$1 XXX/$2", "$2$2$2 YY$1Y/$2")}; - +const TSubstTest SUBSTTEST_DATA[] = { + TSubstTest("([a-zA-Z]*[0-9]+) (_[a-z]+)", "Xxx123 534 ___124 bsd _A ZXC _L 141 _sd dsfg QWE123 _bbb", "141 XXX/_sd", "$1 XXX/$2", "$2$2$2 YY$1Y/$2")}; + class TRegexpTest: public TTestBase { private: regmatch_t Matches[NMATCHES]; @@ -49,7 +49,7 @@ private: private: UNIT_TEST_SUITE(TRegexpTest); UNIT_TEST(TestRe) - UNIT_TEST(TestSubst) + UNIT_TEST(TestSubst) UNIT_TEST(TestOffEndOfBuffer); UNIT_TEST_SUITE_END(); @@ -58,8 +58,8 @@ private: memset(Matches, 0, sizeof(Matches)); TString result; - TRegExBase re(regTest.Regexp, regTest.CompileOptions); - if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { + TRegExBase re(regTest.Regexp, regTest.CompileOptions); + if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { for (auto& matche : Matches) { if (matche.rm_so == -1) { break; @@ -70,27 +70,27 @@ private: result = "NM"; } StripInPlace(result); - UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); + UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); } } - - inline void TestSubst() { + + inline void TestSubst() { for (const auto& substTest : SUBSTTEST_DATA) { - TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); - subst.ParseReplacement(substTest.Replacement); + TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); + subst.ParseReplacement(substTest.Replacement); TString result = subst.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(result, substTest.Result); - TRegExSubst substCopy = subst; - subst.ParseReplacement(substTest.Replacement2); + UNIT_ASSERT_VALUES_EQUAL(result, substTest.Result); + TRegExSubst substCopy = subst; + subst.ParseReplacement(substTest.Replacement2); TString newResult = subst.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_UNEQUAL(newResult.c_str(), result.c_str()); + UNIT_ASSERT_VALUES_UNEQUAL(newResult.c_str(), result.c_str()); TString copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(copyResult, result); - substCopy = subst; - copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(copyResult, newResult); - } - } + UNIT_ASSERT_VALUES_EQUAL(copyResult, result); + substCopy = subst; + copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); + UNIT_ASSERT_VALUES_EQUAL(copyResult, newResult); + } + } void TestOffEndOfBuffer() { const TString needle{".*[^./]gov[.].*"}; diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h index ba598b3b5e..f3dd66b437 100644 --- a/library/cpp/scheme/scimpl_defs.h +++ b/library/cpp/scheme/scimpl_defs.h @@ -96,7 +96,7 @@ namespace NSc { } public: - bool RelaxedJson = false; + bool RelaxedJson = false; int Opts = 0; bool SortKeys = true; bool FormatJson = false; diff --git a/library/cpp/tvmauth/src/service_impl.h b/library/cpp/tvmauth/src/service_impl.h index 6cb639731e..18dd4ec335 100644 --- a/library/cpp/tvmauth/src/service_impl.h +++ b/library/cpp/tvmauth/src/service_impl.h @@ -18,7 +18,7 @@ namespace NTvmAuth { using TServiceTicketImplPtr = THolder<TCheckedServiceTicket::TImpl>; class TCheckedServiceTicket::TImpl { public: - explicit operator bool() const; + explicit operator bool() const; TTvmId GetSrc() const; const TScopes& GetScopes() const; diff --git a/library/cpp/tvmauth/src/user_impl.h b/library/cpp/tvmauth/src/user_impl.h index 16eb4b312c..e3f1099b90 100644 --- a/library/cpp/tvmauth/src/user_impl.h +++ b/library/cpp/tvmauth/src/user_impl.h @@ -14,7 +14,7 @@ namespace NTvmAuth { using TUserTicketImplPtr = THolder<TCheckedUserTicket::TImpl>; class TCheckedUserTicket::TImpl { public: - explicit operator bool() const; + explicit operator bool() const; TUid GetDefaultUid() const; time_t GetExpirationTime() const; diff --git a/library/cpp/yson/json/yson2json_adapter.cpp b/library/cpp/yson/json/yson2json_adapter.cpp index 6e561cf51d..b5e7c49d4d 100644 --- a/library/cpp/yson/json/yson2json_adapter.cpp +++ b/library/cpp/yson/json/yson2json_adapter.cpp @@ -3,80 +3,80 @@ namespace NYT { TYson2JsonCallbacksAdapter::TYson2JsonCallbacksAdapter(::NYson::TYsonConsumerBase* impl, bool throwException) : NJson::TJsonCallbacks(throwException) - , Impl_(impl) + , Impl_(impl) { } bool TYson2JsonCallbacksAdapter::OnNull() { WrapIfListItem(); - Impl_->OnEntity(); + Impl_->OnEntity(); return true; } bool TYson2JsonCallbacksAdapter::OnBoolean(bool val) { WrapIfListItem(); - Impl_->OnBooleanScalar(val); + Impl_->OnBooleanScalar(val); return true; } bool TYson2JsonCallbacksAdapter::OnInteger(long long val) { WrapIfListItem(); - Impl_->OnInt64Scalar(val); + Impl_->OnInt64Scalar(val); return true; } bool TYson2JsonCallbacksAdapter::OnUInteger(unsigned long long val) { WrapIfListItem(); - Impl_->OnUint64Scalar(val); + Impl_->OnUint64Scalar(val); return true; } bool TYson2JsonCallbacksAdapter::OnString(const TStringBuf& val) { WrapIfListItem(); - Impl_->OnStringScalar(val); + Impl_->OnStringScalar(val); return true; } bool TYson2JsonCallbacksAdapter::OnDouble(double val) { WrapIfListItem(); - Impl_->OnDoubleScalar(val); + Impl_->OnDoubleScalar(val); return true; } bool TYson2JsonCallbacksAdapter::OnOpenArray() { WrapIfListItem(); - State_.ContextStack.push(true); - Impl_->OnBeginList(); + State_.ContextStack.push(true); + Impl_->OnBeginList(); return true; } bool TYson2JsonCallbacksAdapter::OnCloseArray() { - State_.ContextStack.pop(); - Impl_->OnEndList(); + State_.ContextStack.pop(); + Impl_->OnEndList(); return true; } bool TYson2JsonCallbacksAdapter::OnOpenMap() { WrapIfListItem(); - State_.ContextStack.push(false); - Impl_->OnBeginMap(); + State_.ContextStack.push(false); + Impl_->OnBeginMap(); return true; } bool TYson2JsonCallbacksAdapter::OnCloseMap() { - State_.ContextStack.pop(); - Impl_->OnEndMap(); + State_.ContextStack.pop(); + Impl_->OnEndMap(); return true; } bool TYson2JsonCallbacksAdapter::OnMapKey(const TStringBuf& val) { - Impl_->OnKeyedItem(val); + Impl_->OnKeyedItem(val); return true; } void TYson2JsonCallbacksAdapter::WrapIfListItem() { - if (!State_.ContextStack.empty() && State_.ContextStack.top()) { - Impl_->OnListItem(); + if (!State_.ContextStack.empty() && State_.ContextStack.top()) { + Impl_->OnListItem(); } } } diff --git a/library/cpp/yson/json/yson2json_adapter.h b/library/cpp/yson/json/yson2json_adapter.h index e95212254b..da1bf5ba70 100644 --- a/library/cpp/yson/json/yson2json_adapter.h +++ b/library/cpp/yson/json/yson2json_adapter.h @@ -10,17 +10,17 @@ namespace NYT { class TYson2JsonCallbacksAdapter : public NJson::TJsonCallbacks { public: - class TState { - private: - // Stores current context stack - // If true - we are in a list - // If false - we are in a map - TStack<bool> ContextStack; - - friend class TYson2JsonCallbacksAdapter; - }; - - public: + class TState { + private: + // Stores current context stack + // If true - we are in a list + // If false - we are in a map + TStack<bool> ContextStack; + + friend class TYson2JsonCallbacksAdapter; + }; + + public: TYson2JsonCallbacksAdapter(::NYson::TYsonConsumerBase* impl, bool throwException = false); bool OnNull() override; @@ -35,19 +35,19 @@ namespace NYT { bool OnCloseMap() override; bool OnMapKey(const TStringBuf& val) override; - TState State() const { - return State_; - } - - void Reset(const TState& state) { - State_ = state; - } - + TState State() const { + return State_; + } + + void Reset(const TState& state) { + State_ = state; + } + private: void WrapIfListItem(); private: ::NYson::TYsonConsumerBase* Impl_; - TState State_; + TState State_; }; } diff --git a/library/cpp/yson/writer.cpp b/library/cpp/yson/writer.cpp index f0637f8d2b..054459f9f5 100644 --- a/library/cpp/yson/writer.cpp +++ b/library/cpp/yson/writer.cpp @@ -339,7 +339,7 @@ namespace NYson { } //////////////////////////////////////////////////////////////////////////////// - + void ReformatYsonStream( IInputStream* input, IOutputStream* output, @@ -349,7 +349,7 @@ namespace NYson { TYsonParser parser(&writer, input, type); parser.Parse(); } - + //////////////////////////////////////////////////////////////////////////////// } // namespace NYson diff --git a/library/cpp/yson/writer.h b/library/cpp/yson/writer.h index 79e19d0df5..40f5d7d501 100644 --- a/library/cpp/yson/writer.h +++ b/library/cpp/yson/writer.h @@ -23,14 +23,14 @@ namespace NYson { friend class TYsonWriter; }; - + public: TYsonWriter( IOutputStream* stream, EYsonFormat format = EYsonFormat::Binary, EYsonType type = ::NYson::EYsonType::Node, bool enableRaw = false); - + void OnStringScalar(TStringBuf value) override; void OnInt64Scalar(i64 value) override; void OnUint64Scalar(ui64 value) override; @@ -59,7 +59,7 @@ namespace NYson { EYsonFormat Format; EYsonType Type; bool EnableRaw; - + int Depth; bool BeforeFirstItem; |