diff options
author | svshevtsov <svshevtsov@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:37 +0300 |
commit | 657337012a264721d58c470b4e9e796611f3c492 (patch) | |
tree | 82753fd92cf7cc2dea4e522a945ed570131f920b | |
parent | 44f31b316af517a4fbc6a82ebed8a1c51807deac (diff) | |
download | ydb-657337012a264721d58c470b4e9e796611f3c492.tar.gz |
Restoring authorship annotation for <svshevtsov@yandex-team.ru>. Commit 1 of 2.
38 files changed, 375 insertions, 375 deletions
diff --git a/build/rules/contrib_restricted.policy b/build/rules/contrib_restricted.policy index a83ead1904..9eeb37ced5 100644 --- a/build/rules/contrib_restricted.policy +++ b/build/rules/contrib_restricted.policy @@ -142,7 +142,7 @@ ALLOW orgvisits/library/soc -> contrib/restricted/boost ALLOW quasar/backend -> contrib/restricted/boost ALLOW regulargeo/research -> contrib/restricted/boost ALLOW rem/python/geobase30 -> contrib/restricted/boost -ALLOW drive/contrib/cpp/telemetry -> contrib/restricted/boost +ALLOW drive/contrib/cpp/telemetry -> contrib/restricted/boost ALLOW smart_devices -> contrib/restricted/boost ALLOW statbox/libstatbox -> contrib/restricted/boost ALLOW taxi/uservices -> contrib/restricted/boost diff --git a/library/cpp/http/misc/httpcodes.h b/library/cpp/http/misc/httpcodes.h index cbfbaa1188..87175019f9 100644 --- a/library/cpp/http/misc/httpcodes.h +++ b/library/cpp/http/misc/httpcodes.h @@ -84,11 +84,11 @@ inline TStringBuf HttpCodeStr(int code) noexcept { inline bool IsHttpCode(int code) noexcept { return HttpCodeStrEx(code).data() != HttpCodeStrEx(0).data(); } - + inline bool IsUserError(int code) noexcept { - return code >= 400 && code < 500; -} - + return code >= 400 && code < 500; +} + inline bool IsServerError(int code) noexcept { - return code >= 500; -} + return code >= 500; +} diff --git a/library/cpp/http/misc/ya.make b/library/cpp/http/misc/ya.make index fceb3cf79c..e0f2fb42ea 100644 --- a/library/cpp/http/misc/ya.make +++ b/library/cpp/http/misc/ya.make @@ -5,8 +5,8 @@ OWNER( mvel ) -GENERATE_ENUM_SERIALIZATION(httpcodes.h) - +GENERATE_ENUM_SERIALIZATION(httpcodes.h) + SRCS( httpcodes.cpp httpdate.cpp diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd7..dca5c828cf 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -212,7 +212,7 @@ public: void Wait() { Cb_->OnWait(); - TGuard<TMutex> g(StopMutex); + TGuard<TMutex> g(StopMutex); if (ListenThread) { ListenThread->Join(); ListenThread.Reset(nullptr); @@ -222,7 +222,7 @@ public: void Stop() { Shutdown(); - TGuard<TMutex> g(StopMutex); + TGuard<TMutex> g(StopMutex); if (ListenThread) { ListenThread->Join(); ListenThread.Reset(nullptr); @@ -457,7 +457,7 @@ public: ICallBack* Cb_ = nullptr; THttpServer* Parent_ = nullptr; TWakeupPollAble WakeupPollAble; - TMutex StopMutex; + TMutex StopMutex; private: template <class TThreadPool_> @@ -629,7 +629,7 @@ bool TClientRequest::Reply(void* /*ThreadSpecificResource*/) { return true; } -bool TClientRequest::IsLocal() const { +bool TClientRequest::IsLocal() const { return HasLocalAddress(Socket()); } diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..2a9f6c0872 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -122,7 +122,7 @@ public: NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept; TInstant AcceptMoment() const noexcept; - bool IsLocal() const; + bool IsLocal() const; bool CheckLoopback(); void ProcessFailRequest(int failstate); diff --git a/library/cpp/http/server/options.cpp b/library/cpp/http/server/options.cpp index 05c954384a..50137572cb 100644 --- a/library/cpp/http/server/options.cpp +++ b/library/cpp/http/server/options.cpp @@ -38,6 +38,6 @@ void THttpServerOptions::BindAddresses(TBindAddresses& ret) const { } if (ret.empty()) { - ret.push_back(Host ? TNetworkAddress(Host, Port) : TNetworkAddress(Port)); + ret.push_back(Host ? TNetworkAddress(Host, Port) : TNetworkAddress(Port)); } } diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h index 38eda0e5e7..31214de4c5 100644 --- a/library/cpp/http/server/options.h +++ b/library/cpp/http/server/options.h @@ -68,14 +68,14 @@ public: return *this; } - /// Default interface name to bind the server. Used when none of BindAddress are provided. + /// Default interface name to bind the server. Used when none of BindAddress are provided. inline THttpServerOptions& SetHost(const TString& host) noexcept { Host = host; return *this; } - /// Default port to bind the server. Used when none of BindAddress are provided. + /// Default port to bind the server. Used when none of BindAddress are provided. inline THttpServerOptions& SetPort(ui16 port) noexcept { Port = port; diff --git a/library/cpp/json/json_writer.cpp b/library/cpp/json/json_writer.cpp index 3d058bae36..4f04c12a87 100644 --- a/library/cpp/json/json_writer.cpp +++ b/library/cpp/json/json_writer.cpp @@ -9,9 +9,9 @@ namespace NJson { TJsonWriter::TJsonWriter(IOutputStream* out, bool formatOutput, bool sortkeys, bool validateUtf8) : Out(out) , Buf(NJsonWriter::HEM_UNSAFE) - , DoubleNDigits(TJsonWriterConfig::DefaultDoubleNDigits) - , FloatNDigits(TJsonWriterConfig::DefaultFloatNDigits) - , FloatToStringMode(TJsonWriterConfig::DefaultFloatToStringMode) + , DoubleNDigits(TJsonWriterConfig::DefaultDoubleNDigits) + , FloatNDigits(TJsonWriterConfig::DefaultFloatNDigits) + , FloatToStringMode(TJsonWriterConfig::DefaultFloatToStringMode) , SortKeys(sortkeys) , ValidateUtf8(validateUtf8) , DontEscapeStrings(false) @@ -23,9 +23,9 @@ namespace NJson { TJsonWriter::TJsonWriter(IOutputStream* out, const TJsonWriterConfig& config, bool DFID) : Out(config.Unbuffered ? nullptr : out) , Buf(NJsonWriter::HEM_UNSAFE, config.Unbuffered ? out : nullptr) - , DoubleNDigits(config.DoubleNDigits) - , FloatNDigits(config.FloatNDigits) - , FloatToStringMode(config.FloatToStringMode) + , DoubleNDigits(config.DoubleNDigits) + , FloatNDigits(config.FloatNDigits) + , FloatToStringMode(config.FloatToStringMode) , SortKeys(config.SortKeys) , ValidateUtf8(config.ValidateUtf8) , DontEscapeStrings(config.DontEscapeStrings) @@ -87,11 +87,11 @@ namespace NJson { } void TJsonWriter::Write(float value) { - Buf.WriteFloat(value, FloatToStringMode, FloatNDigits); + Buf.WriteFloat(value, FloatToStringMode, FloatNDigits); } void TJsonWriter::Write(double value) { - Buf.WriteDouble(value, FloatToStringMode, DoubleNDigits); + Buf.WriteDouble(value, FloatToStringMode, DoubleNDigits); } void TJsonWriter::Write(long long value) { @@ -115,7 +115,7 @@ namespace NJson { } void TJsonWriter::Write(const TJsonValue* v) { - Buf.WriteJsonValue(v, SortKeys, FloatToStringMode, DoubleNDigits); + Buf.WriteJsonValue(v, SortKeys, FloatToStringMode, DoubleNDigits); } void TJsonWriter::Write(const TJsonValue& v) { diff --git a/library/cpp/json/json_writer.h b/library/cpp/json/json_writer.h index c7f5c9499a..729aaa939b 100644 --- a/library/cpp/json/json_writer.h +++ b/library/cpp/json/json_writer.h @@ -13,10 +13,10 @@ namespace NJson { struct TJsonWriterConfig { - constexpr static ui32 DefaultDoubleNDigits = 10; - constexpr static ui32 DefaultFloatNDigits = 6; - constexpr static EFloatToStringMode DefaultFloatToStringMode = PREC_NDIGITS; - + constexpr static ui32 DefaultDoubleNDigits = 10; + constexpr static ui32 DefaultFloatNDigits = 6; + constexpr static EFloatToStringMode DefaultFloatToStringMode = PREC_NDIGITS; + inline TJsonWriterConfig& SetUnbuffered(bool v) noexcept { Unbuffered = v; @@ -35,9 +35,9 @@ namespace NJson { return *this; } - ui32 DoubleNDigits = DefaultDoubleNDigits; - ui32 FloatNDigits = DefaultFloatNDigits; - EFloatToStringMode FloatToStringMode = DefaultFloatToStringMode; + ui32 DoubleNDigits = DefaultDoubleNDigits; + ui32 FloatNDigits = DefaultFloatNDigits; + EFloatToStringMode FloatToStringMode = DefaultFloatToStringMode; bool FormatOutput = false; bool SortKeys = false; bool ValidateUtf8 = true; @@ -49,9 +49,9 @@ namespace NJson { class TJsonWriter { IOutputStream* Out; NJsonWriter::TBuf Buf; - const ui32 DoubleNDigits; - const ui32 FloatNDigits; - const EFloatToStringMode FloatToStringMode; + const ui32 DoubleNDigits; + const ui32 FloatNDigits; + const EFloatToStringMode FloatToStringMode; const bool SortKeys; const bool ValidateUtf8; const bool DontEscapeStrings; diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index ca11d34dad..af38ccf662 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -187,42 +187,42 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, ""), "\"A\""); UNIT_ASSERT_VALUES_EQUAL(WrapJsonToCallback(json, "Foo"), "Foo(\"A\")"); } - + Y_UNIT_TEST(FloatPrecision) { - const double value = 1517933989.4242; - const NJson::TJsonValue json(value); - NJson::TJsonWriterConfig config; - { - TString expected = "1517933989"; - TString actual = NJson::WriteJson(json); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - TString expected = "1517933989"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - config.DoubleNDigits = 13; - TString expected = "1517933989.424"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - { - config.DoubleNDigits = 6; - config.FloatToStringMode = PREC_POINT_DIGITS; - TString expected = "1517933989.424200"; - - TStringStream ss; - NJson::WriteJson(&ss, &json, config); - TString actual = ss.Str(); - UNIT_ASSERT_VALUES_EQUAL(actual, expected); - } - } + const double value = 1517933989.4242; + const NJson::TJsonValue json(value); + NJson::TJsonWriterConfig config; + { + TString expected = "1517933989"; + TString actual = NJson::WriteJson(json); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + TString expected = "1517933989"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + config.DoubleNDigits = 13; + TString expected = "1517933989.424"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + { + config.DoubleNDigits = 6; + config.FloatToStringMode = PREC_POINT_DIGITS; + TString expected = "1517933989.424200"; + + TStringStream ss; + NJson::WriteJson(&ss, &json, config); + TString actual = ss.Str(); + UNIT_ASSERT_VALUES_EQUAL(actual, expected); + } + } } diff --git a/library/cpp/json/writer/json.cpp b/library/cpp/json/writer/json.cpp index 02370c2d79..1895ec2382 100644 --- a/library/cpp/json/writer/json.cpp +++ b/library/cpp/json/writer/json.cpp @@ -382,7 +382,7 @@ namespace NJsonWriter { return *a < *b; } - TValueContext TBuf::WriteJsonValue(const NJson::TJsonValue* v, bool sortKeys, EFloatToStringMode mode, int ndigits) { + TValueContext TBuf::WriteJsonValue(const NJson::TJsonValue* v, bool sortKeys, EFloatToStringMode mode, int ndigits) { using namespace NJson; switch (v->GetType()) { default: @@ -393,7 +393,7 @@ namespace NJsonWriter { WriteBool(v->GetBoolean()); break; case JSON_DOUBLE: - WriteDouble(v->GetDouble(), mode, ndigits); + WriteDouble(v->GetDouble(), mode, ndigits); break; case JSON_INTEGER: WriteLongLong(v->GetInteger()); @@ -408,7 +408,7 @@ namespace NJsonWriter { BeginList(); const TJsonValue::TArray& arr = v->GetArray(); for (const auto& it : arr) - WriteJsonValue(&it, sortKeys, mode, ndigits); + WriteJsonValue(&it, sortKeys, mode, ndigits); EndList(); break; } @@ -425,13 +425,13 @@ namespace NJsonWriter { for (size_t i = oldsz, sz = Keys.size(); i < sz; ++i) { TJsonValue::TMapType::const_iterator kv = map.find(*Keys[i]); WriteKey(kv->first); - WriteJsonValue(&kv->second, sortKeys, mode, ndigits); + WriteJsonValue(&kv->second, sortKeys, mode, ndigits); } Keys.resize(oldsz); } else { for (const auto& it : map) { WriteKey(it.first); - WriteJsonValue(&it.second, sortKeys, mode, ndigits); + WriteJsonValue(&it.second, sortKeys, mode, ndigits); } } EndObject(); diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 0aae2531b9..5f6d6c7d59 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -52,7 +52,7 @@ namespace NJsonWriter { TValueContext WriteDouble(double f, EFloatToStringMode mode = PREC_NDIGITS, int ndigits = 10); TValueContext WriteBool(bool b); TValueContext WriteNull(); - TValueContext WriteJsonValue(const NJson::TJsonValue* value, bool sortKeys = false, EFloatToStringMode mode = PREC_NDIGITS, int ndigits = 10); + TValueContext WriteJsonValue(const NJson::TJsonValue* value, bool sortKeys = false, EFloatToStringMode mode = PREC_NDIGITS, int ndigits = 10); TValueContext BeginList(); TBuf& EndList(); diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index fd2a906d6f..2be9f819f0 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -24,7 +24,7 @@ #pragma intrinsic(_InterlockedExchangeAdd) #include <new> -#include <assert.h> +#include <assert.h> #include <errno.h> #define PERTHREAD __declspec(thread) diff --git a/library/cpp/logger/element.cpp b/library/cpp/logger/element.cpp index b510fe16e1..31bbd1dbe9 100644 --- a/library/cpp/logger/element.cpp +++ b/library/cpp/logger/element.cpp @@ -11,12 +11,12 @@ TLogElement::TLogElement(const TLog* parent) } TLogElement::TLogElement(const TLog* parent, ELogPriority priority) - : Parent_(parent) - , Priority_(priority) -{ - Reset(); -} - + : Parent_(parent) + , Priority_(priority) +{ + Reset(); +} + TLogElement::~TLogElement() { try { Finish(); diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp index 9fbd10f666..7244cc86c7 100644 --- a/library/cpp/logger/global/global.cpp +++ b/library/cpp/logger/global/global.cpp @@ -7,7 +7,7 @@ static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter } TLoggerFormatterOperator::Set(formatter.Release()); } - + void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { DoInitGlobalLog( MakeHolder<TGlobalLog>( @@ -22,9 +22,9 @@ void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> for DoInitGlobalLog(THolder(new TGlobalLog(std::move(backend))), std::move(formatter)); } -bool GlobalLogInitialized() { - return TLoggerOperator<TGlobalLog>::Usage(); -} +bool GlobalLogInitialized() { + return TLoggerOperator<TGlobalLog>::Usage(); +} template <> TGlobalLog* CreateDefaultLogger<TGlobalLog>() { diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index cbe71b16ea..c9ec43cf0b 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -5,7 +5,7 @@ // ATTENTION! MUST CALL DoInitGlobalLog BEFORE USAGE -bool GlobalLogInitialized(); +bool GlobalLogInitialized(); void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); diff --git a/library/cpp/logger/global/rty_formater.cpp b/library/cpp/logger/global/rty_formater.cpp index 305f8470c5..9eb40eaea7 100644 --- a/library/cpp/logger/global/rty_formater.cpp +++ b/library/cpp/logger/global/rty_formater.cpp @@ -54,9 +54,9 @@ namespace NLoggingImpl { TString GetSystemResources() { NMemInfo::TMemInfo mi = NMemInfo::GetMemInfo(); - return PrintSystemResources(mi); - } - + return PrintSystemResources(mi); + } + TString PrintSystemResources(const NMemInfo::TMemInfo& mi) { return Sprintf(" rss=%0.3fMb, vms=%0.3fMb", mi.RSS * 1.0 / (1024 * 1024), mi.VMS * 1.0 / (1024 * 1024)); } diff --git a/library/cpp/logger/global/rty_formater.h b/library/cpp/logger/global/rty_formater.h index 6532e1d769..8097200ea5 100644 --- a/library/cpp/logger/global/rty_formater.h +++ b/library/cpp/logger/global/rty_formater.h @@ -2,10 +2,10 @@ #include "common.h" -namespace NMemInfo { - struct TMemInfo; -} - +namespace NMemInfo { + struct TMemInfo; +} + class ILoggerFormatter { public: virtual ~ILoggerFormatter() = default; diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 96cc11bcfd..e71cb05abb 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/guard.h> -#include <util/system/rwlock.h> +#include <util/system/rwlock.h> #include <util/generic/map.h> #include <util/generic/set.h> #include <util/generic/singleton.h> diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index 06fb0739ff..a5933c4ba9 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -1,69 +1,69 @@ #include <library/cpp/object_factory/object_factory.h> #include <library/cpp/testing/unittest/registar.h> - + #include <util/generic/noncopyable.h> #include <util/generic/string.h> -#include <util/generic/ptr.h> - -using namespace NObjectFactory; - -struct TArgument { +#include <util/generic/ptr.h> + +using namespace NObjectFactory; + +struct TArgument { TString Name; - void* Discarded; -}; - -class ICommonInterface { -public: + void* Discarded; +}; + +class ICommonInterface { +public: virtual ~ICommonInterface() { } - + virtual TString GetValue() const = 0; -}; - +}; + class TDirectOrder: public ICommonInterface { -public: +public: TDirectOrder(const TString& provider, float factor, TArgument& argument) - : Provider(provider) - , Factor(factor) - , Argument(argument) + : Provider(provider) + , Factor(factor) + , Argument(argument) { } - + TString GetValue() const override { - return Provider + ToString(Factor) + Argument.Name; - } + return Provider + ToString(Factor) + Argument.Name; + } -private: +private: const TString Provider; - const float Factor; - const TArgument Argument; -}; - + const float Factor; + const TArgument Argument; +}; + class TInverseOrder: public ICommonInterface { -public: +public: TInverseOrder(const TString& provider, float factor, TArgument& argument) - : Provider(provider) - , Factor(factor) - , Argument(argument) + : Provider(provider) + , Factor(factor) + , Argument(argument) { } - + TString GetValue() const override { - return Argument.Name + ToString(Factor) + Provider; - } + return Argument.Name + ToString(Factor) + Provider; + } -private: +private: const TString Provider; - const float Factor; - const TArgument Argument; -}; - + const float Factor; + const TArgument Argument; +}; + struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { ++CallsCounter; return new TDirectOrder(provider, factor, argument); } - + static int CallsCounter; }; int TDirectOrderCreator::CallsCounter = 0; @@ -71,8 +71,8 @@ int TDirectOrderCreator::CallsCounter = 0; using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const TString&, float, TArgument&>; static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator); -static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); - +static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); + class IMoveableOnlyInterface { @@ -148,15 +148,15 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { TArgument inverseArg{"Fake", nullptr}; THolder<ICommonInterface> direct(TTestFactory::Construct("direct", "prov", 0.42, directArg)); THolder<ICommonInterface> inverse(TTestFactory::Construct("inverse", "prov2", 1, inverseArg)); - - UNIT_ASSERT(!!direct); - UNIT_ASSERT(!!inverse); - - UNIT_ASSERT(direct->GetValue() == "prov0.42Name"); - UNIT_ASSERT(inverse->GetValue() == "Fake1prov2"); + + UNIT_ASSERT(!!direct); + UNIT_ASSERT(!!inverse); + + UNIT_ASSERT(direct->GetValue() == "prov0.42Name"); + UNIT_ASSERT(inverse->GetValue() == "Fake1prov2"); UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1); - } + } Y_UNIT_TEST(TestMoveableOnly) { TString v = "value1"; @@ -186,4 +186,4 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { UNIT_ASSERT_EQUAL(directDs->GetValue(), "prov0.01Name"); } -} +} diff --git a/library/cpp/object_factory/ut/ya.make b/library/cpp/object_factory/ut/ya.make index 5a870072fc..2452bfa632 100644 --- a/library/cpp/object_factory/ut/ya.make +++ b/library/cpp/object_factory/ut/ya.make @@ -1,15 +1,15 @@ -UNITTEST() - -OWNER(svshevtsov) - -PEERDIR( +UNITTEST() + +OWNER(svshevtsov) + +PEERDIR( ADDINCL library/cpp/object_factory -) - +) + SRCDIR(library/cpp/object_factory) - -SRCS( - object_factory_ut.cpp -) - -END() + +SRCS( + object_factory_ut.cpp +) + +END() diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp index 0b4be38c0e..c24a1cf254 100644 --- a/library/cpp/openssl/io/stream.cpp +++ b/library/cpp/openssl/io/stream.cpp @@ -131,39 +131,39 @@ namespace { Connect(); } - inline TSslContextPtr CreateClientContext() { - TSslContextPtr ctx = CreateSslCtx(SSLv23_client_method()); - if (ClientCert_) { - if (!ClientCert_->CertificateFile_ || !ClientCert_->PrivateKeyFile_) { - ythrow yexception() << "both client certificate and private key are required"; - } - if (ClientCert_->PrivateKeyPassword_) { - SSL_CTX_set_default_passwd_cb(ctx.Get(), [](char* buf, int size, int rwflag, void* userData) -> int { - Y_UNUSED(rwflag); - auto io = static_cast<TSslIO*>(userData); - if (!io) { - return -1; - } - if (size < static_cast<int>(io->ClientCert_->PrivateKeyPassword_.size())) { - return -1; - } - return io->ClientCert_->PrivateKeyPassword_.copy(buf, size, 0); - }); - SSL_CTX_set_default_passwd_cb_userdata(ctx.Get(), this); - } - if (1 != SSL_CTX_use_certificate_chain_file(ctx.Get(), ClientCert_->CertificateFile_.c_str())) { - ythrow TSslError() << "SSL_CTX_use_certificate_chain_file"; - } - if (1 != SSL_CTX_use_PrivateKey_file(ctx.Get(), ClientCert_->PrivateKeyFile_.c_str(), SSL_FILETYPE_PEM)) { - ythrow TSslError() << "SSL_CTX_use_PrivateKey_file"; - } - if (1 != SSL_CTX_check_private_key(ctx.Get())) { - ythrow TSslError() << "SSL_CTX_check_private_key (client)"; - } - } - return ctx; - } - + inline TSslContextPtr CreateClientContext() { + TSslContextPtr ctx = CreateSslCtx(SSLv23_client_method()); + if (ClientCert_) { + if (!ClientCert_->CertificateFile_ || !ClientCert_->PrivateKeyFile_) { + ythrow yexception() << "both client certificate and private key are required"; + } + if (ClientCert_->PrivateKeyPassword_) { + SSL_CTX_set_default_passwd_cb(ctx.Get(), [](char* buf, int size, int rwflag, void* userData) -> int { + Y_UNUSED(rwflag); + auto io = static_cast<TSslIO*>(userData); + if (!io) { + return -1; + } + if (size < static_cast<int>(io->ClientCert_->PrivateKeyPassword_.size())) { + return -1; + } + return io->ClientCert_->PrivateKeyPassword_.copy(buf, size, 0); + }); + SSL_CTX_set_default_passwd_cb_userdata(ctx.Get(), this); + } + if (1 != SSL_CTX_use_certificate_chain_file(ctx.Get(), ClientCert_->CertificateFile_.c_str())) { + ythrow TSslError() << "SSL_CTX_use_certificate_chain_file"; + } + if (1 != SSL_CTX_use_PrivateKey_file(ctx.Get(), ClientCert_->PrivateKeyFile_.c_str(), SSL_FILETYPE_PEM)) { + ythrow TSslError() << "SSL_CTX_use_PrivateKey_file"; + } + if (1 != SSL_CTX_check_private_key(ctx.Get())) { + ythrow TSslError() << "SSL_CTX_check_private_key (client)"; + } + } + return ctx; + } + inline TSslPtr ConstructSsl() { TSslPtr ssl(SSL_new(Ctx.Get())); diff --git a/library/cpp/openssl/io/stream.h b/library/cpp/openssl/io/stream.h index 7bca8f80ef..9cff017104 100644 --- a/library/cpp/openssl/io/stream.h +++ b/library/cpp/openssl/io/stream.h @@ -14,14 +14,14 @@ public: // It can be expanded with ENV: SSL_CERT_DIR. TString Hostname_; }; - struct TClientCert { - TString CertificateFile_; - TString PrivateKeyFile_; - TString PrivateKeyPassword_; - }; + struct TClientCert { + TString CertificateFile_; + TString PrivateKeyFile_; + TString PrivateKeyPassword_; + }; TMaybe<TVerifyCert> VerifyCert_; - TMaybe<TClientCert> ClientCert_; + TMaybe<TClientCert> ClientCert_; // TODO - keys, cyphers, etc }; diff --git a/library/cpp/uri/assign.cpp b/library/cpp/uri/assign.cpp index ae9125c727..71e17988c9 100644 --- a/library/cpp/uri/assign.cpp +++ b/library/cpp/uri/assign.cpp @@ -235,9 +235,9 @@ namespace NUri { // now set all fields prior to validating - Alloc(buflen); + Alloc(buflen); - TMemoryWriteBuffer out(Buffer.data(), Buffer.size()); + TMemoryWriteBuffer out(Buffer.data(), Buffer.size()); for (int idx = 0; idx < FieldUrlMAX; ++idx) { const EField fld = EField(idx); @@ -310,8 +310,8 @@ namespace NUri { if (checkChars != allowChars) ret = ParsedBadFormat; } - - out << '\0'; + + out << '\0'; } if (hostConverted) { @@ -323,7 +323,7 @@ namespace NUri { out << '\0'; } - Buffer.Resize(out.Len()); + Buffer.Resize(out.Len()); if (GetScheme() == SchemeEmpty && SchemeEmpty != defscheme) { if (SchemeUnknown == defscheme) diff --git a/library/cpp/uri/benchmark/main.cpp b/library/cpp/uri/benchmark/main.cpp index d39704877e..17d2b666bc 100644 --- a/library/cpp/uri/benchmark/main.cpp +++ b/library/cpp/uri/benchmark/main.cpp @@ -1,46 +1,46 @@ -#include <library/cpp/uri/uri.h> - -#include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/vector.h> - -const TString URLS[] = { - "http://www.TEST.Ru:80/InDex.html", - "www.ya.ru/index.html", - "https://workplace.z.yandex-team.ru/di#vertical=drive&datePreset=week", - "https://warden.z.yandex-team.ru/components/web/report?filter_type=action_items&filter_status=total&filter_period=review", - "https://meduza.io/news/2021/05/01/italiya-vozobnovila-vydachu-turisticheskih-viz-v-moskve", - "https://gcc.gnu.org/projects/cxx-status.html#cxx20", - "https://github.com/llvm/llvm-project/commits/main/libcxx", - "https://photos.google.com/share/AF1QipNi8VN2pw2Ya_xCV8eFgzEZmiXDy1-GwhXbqFtvXoH3HypF10as9puV8FdoVZpOZA?key=WkZjQTIxQTM5a01oZkNUYTE2ZllKTVJKZk1CMTR3", - "https://mag.auto.ru/article/ladasolaris/?from=mag_web_block&utm_campaign=ladasolaris&utm_content=populyarnoe&utm_source=mag_web_block&utm_medium=cpc", - "https://yabs.yandex.ru/count/WZ4ejI_zODW1FH40j1nmE7kaiN1MJWK0s08GWY0nuM6EO000000useqKG0H846344d30nU21pYI00GcG0VpCzQaucBW1mCNWWOR1co7e0QG2y0A-meRx0v03yCE0RzqD-0Jozzu1Y0Nozzu1a0Nozzu1m0Nvks_D2-U0-KK5Iga7StZ0vgZ8Ao2m1u20c0ou1-u9q0SIW870W822W07u2DoYy82d4W10oQeB4EBQlCbpU0002zaBbLJ1w0lozzu1y0i6w0oNm808WWuaCaOrC30oGaKjHaCoHIqqDpWoBJX1HZajCaD3HJGtDKH3Gp7Dbvo7cB_HWagW3i24FO0Gm-3DmA8G0w7W4e606EaIQREKnW19jq8oc1C8g1E2WkxBsSo3dXRW4_BttW6W5FBttW6e5FBttW7G5EUCwadO583Nge06w1IC0j0LWDUgW0RO5S6AzkoZZxpyO_2G5i41e1RGWVs31iaMWHUe5md05xGIs1V0X3sm68AikOG6q1WG-1ZKfU3zXERBdee1W1cG6G6W6Qe3i1cu6T8P4dbXOdDVSsLoTcLoBt8rCZGjCkWPWC83y1c0mWE16l__eqZnoGHLc1hyy8W2i1hotyIEmftqxKJr6W40000R02tR-6NBeHRAQn6iQSWtbmq2DFDwGK8a9Muu2wvTOhNWE4vj3Fy-LbbUXS4Y0NLWZWE9MX1ZSNyOanc8rS-k0u1LdAMo0O-fHvO33T0LBwYZBzcF7h0qb3q0~1", - "https://yandex.ru/pogoda/nowcast/?utm_campaign=alert&utm_content=alert_separate&utm_medium=web&utm_source=home&utm_term=nowcast&morda_geolocation=1", - "https://an.yandex.ru/count/WluejI_zOE02fHS052S_YplH_yoFzGK0u0CGWY0nncwAO000000uYgLImfs4aOKAW06Suha2Y07-gFqAa07-vu2bpu20W0AO0VxdWALFe07Ug07Uk076nFll8S010jW1w9_VcG7W0Soxo1te0Ue40Q02vAG1y0Aasfk_0SOA-0IzX9W1Y0MzX9W1a0Nav9y1e0MCiIwe1ShJ9h05ojCck0NkpoZ9qoOhae0mkgnJ5wa7cB8OEOwtEX-m1u20a2Iu1u05ibB92YPyFmDpJFK_D7ddf9Yo002blSLG6C7e2xs4c07m2mc83BIDthu1gGpzGrRLHHZfF-WCbmBW3OA0mC60288E93OtGqOmC4L4BJ4sDaCjD4P5H2r1EJX5BKKuCZCvGZX4DqGtgwI2XAENwwcOvUBgu_6jdH_P3u0Gz8sO7OWGpz-nX0e1eU0HoV740-WHhS3enS2ScyBwO3_lGEaI3kz-5M87zWKoc1C4g1Eli-_mek7ml1RW4-xFA8WKqRAuZvJoWDi8e1JkpoYe5EJadudj_uC6w1I40iWLhPEErFa4q1MEz9w41jWLmOhsxAEFlFnZyA0Mq87zWmR95j0Mj8tUlW615vWNWfsO8wWN2RWN0S0NjHBO5y24FUWN0PaOe1WBi1ZIlwc41hWO0j0O4FWOeQI_pOMKhhOPW1c96MWs1G000000a1a1e1cg0x0Pk1d_0T8P4dbXOdDVSsLoTcLoBt8rCZCjCkWPWC83y1c0mWE16l__fs_4tYo3a1g0W06O6l70j06m6hkouUoAwFByhm6u6W7r6W4000226nmnDZ4vDZWrC3OnBZasE30pBZWrDJSmBZOuDJSt9I1HX8PYb34CCgLmxEvDy50h8PoKR4c2QKHEe8YaRoCEXF5m_E1rNC99Bpm6wIRbNGAU6GiQ3qguwKm8cq7la7pmUZxo079vS26KW_bTaCPY9QnjKrUHau50oq6yQCyn5TW0kBtjBWG2fE3FRk2DVwuirPJ_lvLb3GlkDKAujdLv~1?stat-id=1", - "https://rasp.yandex.ru/?utm_source=yamain&utm_medium=geoblock&utm_campaign=main", - "https://dsp-rambler.ru/click?url=hs31lTJpNQdz5IfhdiQZitCij144sWuuLcC3jopSDRPYYlPZNuD1x6OEJg74u0nbP0J0oXWXw7awYsCTgG7Cr*koGqxBBhOnzB5aZ6aLfCVVGlIuP3L194y025VLJAsK04sZwSvJbxEYfnbOWKPgQHOf7c8Gqkope95-kr--aTxpsg18jiwVdEPBENe3F2Iahm3yL*3vvzt-t7Vq6bANhL3DiJglfLw2WVd4tAhoAepFV*QybPJFoGHbdOWGMTyzpWMxWPLKb7MRFQWj1K*58qPyfNkfyQ72vvzjviirTM57xng8Cxbi08-HzM5x7imDOYIY8EvXOqfU3Q0KWsyO1RC1yHHVinVxthuIb16zLjg2aoYFpz-OLiTYhlmk1vyK9t9fLz8*Oiez9i*7TqIwcWZyX5gUFuOOJ4sTWbeQLe6IQEShvKIj7v9yBZRLkRmdHLfrREuTNpBMBtRG80MIxwXyt6SjjFOhSKtK-yDA19Wawzgw9fNOy9DW0TDAehQkPUTz*5-htmszyUqJWk5ovqoyHV3acnOI2-klqMCMfU9w3*GOYS0CuNTrggGCQH376EaeQthtwiUcabSarBEocGEsW7n27kIsrtYh2-SZwPvKC1Ek3dg35nuEO-MWNPMmqJvAhBGXHF*EQkcB3eLUEluJmwTxqPRv00M4PNgdYsYsgKYPU6MMJTxbH7fA*Q2vA7WErGONTSzhSOeNLPP4vR9WalRvzllDB3XH4bNx6Pleb3ZfWmoYTNN0Lux3-VxOSjIvDDGzMirfOVPKZB4qVQWsP4WHCrRgsijW43cKGhcQ0dPORYO5v0xhzMjoZ0qDEsaiXBkfRXccnQ3QGaXk2PC1vu*Zlj0qgJfO5i8e66z4HEiMWRF4JH8ZsbZqrUzKXX-WpPQuVA0MOslhzq8m3KS3UIEurWCn80utY4AWCuHzGooJbb*PcHhYMqIBbLcJW76RK9HQjI8Bxiu4C9wECXeWIqeVuHzbmb7PGizIDVwg-g8I-zrBgd8OH3kWtC09YwSB-F9wOHrrcBG*Sv6fdnwubW1ndv0V1jsok2DhMT9IFBOoa-brtWYIdttkRs2J4m*Ai5IgVOagS2wyboiHKptd7aQ7j1YnJENZbFfs2nSwvPTvvSA8w-vCJHo-xEW6tPWaAOrVVRZscjNb4HovTUKBhxrCm8cZYw0ZahlRWGDpB0QkiI-xSv7YdYzoAQMvEOF8h*MKTn1Had8cI2FJ3WtcaT3siShD*APePK6dwqGsNJRz3lfbeX*hykpwK8kTumfS6z51bv06bjahc*fo1vjNt8ivt2BJPWqnGkYH9-8r76iBia7d1zKKnzfqk-mu3m9eP0kiKkoqMKaugV2muZlt5h4ps29ikmTIc-8vYtwHOdLDay7PUhTC4tKepBVRZh6nXrIa5POmkVNV7hVfeoMXqlid2B-2LM3CWCo*W2r23aefVN8mi3t-dnWNUlVgurAc*674C76Py8Qdr0*EJqmYjhrQw6jbm*nB3O-kd1aYqWXWC3Msg1a5r9sRu1WVLKzmwwzjPX6b44R5ULVhu1OqH6*O7hFIbN584lUhWM6g1nWFqhwhN3**Bam802sRvZjguTILo*UAH7WW1DRRG5MsTs-ZP3tOFMkQKWuJ3LRLDXtnkyN25S0LYEmH8R0vTstUmFwafeJSmm90Iuseu9DKArqrb1Wn2cZv2zgAEYy66U7kkBTQSC76WlwBJTVpoK6MUohrEll23wivbnhNaGzaSe6kWRq1ItpFkqv9gXkCAAAAuty8CgAAAAA", - "https://news.rambler.ru/moscow_city/46342947-pogoda-v-moskve-sinoptiki-poobeschali-moskvicham-silnyy-liven-blizhayshey-nochyu/?utm_source=head&utm_campaign=self_promo&utm_medium=news&utm_content=news", -}; - -Y_CPU_BENCHMARK(Parsing, iface) { - for (size_t i = 0; i < iface.Iterations(); ++i) { - for (auto&& url : URLS) { - NUri::TUri uri; - auto parseResult = uri.Parse(url, uri.FeaturesAll); - Y_DO_NOT_OPTIMIZE_AWAY(parseResult); - Y_VERIFY(parseResult == NUri::TState::ParsedOK, "cannot parse %s: %d", url.c_str(), static_cast<ui32>(parseResult)); - } - } -} - -Y_CPU_BENCHMARK(ParsingAndCopying, iface) { - for (size_t i = 0; i < iface.Iterations(); ++i) { - for (auto&& url : URLS) { - NUri::TUri uri; - auto parseResult = uri.Parse(url, uri.FeaturesAll); - Y_VERIFY(parseResult == NUri::TState::ParsedOK, "cannot parse %s: %d", url.c_str(), static_cast<ui32>(parseResult)); - auto copy = uri; - Y_DO_NOT_OPTIMIZE_AWAY(copy); - } - } -} +#include <library/cpp/uri/uri.h> + +#include <library/cpp/testing/benchmark/bench.h> + +#include <util/generic/vector.h> + +const TString URLS[] = { + "http://www.TEST.Ru:80/InDex.html", + "www.ya.ru/index.html", + "https://workplace.z.yandex-team.ru/di#vertical=drive&datePreset=week", + "https://warden.z.yandex-team.ru/components/web/report?filter_type=action_items&filter_status=total&filter_period=review", + "https://meduza.io/news/2021/05/01/italiya-vozobnovila-vydachu-turisticheskih-viz-v-moskve", + "https://gcc.gnu.org/projects/cxx-status.html#cxx20", + "https://github.com/llvm/llvm-project/commits/main/libcxx", + "https://photos.google.com/share/AF1QipNi8VN2pw2Ya_xCV8eFgzEZmiXDy1-GwhXbqFtvXoH3HypF10as9puV8FdoVZpOZA?key=WkZjQTIxQTM5a01oZkNUYTE2ZllKTVJKZk1CMTR3", + "https://mag.auto.ru/article/ladasolaris/?from=mag_web_block&utm_campaign=ladasolaris&utm_content=populyarnoe&utm_source=mag_web_block&utm_medium=cpc", + "https://yabs.yandex.ru/count/WZ4ejI_zODW1FH40j1nmE7kaiN1MJWK0s08GWY0nuM6EO000000useqKG0H846344d30nU21pYI00GcG0VpCzQaucBW1mCNWWOR1co7e0QG2y0A-meRx0v03yCE0RzqD-0Jozzu1Y0Nozzu1a0Nozzu1m0Nvks_D2-U0-KK5Iga7StZ0vgZ8Ao2m1u20c0ou1-u9q0SIW870W822W07u2DoYy82d4W10oQeB4EBQlCbpU0002zaBbLJ1w0lozzu1y0i6w0oNm808WWuaCaOrC30oGaKjHaCoHIqqDpWoBJX1HZajCaD3HJGtDKH3Gp7Dbvo7cB_HWagW3i24FO0Gm-3DmA8G0w7W4e606EaIQREKnW19jq8oc1C8g1E2WkxBsSo3dXRW4_BttW6W5FBttW6e5FBttW7G5EUCwadO583Nge06w1IC0j0LWDUgW0RO5S6AzkoZZxpyO_2G5i41e1RGWVs31iaMWHUe5md05xGIs1V0X3sm68AikOG6q1WG-1ZKfU3zXERBdee1W1cG6G6W6Qe3i1cu6T8P4dbXOdDVSsLoTcLoBt8rCZGjCkWPWC83y1c0mWE16l__eqZnoGHLc1hyy8W2i1hotyIEmftqxKJr6W40000R02tR-6NBeHRAQn6iQSWtbmq2DFDwGK8a9Muu2wvTOhNWE4vj3Fy-LbbUXS4Y0NLWZWE9MX1ZSNyOanc8rS-k0u1LdAMo0O-fHvO33T0LBwYZBzcF7h0qb3q0~1", + "https://yandex.ru/pogoda/nowcast/?utm_campaign=alert&utm_content=alert_separate&utm_medium=web&utm_source=home&utm_term=nowcast&morda_geolocation=1", + "https://an.yandex.ru/count/WluejI_zOE02fHS052S_YplH_yoFzGK0u0CGWY0nncwAO000000uYgLImfs4aOKAW06Suha2Y07-gFqAa07-vu2bpu20W0AO0VxdWALFe07Ug07Uk076nFll8S010jW1w9_VcG7W0Soxo1te0Ue40Q02vAG1y0Aasfk_0SOA-0IzX9W1Y0MzX9W1a0Nav9y1e0MCiIwe1ShJ9h05ojCck0NkpoZ9qoOhae0mkgnJ5wa7cB8OEOwtEX-m1u20a2Iu1u05ibB92YPyFmDpJFK_D7ddf9Yo002blSLG6C7e2xs4c07m2mc83BIDthu1gGpzGrRLHHZfF-WCbmBW3OA0mC60288E93OtGqOmC4L4BJ4sDaCjD4P5H2r1EJX5BKKuCZCvGZX4DqGtgwI2XAENwwcOvUBgu_6jdH_P3u0Gz8sO7OWGpz-nX0e1eU0HoV740-WHhS3enS2ScyBwO3_lGEaI3kz-5M87zWKoc1C4g1Eli-_mek7ml1RW4-xFA8WKqRAuZvJoWDi8e1JkpoYe5EJadudj_uC6w1I40iWLhPEErFa4q1MEz9w41jWLmOhsxAEFlFnZyA0Mq87zWmR95j0Mj8tUlW615vWNWfsO8wWN2RWN0S0NjHBO5y24FUWN0PaOe1WBi1ZIlwc41hWO0j0O4FWOeQI_pOMKhhOPW1c96MWs1G000000a1a1e1cg0x0Pk1d_0T8P4dbXOdDVSsLoTcLoBt8rCZCjCkWPWC83y1c0mWE16l__fs_4tYo3a1g0W06O6l70j06m6hkouUoAwFByhm6u6W7r6W4000226nmnDZ4vDZWrC3OnBZasE30pBZWrDJSmBZOuDJSt9I1HX8PYb34CCgLmxEvDy50h8PoKR4c2QKHEe8YaRoCEXF5m_E1rNC99Bpm6wIRbNGAU6GiQ3qguwKm8cq7la7pmUZxo079vS26KW_bTaCPY9QnjKrUHau50oq6yQCyn5TW0kBtjBWG2fE3FRk2DVwuirPJ_lvLb3GlkDKAujdLv~1?stat-id=1", + "https://rasp.yandex.ru/?utm_source=yamain&utm_medium=geoblock&utm_campaign=main", + "https://dsp-rambler.ru/click?url=hs31lTJpNQdz5IfhdiQZitCij144sWuuLcC3jopSDRPYYlPZNuD1x6OEJg74u0nbP0J0oXWXw7awYsCTgG7Cr*koGqxBBhOnzB5aZ6aLfCVVGlIuP3L194y025VLJAsK04sZwSvJbxEYfnbOWKPgQHOf7c8Gqkope95-kr--aTxpsg18jiwVdEPBENe3F2Iahm3yL*3vvzt-t7Vq6bANhL3DiJglfLw2WVd4tAhoAepFV*QybPJFoGHbdOWGMTyzpWMxWPLKb7MRFQWj1K*58qPyfNkfyQ72vvzjviirTM57xng8Cxbi08-HzM5x7imDOYIY8EvXOqfU3Q0KWsyO1RC1yHHVinVxthuIb16zLjg2aoYFpz-OLiTYhlmk1vyK9t9fLz8*Oiez9i*7TqIwcWZyX5gUFuOOJ4sTWbeQLe6IQEShvKIj7v9yBZRLkRmdHLfrREuTNpBMBtRG80MIxwXyt6SjjFOhSKtK-yDA19Wawzgw9fNOy9DW0TDAehQkPUTz*5-htmszyUqJWk5ovqoyHV3acnOI2-klqMCMfU9w3*GOYS0CuNTrggGCQH376EaeQthtwiUcabSarBEocGEsW7n27kIsrtYh2-SZwPvKC1Ek3dg35nuEO-MWNPMmqJvAhBGXHF*EQkcB3eLUEluJmwTxqPRv00M4PNgdYsYsgKYPU6MMJTxbH7fA*Q2vA7WErGONTSzhSOeNLPP4vR9WalRvzllDB3XH4bNx6Pleb3ZfWmoYTNN0Lux3-VxOSjIvDDGzMirfOVPKZB4qVQWsP4WHCrRgsijW43cKGhcQ0dPORYO5v0xhzMjoZ0qDEsaiXBkfRXccnQ3QGaXk2PC1vu*Zlj0qgJfO5i8e66z4HEiMWRF4JH8ZsbZqrUzKXX-WpPQuVA0MOslhzq8m3KS3UIEurWCn80utY4AWCuHzGooJbb*PcHhYMqIBbLcJW76RK9HQjI8Bxiu4C9wECXeWIqeVuHzbmb7PGizIDVwg-g8I-zrBgd8OH3kWtC09YwSB-F9wOHrrcBG*Sv6fdnwubW1ndv0V1jsok2DhMT9IFBOoa-brtWYIdttkRs2J4m*Ai5IgVOagS2wyboiHKptd7aQ7j1YnJENZbFfs2nSwvPTvvSA8w-vCJHo-xEW6tPWaAOrVVRZscjNb4HovTUKBhxrCm8cZYw0ZahlRWGDpB0QkiI-xSv7YdYzoAQMvEOF8h*MKTn1Had8cI2FJ3WtcaT3siShD*APePK6dwqGsNJRz3lfbeX*hykpwK8kTumfS6z51bv06bjahc*fo1vjNt8ivt2BJPWqnGkYH9-8r76iBia7d1zKKnzfqk-mu3m9eP0kiKkoqMKaugV2muZlt5h4ps29ikmTIc-8vYtwHOdLDay7PUhTC4tKepBVRZh6nXrIa5POmkVNV7hVfeoMXqlid2B-2LM3CWCo*W2r23aefVN8mi3t-dnWNUlVgurAc*674C76Py8Qdr0*EJqmYjhrQw6jbm*nB3O-kd1aYqWXWC3Msg1a5r9sRu1WVLKzmwwzjPX6b44R5ULVhu1OqH6*O7hFIbN584lUhWM6g1nWFqhwhN3**Bam802sRvZjguTILo*UAH7WW1DRRG5MsTs-ZP3tOFMkQKWuJ3LRLDXtnkyN25S0LYEmH8R0vTstUmFwafeJSmm90Iuseu9DKArqrb1Wn2cZv2zgAEYy66U7kkBTQSC76WlwBJTVpoK6MUohrEll23wivbnhNaGzaSe6kWRq1ItpFkqv9gXkCAAAAuty8CgAAAAA", + "https://news.rambler.ru/moscow_city/46342947-pogoda-v-moskve-sinoptiki-poobeschali-moskvicham-silnyy-liven-blizhayshey-nochyu/?utm_source=head&utm_campaign=self_promo&utm_medium=news&utm_content=news", +}; + +Y_CPU_BENCHMARK(Parsing, iface) { + for (size_t i = 0; i < iface.Iterations(); ++i) { + for (auto&& url : URLS) { + NUri::TUri uri; + auto parseResult = uri.Parse(url, uri.FeaturesAll); + Y_DO_NOT_OPTIMIZE_AWAY(parseResult); + Y_VERIFY(parseResult == NUri::TState::ParsedOK, "cannot parse %s: %d", url.c_str(), static_cast<ui32>(parseResult)); + } + } +} + +Y_CPU_BENCHMARK(ParsingAndCopying, iface) { + for (size_t i = 0; i < iface.Iterations(); ++i) { + for (auto&& url : URLS) { + NUri::TUri uri; + auto parseResult = uri.Parse(url, uri.FeaturesAll); + Y_VERIFY(parseResult == NUri::TState::ParsedOK, "cannot parse %s: %d", url.c_str(), static_cast<ui32>(parseResult)); + auto copy = uri; + Y_DO_NOT_OPTIMIZE_AWAY(copy); + } + } +} diff --git a/library/cpp/uri/benchmark/ya.make b/library/cpp/uri/benchmark/ya.make index 77ea238de7..d83bab6b3b 100644 --- a/library/cpp/uri/benchmark/ya.make +++ b/library/cpp/uri/benchmark/ya.make @@ -1,17 +1,17 @@ -Y_BENCHMARK() - -OWNER( - svshevtsov - g:base -) - -PEERDIR( - library/cpp/testing/benchmark - library/cpp/uri -) - -SRCS( - main.cpp -) - -END() +Y_BENCHMARK() + +OWNER( + svshevtsov + g:base +) + +PEERDIR( + library/cpp/testing/benchmark + library/cpp/uri +) + +SRCS( + main.cpp +) + +END() diff --git a/library/cpp/uri/uri.cpp b/library/cpp/uri/uri.cpp index 56a9a4e5ef..2b9c7f7a39 100644 --- a/library/cpp/uri/uri.cpp +++ b/library/cpp/uri/uri.cpp @@ -126,7 +126,7 @@ namespace NUri { bool TUri::FldTryCpy(EField field, const TStringBuf& value) { if (!FldIsDirty(field)) { do { - if (!FldIsSet(field)) + if (!FldIsSet(field)) break; TStringBuf& fld = Fields[field]; @@ -160,11 +160,11 @@ namespace NUri { } if (!len) - Buffer.Clear(); + Buffer.Clear(); else { - TBuffer newbuf; - newbuf.Resize(len); - TMemoryWriteBuffer out(newbuf.data(), newbuf.size()); + TBuffer newbuf; + newbuf.Resize(len); + TMemoryWriteBuffer out(newbuf.data(), newbuf.size()); for (int i = 0; i < FieldAllMAX; ++i) { const EField fld = EField(i); if (!FldIsSet(fld)) @@ -174,9 +174,9 @@ namespace NUri { const TStringBuf& val = Fields[fld]; out << val; FldSetNoDirty(fld, TStringBuf(beg, val.length())); - out << '\0'; + out << '\0'; } - Buffer = std::move(newbuf); + Buffer = std::move(newbuf); } CheckMissingFields(); diff --git a/library/cpp/uri/uri.h b/library/cpp/uri/uri.h index 3b6c19fe4a..ee8f22175c 100644 --- a/library/cpp/uri/uri.h +++ b/library/cpp/uri/uri.h @@ -4,7 +4,7 @@ #include "encode.h" #include <library/cpp/charset/doccodes.h> -#include <util/generic/buffer.h> +#include <util/generic/buffer.h> #include <util/generic/ptr.h> #include <util/generic/singleton.h> #include <util/generic/string.h> @@ -33,7 +33,7 @@ namespace NUri { }; private: - TBuffer Buffer; + TBuffer Buffer; TStringBuf Fields[FieldAllMAX]; ui32 FieldsSet; ui16 Port; @@ -45,10 +45,10 @@ namespace NUri { private: void Alloc(size_t len) { Dealloc(); // to prevent copy below - Buffer.Resize(len); + Buffer.Resize(len); } void Dealloc() { - Buffer.Clear(); + Buffer.Clear(); } void ClearImpl() { @@ -70,7 +70,7 @@ namespace NUri { for (int i = 0; i < FieldAllMAX; ++i) Fields[i] = url.Fields[i]; - RewriteImpl(); + RewriteImpl(); } private: @@ -209,7 +209,7 @@ namespace NUri { private: bool IsInBuffer(const char* buf) const { - return buf >= Buffer.data() && buf < Buffer.data() + Buffer.size(); + return buf >= Buffer.data() && buf < Buffer.data() + Buffer.size(); } public: @@ -260,7 +260,7 @@ namespace NUri { TUri(const TStringBuf& host, ui16 port, const TStringBuf& path, const TStringBuf& query = TStringBuf(), const TStringBuf& scheme = "http", unsigned defaultPort = 0); TUri(const TUri& url) - : FieldsSet(url.FieldsSet) + : FieldsSet(url.FieldsSet) , Port(url.Port) , DefaultPort(url.DefaultPort) , Scheme(url.Scheme) diff --git a/util/datetime/base.h b/util/datetime/base.h index 5e902b8f63..4239ce2e6b 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -148,9 +148,9 @@ public: } constexpr TValue Days() const noexcept { - return Hours() / 24; - } - + return Hours() / 24; + } + constexpr TValue NanoSeconds() const noexcept { return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000; } @@ -270,7 +270,7 @@ public: return MicroSeconds((ui64)(typename NDateTimeHelpers::TPrecisionHelper<T>::THighPrecision(ms) * 1000)); } - using TBase::Days; + using TBase::Days; using TBase::Hours; using TBase::MicroSeconds; using TBase::MilliSeconds; @@ -376,7 +376,7 @@ public: return TInstant::MicroSeconds(::MicroSeconds()); } - using TBase::Days; + using TBase::Days; using TBase::Hours; using TBase::MicroSeconds; using TBase::MilliSeconds; @@ -416,11 +416,11 @@ public: return Minutes(h * 60); } - /// days since epoch + /// days since epoch static constexpr TInstant Days(ui64 d) noexcept { - return Hours(d * 24); - } - + return Hours(d * 24); + } + constexpr time_t TimeT() const noexcept { return (time_t)Seconds(); } diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index afc3f802eb..7eb7adccef 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -459,38 +459,38 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { UNIT_ASSERT_VALUES_EQUAL(value.MicroSeconds(), 1234567); } - template <class T> - void TestTimeUnits() { + template <class T> + void TestTimeUnits() { T withTime = T::MicroSeconds(1249571946000000L); T onlyMinutes = T::MicroSeconds(1249571940000000L); T onlyHours = T::MicroSeconds(1249570800000000L); T onlyDays = T::MicroSeconds(1249516800000000L); - ui64 minutes = 20826199; + ui64 minutes = 20826199; ui64 hours = 347103; - ui64 days = 14462; - - UNIT_ASSERT_VALUES_EQUAL(withTime.Minutes(), minutes); - UNIT_ASSERT_VALUES_EQUAL(onlyMinutes, T::Minutes(minutes)); - UNIT_ASSERT_VALUES_EQUAL(onlyMinutes.Minutes(), minutes); - + ui64 days = 14462; + + UNIT_ASSERT_VALUES_EQUAL(withTime.Minutes(), minutes); + UNIT_ASSERT_VALUES_EQUAL(onlyMinutes, T::Minutes(minutes)); + UNIT_ASSERT_VALUES_EQUAL(onlyMinutes.Minutes(), minutes); + UNIT_ASSERT_VALUES_EQUAL(withTime.Hours(), hours); - UNIT_ASSERT_VALUES_EQUAL(onlyMinutes.Hours(), hours); - UNIT_ASSERT_VALUES_EQUAL(onlyHours, T::Hours(hours)); + UNIT_ASSERT_VALUES_EQUAL(onlyMinutes.Hours(), hours); + UNIT_ASSERT_VALUES_EQUAL(onlyHours, T::Hours(hours)); UNIT_ASSERT_VALUES_EQUAL(onlyHours.Hours(), hours); - - UNIT_ASSERT_VALUES_EQUAL(withTime.Days(), days); - UNIT_ASSERT_VALUES_EQUAL(onlyHours.Days(), days); - UNIT_ASSERT_VALUES_EQUAL(onlyDays, T::Days(days)); - UNIT_ASSERT_VALUES_EQUAL(onlyDays.Days(), days); + + UNIT_ASSERT_VALUES_EQUAL(withTime.Days(), days); + UNIT_ASSERT_VALUES_EQUAL(onlyHours.Days(), days); + UNIT_ASSERT_VALUES_EQUAL(onlyDays, T::Days(days)); + UNIT_ASSERT_VALUES_EQUAL(onlyDays.Days(), days); } - + Y_UNIT_TEST(TestInstantUnits) { - TestTimeUnits<TInstant>(); - } - + TestTimeUnits<TInstant>(); + } + Y_UNIT_TEST(TestDurationUnits) { - TestTimeUnits<TDuration>(); - } + TestTimeUnits<TDuration>(); + } Y_UNIT_TEST(TestNoexceptConstruction) { UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception); diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..c705c7d636 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -402,49 +402,49 @@ Y_UNIT_TEST_SUITE(TYMapTest) { EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1)); EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1)); } - - struct TParametrizedKeyCmp { - bool Inverse; - - TParametrizedKeyCmp(bool inverse = false) - : Inverse(inverse) - { - } - - bool operator()(TKey lhs, TKey rhs) const { - if (Inverse) { - return lhs.m_data > rhs.m_data; - } else { - return lhs.m_data < rhs.m_data; - } - } - }; - + + struct TParametrizedKeyCmp { + bool Inverse; + + TParametrizedKeyCmp(bool inverse = false) + : Inverse(inverse) + { + } + + bool operator()(TKey lhs, TKey rhs) const { + if (Inverse) { + return lhs.m_data > rhs.m_data; + } else { + return lhs.m_data < rhs.m_data; + } + } + }; + Y_UNIT_TEST(TestMoveComparator) { using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>; - - TParametrizedKeyCmp direct(false); - TParametrizedKeyCmp inverse(true); - - { - Container c(direct); - c = Container(inverse); - + + TParametrizedKeyCmp direct(false); + TParametrizedKeyCmp inverse(true); + + { + Container c(direct); + c = Container(inverse); + c.insert(std::make_pair(TKey(1), 101)); c.insert(std::make_pair(TKey(2), 102)); c.insert(std::make_pair(TKey(3), 103)); - + TVector<int> values; for (auto& i : c) { values.push_back(i.second); - } - - UNIT_ASSERT_VALUES_EQUAL(values.size(), 3); - UNIT_ASSERT_VALUES_EQUAL(values[0], 103); - UNIT_ASSERT_VALUES_EQUAL(values[1], 102); - UNIT_ASSERT_VALUES_EQUAL(values[2], 101); - } - } + } + + UNIT_ASSERT_VALUES_EQUAL(values.size(), 3); + UNIT_ASSERT_VALUES_EQUAL(values[0], 103); + UNIT_ASSERT_VALUES_EQUAL(values[1], 102); + UNIT_ASSERT_VALUES_EQUAL(values[2], 101); + } + } Y_UNIT_TEST(TestMapInitializerList) { TMap<TString, int> m = { diff --git a/util/network/sock.h b/util/network/sock.h index b10be2f715..ec8d146287 100644 --- a/util/network/sock.h +++ b/util/network/sock.h @@ -326,7 +326,7 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr { TString GetIp() const noexcept { char ip6[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, (void*)&sin6_addr, ip6, INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (void*)&sin6_addr, ip6, INET6_ADDRSTRLEN); return TString(ip6); } diff --git a/util/system/file_lock.cpp b/util/system/file_lock.cpp index 45d91282c5..81558eb09f 100644 --- a/util/system/file_lock.cpp +++ b/util/system/file_lock.cpp @@ -1,10 +1,10 @@ #include "file_lock.h" #include "flock.h" -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #include <cerrno> - + namespace { int GetMode(const EFileLockType type) { switch (type) { @@ -29,18 +29,18 @@ void TFileLock::Acquire() { Flock(GetMode(Type)); } -bool TFileLock::TryAcquire() { - try { +bool TFileLock::TryAcquire() { + try { Flock(GetMode(Type) | LOCK_NB); - return true; - } catch (const TSystemError& e) { - if (e.Status() != EWOULDBLOCK) { - throw; - } - return false; - } -} - + return true; + } catch (const TSystemError& e) { + if (e.Status() != EWOULDBLOCK) { + throw; + } + return false; + } +} + void TFileLock::Release() { Flock(LOCK_UN); } diff --git a/util/system/file_lock.h b/util/system/file_lock.h index b2aaff5baf..5921d9a707 100644 --- a/util/system/file_lock.h +++ b/util/system/file_lock.h @@ -14,7 +14,7 @@ public: TFileLock(const TString& filename, const EFileLockType type = EFileLockType::Exclusive); void Acquire(); - bool TryAcquire(); + bool TryAcquire(); void Release(); inline void lock() { diff --git a/util/system/flock_ut.cpp b/util/system/flock_ut.cpp index b5f6cb5328..26afbbc047 100644 --- a/util/system/flock_ut.cpp +++ b/util/system/flock_ut.cpp @@ -23,10 +23,10 @@ Y_UNIT_TEST_SUITE(TFileLockTest) { { TGuard<TFileLock> guard(fileLockExclusive1); } - { + { TTryGuard<TFileLock> tryGuard(fileLockExclusive1); - UNIT_ASSERT(tryGuard.WasAcquired()); - } + UNIT_ASSERT(tryGuard.WasAcquired()); + } { TGuard<TFileLock> guard1(fileLockExclusive1); TTryGuard<TFileLock> guard2(fileLockExclusive2); diff --git a/util/system/guard.h b/util/system/guard.h index efc091d5f8..b92d6432dd 100644 --- a/util/system/guard.h +++ b/util/system/guard.h @@ -137,12 +137,12 @@ public: Init(t); } - inline TTryGuard(TTryGuard&& g) noexcept - : T_(g.T_) - { - g.T_ = nullptr; - } - + inline TTryGuard(TTryGuard&& g) noexcept + : T_(g.T_) + { + g.T_ = nullptr; + } + inline ~TTryGuard() { Release(); } diff --git a/util/system/rusage.cpp b/util/system/rusage.cpp index 2befeca875..4d15a48a7d 100644 --- a/util/system/rusage.cpp +++ b/util/system/rusage.cpp @@ -99,7 +99,7 @@ void TRusage::Fill() { } MaxRss = pmc.PeakWorkingSetSize; - MajorPageFaults = pmc.PageFaultCount; + MajorPageFaults = pmc.PageFaultCount; #else struct rusage ru; @@ -114,7 +114,7 @@ void TRusage::Fill() { #else MaxRss = ru.ru_maxrss * 1024LL; #endif - MajorPageFaults = ru.ru_majflt; + MajorPageFaults = ru.ru_majflt; Utime = ru.ru_utime; Stime = ru.ru_stime; #endif diff --git a/util/system/rusage.h b/util/system/rusage.h index 61aeca83f2..bb3725a7f7 100644 --- a/util/system/rusage.h +++ b/util/system/rusage.h @@ -10,7 +10,7 @@ struct TRusage { // some fields may be zero if unsupported ui64 MaxRss = 0; - ui64 MajorPageFaults = 0; + ui64 MajorPageFaults = 0; TDuration Utime; TDuration Stime; |