diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
561 files changed, 6907 insertions, 6907 deletions
diff --git a/library/cpp/accurate_accumulate/accurate_accumulate.h b/library/cpp/accurate_accumulate/accurate_accumulate.h index dacced17e9..87f12d632e 100644 --- a/library/cpp/accurate_accumulate/accurate_accumulate.h +++ b/library/cpp/accurate_accumulate/accurate_accumulate.h @@ -184,7 +184,7 @@ static inline double FastAccumulate(It begin, It end) { } template <typename T> -static inline double FastAccumulate(const TVector<T>& sequence) { +static inline double FastAccumulate(const TVector<T>& sequence) { return FastAccumulate(sequence.begin(), sequence.end()); } @@ -194,7 +194,7 @@ static inline double FastKahanAccumulate(It begin, It end) { } template <typename T> -static inline double FastKahanAccumulate(const TVector<T>& sequence) { +static inline double FastKahanAccumulate(const TVector<T>& sequence) { return FastKahanAccumulate(sequence.begin(), sequence.end()); } @@ -204,7 +204,7 @@ static inline double FastInnerProduct(It1 begin1, It1 end1, It2 begin2) { } template <typename T> -static inline double FastInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { +static inline double FastInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { Y_ASSERT(lhs.size() == rhs.size()); return FastInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } @@ -215,7 +215,7 @@ static inline double FastKahanInnerProduct(It1 begin1, It1 end1, It2 begin2) { } template <typename T> -static inline double FastKahanInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { +static inline double FastKahanInnerProduct(const TVector<T>& lhs, const TVector<T>& rhs) { Y_ASSERT(lhs.size() == rhs.size()); return FastKahanInnerProduct(lhs.begin(), lhs.end(), rhs.begin()); } diff --git a/library/cpp/accurate_accumulate/benchmark/main.cpp b/library/cpp/accurate_accumulate/benchmark/main.cpp index 3c5e6e775d..11f5d7d843 100644 --- a/library/cpp/accurate_accumulate/benchmark/main.cpp +++ b/library/cpp/accurate_accumulate/benchmark/main.cpp @@ -10,7 +10,7 @@ namespace { template <typename T, size_t N> struct TNormalizedExamplesHolder { - TVector<T> Examples; + TVector<T> Examples; TNormalizedExamplesHolder() : Examples(N) { @@ -23,7 +23,7 @@ namespace { template <typename T, size_t N> struct TExamplesHolder { - TVector<T> Examples; + TVector<T> Examples; TExamplesHolder() : Examples(N) { diff --git a/library/cpp/actors/core/actorsystem.cpp b/library/cpp/actors/core/actorsystem.cpp index c58698a206..3914a4a183 100644 --- a/library/cpp/actors/core/actorsystem.cpp +++ b/library/cpp/actors/core/actorsystem.cpp @@ -160,7 +160,7 @@ namespace NActors { // get high 32 bits as seconds from epoch // it could wrap every century, but we don't expect any actor-reference to live this long so such wrap will do no harm - const ui64 timeFromEpoch = TInstant::MicroSeconds(RelaxedLoad(&CurrentTimestamp)).Seconds(); + const ui64 timeFromEpoch = TInstant::MicroSeconds(RelaxedLoad(&CurrentTimestamp)).Seconds(); // get low 32 bits as counter value ui32 lowPartEnd = (ui32)(AtomicAdd(CurrentIDCounter, count)); @@ -208,7 +208,7 @@ namespace NActors { StartExecuted = true; ScheduleQueue.Reset(new NSchedulerQueue::TQueueType()); - TVector<NSchedulerQueue::TReader*> scheduleReaders; + TVector<NSchedulerQueue::TReader*> scheduleReaders; scheduleReaders.push_back(&ScheduleQueue->Reader); CpuManager->PrepareStart(scheduleReaders, this); Scheduler->Prepare(this, &CurrentTimestamp, &CurrentMonotonic); diff --git a/library/cpp/actors/core/actorsystem.h b/library/cpp/actors/core/actorsystem.h index 40499d7586..27c242ccc6 100644 --- a/library/cpp/actors/core/actorsystem.h +++ b/library/cpp/actors/core/actorsystem.h @@ -42,7 +42,7 @@ namespace NActors { namespace NSchedulerQueue { class TReader; - struct TQueueType; + struct TQueueType; } class IExecutorPool : TNonCopyable { @@ -110,7 +110,7 @@ namespace NActors { virtual void Shutdown() = 0; virtual bool Cleanup() = 0; - virtual void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const { + virtual void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const { // TODO: make pure virtual and override everywhere Y_UNUSED(poolStats); Y_UNUSED(statsCopy); @@ -173,7 +173,7 @@ namespace NActors { using TProxyWrapperFactory = std::function<TActorId(TActorSystem*, ui32)>; struct TInterconnectSetup { - TVector<TActorSetupCmd> ProxyActors; + TVector<TActorSetupCmd> ProxyActors; TProxyWrapperFactory ProxyWrapperFactory; }; @@ -229,7 +229,7 @@ namespace NActors { volatile ui64 CurrentMonotonic; volatile ui64 CurrentIDCounter; - THolder<NSchedulerQueue::TQueueType> ScheduleQueue; + THolder<NSchedulerQueue::TQueueType> ScheduleQueue; mutable TTicketLock ScheduleLock; friend class TExecutorThread; diff --git a/library/cpp/actors/core/event_load.h b/library/cpp/actors/core/event_load.h index 0dab1dd374..b8872738aa 100644 --- a/library/cpp/actors/core/event_load.h +++ b/library/cpp/actors/core/event_load.h @@ -2,7 +2,7 @@ #include <util/stream/walk.h> #include <util/system/types.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <library/cpp/actors/util/rope.h> #include <library/cpp/actors/wilson/wilson_trace.h> diff --git a/library/cpp/actors/core/event_pb_ut.cpp b/library/cpp/actors/core/event_pb_ut.cpp index a16c3092b3..fc8cb2d52c 100644 --- a/library/cpp/actors/core/event_pb_ut.cpp +++ b/library/cpp/actors/core/event_pb_ut.cpp @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TEventSerialization) { TMockEvent event; event.msg = &bm; chunker.SetSerializingEvent(&event); - char buf1[87]; + char buf1[87]; TString bmChunkedSerialized; while (!chunker.IsComplete()) { auto range = chunker.FeedBuf(&buf1[0], sizeof(buf1)); diff --git a/library/cpp/actors/core/executor_pool_basic.cpp b/library/cpp/actors/core/executor_pool_basic.cpp index 4dce16939a..77b4eca1d2 100644 --- a/library/cpp/actors/core/executor_pool_basic.cpp +++ b/library/cpp/actors/core/executor_pool_basic.cpp @@ -17,7 +17,7 @@ namespace NActors { ui32 poolId, ui32 threads, ui64 spinThreshold, - const TString& poolName, + const TString& poolName, TAffinity* affinity, TDuration timePerMailbox, ui32 eventsPerMailbox, @@ -234,7 +234,7 @@ namespace NActors { } } - void TBasicExecutorPool::GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const { + void TBasicExecutorPool::GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const { poolStats.MaxUtilizationTime = RelaxedLoad(&MaxUtilizationAccumulator) / (i64)(NHPTimer::GetCyclesPerSecond() / 1000); statsCopy.resize(PoolThreads + 1); diff --git a/library/cpp/actors/core/executor_pool_basic.h b/library/cpp/actors/core/executor_pool_basic.h index 023190f7fe..7ccd3cd179 100644 --- a/library/cpp/actors/core/executor_pool_basic.h +++ b/library/cpp/actors/core/executor_pool_basic.h @@ -95,7 +95,7 @@ namespace NActors { void PrepareStop() override; void Shutdown() override; - void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const override; + void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const override; TString GetName() const override { return PoolName; } diff --git a/library/cpp/actors/core/executor_pool_io.cpp b/library/cpp/actors/core/executor_pool_io.cpp index fb557ae6b0..49fe990374 100644 --- a/library/cpp/actors/core/executor_pool_io.cpp +++ b/library/cpp/actors/core/executor_pool_io.cpp @@ -106,7 +106,7 @@ namespace NActors { ActorSystem = actorSystem; - ScheduleQueue.Reset(new NSchedulerQueue::TQueueType()); + ScheduleQueue.Reset(new NSchedulerQueue::TQueueType()); for (ui32 i = 0; i != PoolThreads; ++i) { Threads[i].Thread.Reset(new TExecutorThread(i, 0, actorSystem, this, MailboxTable.Get(), PoolName)); diff --git a/library/cpp/actors/core/executor_pool_io.h b/library/cpp/actors/core/executor_pool_io.h index e576d642a1..651217e0c9 100644 --- a/library/cpp/actors/core/executor_pool_io.h +++ b/library/cpp/actors/core/executor_pool_io.h @@ -19,7 +19,7 @@ namespace NActors { TArrayHolder<TThreadCtx> Threads; TUnorderedCache<ui32, 512, 4> ThreadQueue; - THolder<NSchedulerQueue::TQueueType> ScheduleQueue; + THolder<NSchedulerQueue::TQueueType> ScheduleQueue; TTicketLock ScheduleLock; const TString PoolName; diff --git a/library/cpp/actors/core/executor_pool_united.h b/library/cpp/actors/core/executor_pool_united.h index a090ba2466..3d591d7ffb 100644 --- a/library/cpp/actors/core/executor_pool_united.h +++ b/library/cpp/actors/core/executor_pool_united.h @@ -126,7 +126,7 @@ namespace NActors { void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) override; void Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) override; - void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const override; + void GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const override; TString GetName() const override { return PoolName; diff --git a/library/cpp/actors/core/interconnect.h b/library/cpp/actors/core/interconnect.h index 679a4b8cc6..c26fe1b0b5 100644 --- a/library/cpp/actors/core/interconnect.h +++ b/library/cpp/actors/core/interconnect.h @@ -210,7 +210,7 @@ namespace NActors { }; struct TEvNodesInfo: public TEventLocal<TEvNodesInfo, EvNodesInfo> { - TVector<TNodeInfo> Nodes; + TVector<TNodeInfo> Nodes; const TNodeInfo* GetNodeInfo(ui32 nodeId) const { for (const auto& x : Nodes) { diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp index 5f63b5af58..6322677c68 100644 --- a/library/cpp/actors/core/log.cpp +++ b/library/cpp/actors/core/log.cpp @@ -214,7 +214,7 @@ namespace NActors { if (Settings && Settings->Satisfies(priority, component, 0ull)) { va_list params; va_start(params, c); - TString formatted; + TString formatted; vsprintf(formatted, c, params); auto ok = OutputRecord(time, NLog::EPrio(priority), component, formatted); @@ -229,7 +229,7 @@ namespace NActors { } void TLoggerActor::LogIgnoredCount(TInstant now) { - TString message = Sprintf("Ignored IgnoredCount# %" PRIu64 " log records due to logger overflow!", IgnoredCount); + TString message = Sprintf("Ignored IgnoredCount# %" PRIu64 " log records due to logger overflow!", IgnoredCount); if (!OutputRecord(now, NActors::NLog::EPrio::Error, Settings->LoggerComponent, message)) { BecomeDefunct(); } @@ -304,7 +304,7 @@ namespace NActors { void TLoggerActor::HandleLogComponentLevelRequest(TLogComponentLevelRequest::TPtr& ev, const NActors::TActorContext& ctx) { Metrics->IncLevelRequests(); - TString explanation; + TString explanation; int code = Settings->SetLevel(ev->Get()->Priority, ev->Get()->Component, explanation); ctx.Send(ev->Sender, new TLogComponentLevelResponse(code, explanation)); } @@ -475,7 +475,7 @@ namespace NActors { } } else { - TString explanation; + TString explanation; if (hasComponent && hasPriority) { Settings->SetLevel(priority, component, explanation); } @@ -675,7 +675,7 @@ namespace NActors { void WriteData(const TLogRecord& rec) override { #ifdef _MSC_VER if (IsDebuggerPresent()) { - TString x; + TString x; x.reserve(rec.Len + 2); x.append(rec.Data, rec.Len); x.append('\n'); @@ -699,7 +699,7 @@ namespace NActors { } private: - const TString Indent; + const TString Indent; }; class TLineFileLogBackend: public TFileLogBackend { @@ -739,7 +739,7 @@ namespace NActors { return new TStderrBackend(); } - TAutoPtr<TLogBackend> CreateFileBackend(const TString& fileName) { + TAutoPtr<TLogBackend> CreateFileBackend(const TString& fileName) { return new TLineFileLogBackend(fileName); } diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index c11a7cf3c1..073c233202 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -163,7 +163,7 @@ namespace NActors { protected: int Code; - TString Explanation; + TString Explanation; }; class TLogIgnored: public TEventLocal<TLogIgnored, int(NLog::EEv::Ignored)> { @@ -297,7 +297,7 @@ namespace NActors { TAutoPtr<TLogBackend> CreateSysLogBackend(const TString& ident, bool logPError, bool logCons); TAutoPtr<TLogBackend> CreateStderrBackend(); - TAutoPtr<TLogBackend> CreateFileBackend(const TString& fileName); + TAutoPtr<TLogBackend> CreateFileBackend(const TString& fileName); TAutoPtr<TLogBackend> CreateNullBackend(); TAutoPtr<TLogBackend> CreateCompositeLogBackend(TVector<TAutoPtr<TLogBackend>>&& underlyingBackends); @@ -332,7 +332,7 @@ namespace NActors { NLog::EPriority mPriority, NLog::EComponent mComponent, const char* format, TArgs&&... params) { - TString Formatted; + TString Formatted; if constexpr (sizeof... (params) > 0) { diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp index f52f2fc5d2..8f4009ae4c 100644 --- a/library/cpp/actors/core/log_settings.cpp +++ b/library/cpp/actors/core/log_settings.cpp @@ -90,7 +90,7 @@ namespace NActors { int TSettings::SetLevelImpl( const TString& name, bool isSampling, EPriority priority, EComponent component, TString& explanation) { - TString titleName(name); + TString titleName(name); titleName.to_title(); // check priority diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h index 7fe4504edd..bd8686cefd 100644 --- a/library/cpp/actors/core/log_settings.h +++ b/library/cpp/actors/core/log_settings.h @@ -75,7 +75,7 @@ namespace NActors { bool AllowDrop; TDuration ThrottleDelay; TArrayHolder<TAtomic> ComponentInfo; - TVector<TString> ComponentNames; + TVector<TString> ComponentNames; EComponent MinVal; EComponent MaxVal; EComponent Mask; @@ -90,8 +90,8 @@ namespace NActors { JSON_FORMAT }; ELogFormat Format; - TString ShortHostName; - TString ClusterName; + TString ShortHostName; + TString ClusterName; TString MessagePrefix; // The best way to provide minVal, maxVal and func is to have @@ -167,7 +167,7 @@ namespace NActors { private: int SetLevelImpl( - const TString& name, bool isSampling, + const TString& name, bool isSampling, EPriority priority, EComponent component, TString& explanation); }; diff --git a/library/cpp/actors/core/mailbox.h b/library/cpp/actors/core/mailbox.h index 0bd9c4d314..acd6e852a3 100644 --- a/library/cpp/actors/core/mailbox.h +++ b/library/cpp/actors/core/mailbox.h @@ -399,7 +399,7 @@ namespace NActors { struct THTSwapMailbox: public TMailboxHeader { using TQueueType = NThreading::THTSwapQueue<IEventHandle*>; - TQueueType Queue; + TQueueType Queue; NHPTimer::STime ScheduleMoment; char Padding_[16]; @@ -449,7 +449,7 @@ namespace NActors { struct TReadAsFilledMailbox: public TMailboxHeader { using TQueueType = NThreading::TReadAsFilledQueue<IEventHandle>; - TQueueType Queue; + TQueueType Queue; NHPTimer::STime ScheduleMoment; char Padding_[8]; @@ -498,11 +498,11 @@ namespace NActors { "expect sizeof(TReadAsFilledMailbox) == 192"); struct TTinyReadAsFilledMailbox: public TMailboxHeader { - using TQueueType = NThreading::TReadAsFilledQueue< + using TQueueType = NThreading::TReadAsFilledQueue< IEventHandle, NThreading::TRaFQueueBunchSize<4>>; - TQueueType Queue; + TQueueType Queue; NHPTimer::STime ScheduleMoment; char Padding_[8]; diff --git a/library/cpp/actors/core/mon.h b/library/cpp/actors/core/mon.h index c450f2338e..f108b370d5 100644 --- a/library/cpp/actors/core/mon.h +++ b/library/cpp/actors/core/mon.h @@ -57,7 +57,7 @@ namespace NActors { virtual EContentType GetContentType() const = 0; }; - // Ready to output HTML in TString + // Ready to output HTML in TString struct TEvHttpInfoRes: public IEvHttpInfoRes { TEvHttpInfoRes(const TString& answer, int subReqId = 0, EContentType contentType = Html) : Answer(answer) @@ -74,7 +74,7 @@ namespace NActors { return ContentType; } - const TString Answer; + const TString Answer; const int SubRequestId; const EContentType ContentType; }; @@ -83,7 +83,7 @@ namespace NActors { TEvRemoteHttpInfo() { } - TEvRemoteHttpInfo(const TString& query) + TEvRemoteHttpInfo(const TString& query) : Query(query) { } @@ -94,20 +94,20 @@ namespace NActors { { } - TString Query; + TString Query; HTTP_METHOD Method; - TString PathInfo() const { + TString PathInfo() const { const size_t pos = Query.find('?'); - return (pos == TString::npos) ? TString() : Query.substr(0, pos); + return (pos == TString::npos) ? TString() : Query.substr(0, pos); } TCgiParameters Cgi() const { const size_t pos = Query.find('?'); - return TCgiParameters((pos == TString::npos) ? TString() : Query.substr(pos + 1)); + return TCgiParameters((pos == TString::npos) ? TString() : Query.substr(pos + 1)); } - TString ToStringHeader() const override { + TString ToStringHeader() const override { return "TEvRemoteHttpInfo"; } @@ -137,14 +137,14 @@ namespace NActors { TEvRemoteHttpInfoRes() { } - TEvRemoteHttpInfoRes(const TString& html) + TEvRemoteHttpInfoRes(const TString& html) : Html(html) { } - TString Html; + TString Html; - TString ToStringHeader() const override { + TString ToStringHeader() const override { return "TEvRemoteHttpInfoRes"; } @@ -169,14 +169,14 @@ namespace NActors { TEvRemoteJsonInfoRes() { } - TEvRemoteJsonInfoRes(const TString& json) + TEvRemoteJsonInfoRes(const TString& json) : Json(json) { } - TString Json; + TString Json; - TString ToStringHeader() const override { + TString ToStringHeader() const override { return "TEvRemoteJsonInfoRes"; } @@ -201,14 +201,14 @@ namespace NActors { TEvRemoteBinaryInfoRes() { } - TEvRemoteBinaryInfoRes(const TString& blob) + TEvRemoteBinaryInfoRes(const TString& blob) : Blob(blob) { } - TString Blob; + TString Blob; - TString ToStringHeader() const override { + TString ToStringHeader() const override { return "TEvRemoteBinaryInfoRes"; } diff --git a/library/cpp/actors/core/mon_stats.h b/library/cpp/actors/core/mon_stats.h index d55552af0c..dc5c959134 100644 --- a/library/cpp/actors/core/mon_stats.h +++ b/library/cpp/actors/core/mon_stats.h @@ -76,9 +76,9 @@ namespace NActors { TLogHistogram EventDeliveryTimeHistogram; TLogHistogram EventProcessingCountHistogram; TLogHistogram EventProcessingTimeHistogram; - TVector<NHPTimer::STime> ElapsedTicksByActivity; - TVector<ui64> ReceivedEventsByActivity; - TVector<i64> ActorsAliveByActivity; // the sum should be positive, but per-thread might be negative + TVector<NHPTimer::STime> ElapsedTicksByActivity; + TVector<ui64> ReceivedEventsByActivity; + TVector<i64> ActorsAliveByActivity; // the sum should be positive, but per-thread might be negative TVector<ui64> ScheduledEventsByActivity; ui64 PoolActorRegistrations = 0; ui64 PoolDestroyedActors = 0; @@ -95,7 +95,7 @@ namespace NActors { {} template <typename T> - static void AggregateOne(TVector<T>& self, const TVector<T>& other) { + static void AggregateOne(TVector<T>& self, const TVector<T>& other) { const size_t selfSize = self.size(); const size_t otherSize = other.size(); if (selfSize < otherSize) diff --git a/library/cpp/actors/core/process_stats.cpp b/library/cpp/actors/core/process_stats.cpp index 0e1dbd0031..5c1b1bf08e 100644 --- a/library/cpp/actors/core/process_stats.cpp +++ b/library/cpp/actors/core/process_stats.cpp @@ -80,7 +80,7 @@ namespace NActors { TFileInput statm("/proc/" + strPid + "/statm"); statm.ReadLine(str); - TVector<TString> fields; + TVector<TString> fields; StringSplitter(str).Split(' ').SkipEmpty().Collect(&fields); if (fields.size() >= 7) { ui64 resident = FromString<ui64>(fields[1]); diff --git a/library/cpp/actors/core/scheduler_basic.cpp b/library/cpp/actors/core/scheduler_basic.cpp index fba200e16b..985d411db5 100644 --- a/library/cpp/actors/core/scheduler_basic.cpp +++ b/library/cpp/actors/core/scheduler_basic.cpp @@ -94,7 +94,7 @@ namespace NActors { while (!!activeSec && !activeSec->empty()) { TMomentMap::iterator it = activeSec->begin(); if (it->first <= throttledMonotonic) { - if (NSchedulerQueue::TQueueType* q = it->second.Get()) { + if (NSchedulerQueue::TQueueType* q = it->second.Get()) { while (NSchedulerQueue::TEntry* x = q->Reader.Pop()) { somethingDone = true; Y_VERIFY_DEBUG(x->InstantMicroseconds <= activeTick); @@ -151,18 +151,18 @@ namespace NActors { if (instant <= activeTick) { if (!activeSec) activeSec.Reset(new TMomentMap()); - TAutoPtr<NSchedulerQueue::TQueueType>& queue = (*activeSec)[instant]; + TAutoPtr<NSchedulerQueue::TQueueType>& queue = (*activeSec)[instant]; if (!queue) - queue.Reset(new NSchedulerQueue::TQueueType()); + queue.Reset(new NSchedulerQueue::TQueueType()); queue->Writer.Push(instant, ev, cookie); } else { const ui64 intrasecond = AlignUp<ui64>(instant, IntrasecondThreshold); TAutoPtr<TMomentMap>& msec = ScheduleMap[intrasecond]; if (!msec) msec.Reset(new TMomentMap()); - TAutoPtr<NSchedulerQueue::TQueueType>& queue = (*msec)[instant]; + TAutoPtr<NSchedulerQueue::TQueueType>& queue = (*msec)[instant]; if (!queue) - queue.Reset(new NSchedulerQueue::TQueueType()); + queue.Reset(new NSchedulerQueue::TQueueType()); queue->Writer.Push(instant, ev, cookie); } diff --git a/library/cpp/actors/core/scheduler_basic.h b/library/cpp/actors/core/scheduler_basic.h index 2ccde39235..54c193c4a1 100644 --- a/library/cpp/actors/core/scheduler_basic.h +++ b/library/cpp/actors/core/scheduler_basic.h @@ -26,7 +26,7 @@ namespace NActors { volatile bool StopFlag; - typedef TMap<ui64, TAutoPtr<NSchedulerQueue::TQueueType>> TMomentMap; // intrasecond queues + typedef TMap<ui64, TAutoPtr<NSchedulerQueue::TQueueType>> TMomentMap; // intrasecond queues typedef THashMap<ui64, TAutoPtr<TMomentMap>> TScheduleMap; // over-second schedule TScheduleMap ScheduleMap; diff --git a/library/cpp/actors/core/scheduler_queue.h b/library/cpp/actors/core/scheduler_queue.h index 3b8fac28f0..a4905e09f1 100644 --- a/library/cpp/actors/core/scheduler_queue.h +++ b/library/cpp/actors/core/scheduler_queue.h @@ -108,11 +108,11 @@ namespace NActors { } }; - struct TQueueType { + struct TQueueType { TReader Reader; TWriter Writer; - TQueueType() { + TQueueType() { Writer.Init(Reader); } }; diff --git a/library/cpp/actors/core/ya.make b/library/cpp/actors/core/ya.make index 880a9d00db..76596cdfe6 100644 --- a/library/cpp/actors/core/ya.make +++ b/library/cpp/actors/core/ya.make @@ -5,8 +5,8 @@ OWNER( g:kikimr ) -NO_WSHADOW() - +NO_WSHADOW() + IF (PROFILE_MEMORY_ALLOCATIONS) CFLAGS(-DPROFILE_MEMORY_ALLOCATIONS) ENDIF() diff --git a/library/cpp/actors/dnscachelib/dnscache.h b/library/cpp/actors/dnscachelib/dnscache.h index 3313a251a1..b7e199c3b5 100644 --- a/library/cpp/actors/dnscachelib/dnscache.h +++ b/library/cpp/actors/dnscachelib/dnscache.h @@ -21,7 +21,7 @@ public: TDnsCache(bool allowIpv4 = true, bool allowIpv6 = true, time_t entry_lifetime = 1800, time_t neg_lifetime = 1, ui32 request_timeout = 500000); ~TDnsCache(); - TString GetHostByAddr(const NAddr::IRemoteAddr&); + TString GetHostByAddr(const NAddr::IRemoteAddr&); // ip in network byte order TIpHost Get(const TString& host); @@ -43,7 +43,7 @@ protected: private: struct TGHBNContext { TDnsCache* Owner; - TString Hostname; + TString Hostname; int Family; }; @@ -56,23 +56,23 @@ private: THost() noexcept { } - TVector<TIpHost> AddrsV4; + TVector<TIpHost> AddrsV4; time_t ResolvedV4 = 0; time_t NotFoundV4 = 0; TAtomic InProgressV4 = 0; - TVector<in6_addr> AddrsV6; + TVector<in6_addr> AddrsV6; time_t ResolvedV6 = 0; time_t NotFoundV6 = 0; TAtomic InProgressV6 = 0; - TString AddrsV4ToString() const; - TString AddrsV6ToString() const; + TString AddrsV4ToString() const; + TString AddrsV6ToString() const; bool IsStale(int family, const TDnsCache* ctx) const noexcept; }; - typedef TMap<TString, THost> THostCache; + typedef TMap<TString, THost> THostCache; struct TAddr { TString Hostname; @@ -96,7 +96,7 @@ private: return false; } }; - typedef TMap<in6_addr, TAddr, TAddrCmp> TAddrCache; + typedef TMap<in6_addr, TAddr, TAddrCmp> TAddrCache; const THost& Resolve(const TString&, int family, bool cacheOnly = false); diff --git a/library/cpp/actors/dnscachelib/timekeeper.h b/library/cpp/actors/dnscachelib/timekeeper.h index 0528d8549c..73b5c20c35 100644 --- a/library/cpp/actors/dnscachelib/timekeeper.h +++ b/library/cpp/actors/dnscachelib/timekeeper.h @@ -14,7 +14,7 @@ class TTimeKeeper { public: static TInstant GetNow(void) { - return TInstant::MicroSeconds(GetTime()); + return TInstant::MicroSeconds(GetTime()); } static time_t GetTime(void) { diff --git a/library/cpp/actors/interconnect/load.cpp b/library/cpp/actors/interconnect/load.cpp index 2a8443da71..6ed6776e91 100644 --- a/library/cpp/actors/interconnect/load.cpp +++ b/library/cpp/actors/interconnect/load.cpp @@ -217,7 +217,7 @@ namespace NInterconnect { // put item into timeout queue PutTimeoutQueueItem(ctx, id); - const TDuration duration = TDuration::MicroSeconds(Params.IntervalMin.GetValue() + + const TDuration duration = TDuration::MicroSeconds(Params.IntervalMin.GetValue() + RandomNumber(Params.IntervalMax.GetValue() - Params.IntervalMin.GetValue() + 1)); if (Params.SoftLoad) { NextMessageTimestamp += duration; diff --git a/library/cpp/actors/interconnect/ya.make b/library/cpp/actors/interconnect/ya.make index 60d29b0fc0..f75cb720f0 100644 --- a/library/cpp/actors/interconnect/ya.make +++ b/library/cpp/actors/interconnect/ya.make @@ -6,8 +6,8 @@ OWNER( g:kikimr ) -NO_WSHADOW() - +NO_WSHADOW() + IF (PROFILE_MEMORY_ALLOCATIONS) CFLAGS(-DPROFILE_MEMORY_ALLOCATIONS) ENDIF() diff --git a/library/cpp/actors/memory_log/memlog.h b/library/cpp/actors/memory_log/memlog.h index 2aa27272a6..469b7aed5e 100644 --- a/library/cpp/actors/memory_log/memlog.h +++ b/library/cpp/actors/memory_log/memlog.h @@ -1,7 +1,7 @@ #pragma once #include <library/cpp/threading/queue/mpmc_unordered_ring.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/printf.h> #include <util/system/datetime.h> #include <util/system/thread.h> diff --git a/library/cpp/actors/prof/tag.cpp b/library/cpp/actors/prof/tag.cpp index 9ccf03e1a9..9c4f31f09e 100644 --- a/library/cpp/actors/prof/tag.cpp +++ b/library/cpp/actors/prof/tag.cpp @@ -64,7 +64,7 @@ namespace NProfiling { return TStringAtoms::Instance().MakeTag(s); } - ui32 MakeTags(const TVector<const char*>& ss) { + ui32 MakeTags(const TVector<const char*>& ss) { return TStringAtoms::Instance().MakeTags(ss); } diff --git a/library/cpp/actors/prof/tag.h b/library/cpp/actors/prof/tag.h index 357e264a22..9ca3dcc3a5 100644 --- a/library/cpp/actors/prof/tag.h +++ b/library/cpp/actors/prof/tag.h @@ -12,7 +12,7 @@ namespace NProfiling { ui32 MakeTag(const char* s); // Make only unique tags. Y_VERIFY inside. - ui32 MakeTags(const TVector<const char*>& ss); + ui32 MakeTags(const TVector<const char*>& ss); const char* GetTag(ui32 tag); size_t GetTagsCount(); diff --git a/library/cpp/actors/prof/ut/tag_ut.cpp b/library/cpp/actors/prof/ut/tag_ut.cpp index accf3921ab..6687959752 100644 --- a/library/cpp/actors/prof/ut/tag_ut.cpp +++ b/library/cpp/actors/prof/ut/tag_ut.cpp @@ -54,7 +54,7 @@ void TAtomTagsTest::Test_MakeAndGetTag() { } void TAtomTagsTest::Test_MakeVector() { - TVector<const char*> strs = { + TVector<const char*> strs = { "vector tag 0", "vector tag 1", "vector tag 3", diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 6fa25b9965..132b252cda 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -38,7 +38,7 @@ namespace NActors { void PrintEvent(TAutoPtr<IEventHandle>& ev, const TTestActorRuntimeBase* runtime) { Cerr << "mailbox: " << ev->GetRecipientRewrite().Hint() << ", type: " << Sprintf("%08x", ev->GetTypeRewrite()) << ", from " << ev->Sender.LocalId(); - TString name = runtime->GetActorName(ev->Sender); + TString name = runtime->GetActorName(ev->Sender); if (!name.empty()) Cerr << " \"" << name << "\""; Cerr << ", to " << ev->GetRecipientRewrite().LocalId(); @@ -473,7 +473,7 @@ namespace NActors { , ShouldContinue() , CurrentTimestamp(0) , DispatchTimeout(DEFAULT_DISPATCH_TIMEOUT) - , ReschedulingDelay(TDuration::MicroSeconds(0)) + , ReschedulingDelay(TDuration::MicroSeconds(0)) , ObserverFunc(&TTestActorRuntimeBase::DefaultObserverFunc) , ScheduledEventsSelectorFunc(&CollapsedTimeScheduledEventsSelector) , EventFilterFunc(&TTestActorRuntimeBase::DefaultFilterFunc) @@ -588,16 +588,16 @@ namespace NActors { class TScheduledTreeItem { public: - TString Name; + TString Name; ui64 Count; - TVector<TScheduledTreeItem> Children; + TVector<TScheduledTreeItem> Children; - TScheduledTreeItem(const TString& name) + TScheduledTreeItem(const TString& name) : Name(name) , Count(0) {} - TScheduledTreeItem* GetItem(const TString& name) { + TScheduledTreeItem* GetItem(const TString& name) { TScheduledTreeItem* item = nullptr; for (TScheduledTreeItem& i : Children) { if (i.Name == name) { @@ -621,8 +621,8 @@ namespace NActors { void Print(IOutputStream& stream, const TString& prefix) { for (auto it = Children.begin(); it != Children.end(); ++it) { bool lastChild = (std::next(it) == Children.end()); - TString connectionPrefix = lastChild ? "└─ " : "├─ "; - TString subChildPrefix = lastChild ? " " : "│ "; + TString connectionPrefix = lastChild ? "└─ " : "├─ "; + TString subChildPrefix = lastChild ? " " : "│ "; stream << prefix << connectionPrefix << it->Name << " (" << it->Count << ")\n"; it->Print(stream, prefix + subChildPrefix); } @@ -630,7 +630,7 @@ namespace NActors { void Print(IOutputStream& stream) { stream << Name << " (" << Count << ")\n"; - Print(stream, TString()); + Print(stream, TString()); } }; @@ -647,7 +647,7 @@ namespace NActors { runtime.ScheduledCount++; if (runtime.ScheduledCount > runtime.ScheduledLimit) { // TScheduledTreeItem root("Root"); -// TVector<TString> path; +// TVector<TString> path; // for (const auto& pr : eventTypes) { // path.clear(); // path.push_back(runtime.GetActorName(pr.first.first)); @@ -658,7 +658,7 @@ namespace NActors { // ui64 count = pr.second; // TScheduledTreeItem* item = &root; // item->Count += count; -// for (TString name : path) { +// for (TString name : path) { // item = item->GetItem(name); // item->Count += count; // } @@ -783,7 +783,7 @@ namespace NActors { TGuard<TMutex> guard(Mutex); for (ui32 nodeIndex = 0; nodeIndex < NodeCount; ++nodeIndex) { TNodeDataBase* node = Nodes[FirstNodeId + nodeIndex].Get(); - TString explanation; + TString explanation; auto status = node->LogSettings->SetLevel(priority, component, explanation); if (status) { Y_FAIL("SetLogPriority failed: %s", explanation.c_str()); @@ -1063,7 +1063,7 @@ namespace NActors { TTestActorRuntimeBase& Runtime; } DispatchContextSetter(*this, localContext); - TInstant dispatchTime = TInstant::MicroSeconds(0); + TInstant dispatchTime = TInstant::MicroSeconds(0); TInstant deadline = dispatchTime + DispatchTimeout; const TDuration scheduledEventsInspectInterval = TDuration::MilliSeconds(10); TInstant inspectScheduledEventsAt = dispatchTime + scheduledEventsInspectInterval; @@ -1152,7 +1152,7 @@ namespace NActors { isEmpty = true; auto mboxIt = startWithMboxIt; - TDeque<TEventMailboxId> suspectedBoxes; + TDeque<TEventMailboxId> suspectedBoxes; while (true) { auto& mbox = *mboxIt; bool isIgnored = true; @@ -1741,12 +1741,12 @@ namespace NActors { struct TStrandingActorDecoratorContext : public TThrRefBase { TStrandingActorDecoratorContext() - : Queue(new TQueueType) + : Queue(new TQueueType) { } - typedef TOneOneQueueInplace<IEventHandle*, 32> TQueueType; - TAutoPtr<TQueueType, TQueueType::TPtrCleanDestructor> Queue; + typedef TOneOneQueueInplace<IEventHandle*, 32> TQueueType; + TAutoPtr<TQueueType, TQueueType::TPtrCleanDestructor> Queue; }; class TStrandingActorDecorator : public TActorBootstrapped<TStrandingActorDecorator> { diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h index 26e3b45c98..178837abf9 100644 --- a/library/cpp/actors/testlib/test_runtime.h +++ b/library/cpp/actors/testlib/test_runtime.h @@ -90,9 +90,9 @@ namespace NActors { } }; - TVector<TFinalEventCondition> FinalEvents; - TVector<TEventMailboxId> NonEmptyMailboxes; - TVector<TEventMailboxId> OnlyMailboxes; + TVector<TFinalEventCondition> FinalEvents; + TVector<TEventMailboxId> NonEmptyMailboxes; + TVector<TEventMailboxId> OnlyMailboxes; std::function<bool()> CustomFinalCondition; bool Quiet = false; }; @@ -123,13 +123,13 @@ namespace NActors { static ui64 NextUniqueId; }; - typedef TDeque<TAutoPtr<IEventHandle>> TEventsList; - typedef TSet<TScheduledEventQueueItem> TScheduledEventsList; + typedef TDeque<TAutoPtr<IEventHandle>> TEventsList; + typedef TSet<TScheduledEventQueueItem> TScheduledEventsList; class TEventMailBox : public TThrRefBase { public: TEventMailBox() - : InactiveUntil(TInstant::MicroSeconds(0)) + : InactiveUntil(TInstant::MicroSeconds(0)) #ifdef DEBUG_ORDER_EVENTS , ExpectedReceive(0) , NextToSend(0) @@ -158,7 +158,7 @@ namespace NActors { TInstant InactiveUntil; TEventsList Sent; #ifdef DEBUG_ORDER_EVENTS - TMap<IEventHandle*, ui64> TrackSent; + TMap<IEventHandle*, ui64> TrackSent; ui64 ExpectedReceive; ui64 NextToSend; #endif @@ -238,7 +238,7 @@ namespace NActors { ui32 GetNodeCount() const; ui64 AllocateLocalId(); ui32 InterconnectPoolId() const; - TString GetTempDir(); + TString GetTempDir(); TActorId Register(IActor* actor, ui32 nodeIndex = 0, ui32 poolId = 0, TMailboxType::EType mailboxType = TMailboxType::Simple, ui64 revolvingCounter = 0, const TActorId& parentid = TActorId()); @@ -427,10 +427,10 @@ namespace NActors { } template <typename... TEvents> - static TString TypeNames() { - static TString names[] = { TypeName<TEvents>()... }; - TString result; - for (const TString& s : names) { + static TString TypeNames() { + static TString names[] = { TypeName<TEvents>()... }; + TString result; + for (const TString& s : names) { if (result.empty()) { result += '<'; } else { @@ -464,8 +464,8 @@ namespace NActors { void SetDispatcherRandomSeed(TInstant time, ui64 iteration); TString GetActorName(const TActorId& actorId) const; - const TVector<ui64>& GetTxAllocatorTabletIds() const { return TxAllocatorTabletIds; } - void SetTxAllocatorTabletIds(const TVector<ui64>& ids) { TxAllocatorTabletIds = ids; } + const TVector<ui64>& GetTxAllocatorTabletIds() const { return TxAllocatorTabletIds; } + void SetTxAllocatorTabletIds(const TVector<ui64>& ids) { TxAllocatorTabletIds = ids; } void SetUseRealInterconnect() { UseRealInterconnect = true; @@ -522,7 +522,7 @@ namespace NActors { TMutex Mutex; TCondVar MailboxesHasEvents; TEventMailBoxList Mailboxes; - TMap<ui32, ui64> EvCounters; + TMap<ui32, ui64> EvCounters; ui64 DispatchCyclesCount; ui64 DispatchedEventsCount; ui64 DispatchedEventsLimit = 2'500'000; @@ -566,7 +566,7 @@ namespace NActors { std::shared_ptr<void> AppData0; THolder<TActorSystem> ActorSystem; THolder<IExecutorPool> SchedulerPool; - TVector<IExecutorPool*> ExecutorPools; + TVector<IExecutorPool*> ExecutorPools; THolder<TExecutorThread> ExecutorThread; }; @@ -605,8 +605,8 @@ namespace NActors { const TDispatchOptions* Options; TDispatchContext* PrevContext; - TMap<const TDispatchOptions::TFinalEventCondition*, ui32> FinalEventFrequency; - TSet<TEventMailboxId> FoundNonEmptyMailboxes; + TMap<const TDispatchOptions::TFinalEventCondition*, ui32> FinalEventFrequency; + TSet<TEventMailboxId> FoundNonEmptyMailboxes; bool FinalEventFound = false; }; @@ -627,7 +627,7 @@ namespace NActors { THashMap<TActorId, TActorId> ScheduleWhiteListParent; THashMap<TActorId, TString> ActorNames; TDispatchContext* CurrentDispatchContext; - TVector<ui64> TxAllocatorTabletIds; + TVector<ui64> TxAllocatorTabletIds; static ui32 NextNodeId; }; diff --git a/library/cpp/actors/util/funnel_queue.h b/library/cpp/actors/util/funnel_queue.h index 0e21e2617c..0ed5d9b966 100644 --- a/library/cpp/actors/util/funnel_queue.h +++ b/library/cpp/actors/util/funnel_queue.h @@ -224,7 +224,7 @@ public: } private: - typedef TQueueType<ElementType> TBase; + typedef TQueueType<ElementType> TBase; virtual typename TBase::TEntry* NewEntry(ElementType&& element) noexcept override { AtomicAdd(Count, 1); diff --git a/library/cpp/actors/util/recentwnd.h b/library/cpp/actors/util/recentwnd.h index ba1ede6f29..5a784640cd 100644 --- a/library/cpp/actors/util/recentwnd.h +++ b/library/cpp/actors/util/recentwnd.h @@ -3,7 +3,7 @@ #include <util/generic/deque.h> template <typename TElem, - template <typename, typename...> class TContainer = TDeque> + template <typename, typename...> class TContainer = TDeque> class TRecentWnd { public: TRecentWnd(ui32 wndSize) diff --git a/library/cpp/actors/util/thread.h b/library/cpp/actors/util/thread.h index d742c8c585..c5b0dcc736 100644 --- a/library/cpp/actors/util/thread.h +++ b/library/cpp/actors/util/thread.h @@ -7,7 +7,7 @@ #include <util/system/thread.h> #include <time.h> -inline void SetCurrentThreadName(const TString& name, +inline void SetCurrentThreadName(const TString& name, const ui32 maxCharsFromProcessName = 8) { #if defined(_linux_) // linux limits threadname by 15 + \0 diff --git a/library/cpp/actors/wilson/wilson_trace.h b/library/cpp/actors/wilson/wilson_trace.h index 3d1ca50562..d893cb6e41 100644 --- a/library/cpp/actors/wilson/wilson_trace.h +++ b/library/cpp/actors/wilson/wilson_trace.h @@ -143,7 +143,7 @@ namespace NWilson { return x.TraceId == y.TraceId && x.SpanId == y.SpanId; } - TString ToString() const { + TString ToString() const { return Sprintf("%" PRIu64 ":%" PRIu64, TraceId, SpanId); } diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 1becc3e5da..34badecc37 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -41,7 +41,7 @@ static inline T ESLoad(IInputStream* in) { template <> inline TString ESLoad<TString>(IInputStream* in) { size_t len = ESLoad<ui32>(in); - TString ret; + TString ret; TTempBuf tmp; while (len) { @@ -62,7 +62,7 @@ inline TString ESLoad<TString>(IInputStream* in) { namespace { class TArchiveRecordDescriptor: public TSimpleRefCount<TArchiveRecordDescriptor> { public: - inline TArchiveRecordDescriptor(ui64 off, ui64 len, const TString& name) + inline TArchiveRecordDescriptor(ui64 off, ui64 len, const TString& name) : Off_(off) , Len_(len) , Name_(name) @@ -72,7 +72,7 @@ namespace { inline TArchiveRecordDescriptor(IInputStream* in) : Off_(ESLoad<ui64>(in)) , Len_(ESLoad<ui64>(in)) - , Name_(ESLoad<TString>(in)) + , Name_(ESLoad<TString>(in)) { } @@ -84,29 +84,29 @@ namespace { ESSave(out, Name_); } - inline const TString& Name() const noexcept { + inline const TString& Name() const noexcept { return Name_; } - inline ui64 Length() const noexcept { + inline ui64 Length() const noexcept { return Len_; } - inline ui64 Offset() const noexcept { + inline ui64 Offset() const noexcept { return Off_; } private: ui64 Off_; ui64 Len_; - TString Name_; + TString Name_; }; typedef TIntrusivePtr<TArchiveRecordDescriptor> TArchiveRecordDescriptorRef; } class TArchiveWriter::TImpl { - using TDict = THashMap<TString, TArchiveRecordDescriptorRef>; + using TDict = THashMap<TString, TArchiveRecordDescriptorRef>; public: inline TImpl(IOutputStream& out, bool compress) @@ -194,7 +194,7 @@ TArchiveWriter::TArchiveWriter(IOutputStream* out, bool compress) { } -TArchiveWriter::~TArchiveWriter() { +TArchiveWriter::~TArchiveWriter() { try { Finish(); } catch (...) { @@ -253,7 +253,7 @@ namespace { } class TArchiveReader::TImpl { - typedef THashMap<TString, TArchiveRecordDescriptorRef> TDict; + typedef THashMap<TString, TArchiveRecordDescriptorRef> TDict; public: inline TImpl(const TBlob& blob) @@ -299,11 +299,11 @@ public: } } - inline size_t Count() const noexcept { + inline size_t Count() const noexcept { return Recs_.size(); } - inline TString KeyByIndex(size_t n) const { + inline TString KeyByIndex(size_t n) const { if (n < Count()) { return Recs_[n]->Name(); } @@ -357,7 +357,7 @@ public: private: TBlob Blob_; - TVector<TArchiveRecordDescriptorRef> Recs_; + TVector<TArchiveRecordDescriptorRef> Recs_; TDict Dict_; bool UseDecompression; }; @@ -369,11 +369,11 @@ TArchiveReader::TArchiveReader(const TBlob& data) TArchiveReader::~TArchiveReader() {} -size_t TArchiveReader::Count() const noexcept { +size_t TArchiveReader::Count() const noexcept { return Impl_->Count(); } -TString TArchiveReader::KeyByIndex(size_t n) const { +TString TArchiveReader::KeyByIndex(size_t n) const { return Impl_->KeyByIndex(n); } diff --git a/library/cpp/archive/yarchive.h b/library/cpp/archive/yarchive.h index 8120bcb940..76a074f849 100644 --- a/library/cpp/archive/yarchive.h +++ b/library/cpp/archive/yarchive.h @@ -17,7 +17,7 @@ static constexpr size_t ArchiveWriterDefaultDataAlignment = 16; class TArchiveWriter { public: explicit TArchiveWriter(IOutputStream* out, bool compress = true); - ~TArchiveWriter(); + ~TArchiveWriter(); void Flush(); void Finish(); diff --git a/library/cpp/archive/yarchive_ut.cpp b/library/cpp/archive/yarchive_ut.cpp index 602a1cdbbd..bd15cf825e 100644 --- a/library/cpp/archive/yarchive_ut.cpp +++ b/library/cpp/archive/yarchive_ut.cpp @@ -26,12 +26,12 @@ UNIT_TEST_SUITE_REGISTRATION(TArchiveTest); #define ARCHIVE "./test.ar" void TArchiveTest::CreateArchive() { - TFixedBufferFileOutput out(ARCHIVE); + TFixedBufferFileOutput out(ARCHIVE); TArchiveWriter w(&out); for (size_t i = 0; i < 1000; ++i) { - const TString path = "/" + ToString(i); - const TString data = "data" + ToString(i * 1000) + "dataend"; + const TString path = "/" + ToString(i); + const TString data = "data" + ToString(i * 1000) + "dataend"; TStringInput si(data); w.Add(path, &si); @@ -55,9 +55,9 @@ void TArchiveTest::TestRead() { UNIT_ASSERT_EQUAL(r.Count(), 1000); for (size_t i = 0; i < 1000; ++i) { - const TString key = "/" + ToString(i); + const TString key = "/" + ToString(i); TAutoPtr<IInputStream> is = r.ObjectByKey(key); - const TString data = is->ReadAll(); + const TString data = is->ReadAll(); UNIT_ASSERT_EQUAL(data, "data" + ToString(i * 1000) + "dataend"); } @@ -66,15 +66,15 @@ void TArchiveTest::TestRead() { void TArchiveTest::TestOffsetOrder() { CreateArchive(); TTempFile tmpFile(ARCHIVE); - TBlob blob1 = TBlob::FromFileSingleThreaded(ARCHIVE); - TArchiveReader r(blob1); + TBlob blob1 = TBlob::FromFileSingleThreaded(ARCHIVE); + TArchiveReader r(blob1); const void* prevOffset = nullptr; for (size_t i = 0; i < r.Count(); ++i) { - const TString key = r.KeyByIndex(i); - TBlob blob2 = r.BlobByKey(key); - const void* offset = blob2.Data(); + const TString key = r.KeyByIndex(i); + TBlob blob2 = r.BlobByKey(key); + const void* offset = blob2.Data(); if (i) { UNIT_ASSERT(prevOffset < offset); diff --git a/library/cpp/balloc/balloc.cpp b/library/cpp/balloc/balloc.cpp index fab489db4c..9b66786728 100644 --- a/library/cpp/balloc/balloc.cpp +++ b/library/cpp/balloc/balloc.cpp @@ -109,7 +109,7 @@ extern "C" void free(void* data) { #define OP_THROWNOTHING #endif -void* operator new(size_t size) { +void* operator new(size_t size) { #if defined(Y_COVER_PTR) return malloc(size); #else @@ -168,7 +168,7 @@ void operator delete(void* p, const std::nothrow_t&)OP_THROWNOTHING { #endif } -void* operator new[](size_t size) { +void* operator new[](size_t size) { #if defined(Y_COVER_PTR) return malloc(size); #else diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412424889f..5e6db69bf7 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -247,7 +247,7 @@ private: DataChunkStr(data, sizeof(char)); } void DataChunkStroka(TString& data) { - DataChunkStr(data, sizeof(TString::char_type)); + DataChunkStr(data, sizeof(TString::char_type)); } void DataChunkWtroka(TUtf16String& data) { DataChunkStr(data, sizeof(wchar16)); @@ -281,7 +281,7 @@ private: typedef THashMap<ui64, TPtr<IObjectBase>> CObjectsHash; TAutoPtr<CObjectsHash> Objects; - TVector<IObjectBase*> ObjectQueue; + TVector<IObjectBase*> ObjectQueue; public: bool IsReading() { @@ -390,7 +390,7 @@ public: Add(2, &nSize); } int i = 1; - for (typename TList<T1>::iterator k = data.begin(); k != data.end(); ++k, ++i) + for (typename TList<T1>::iterator k = data.begin(); k != data.end(); ++k, ++i) Add(i + 2, &(*k)); return 0; } @@ -542,7 +542,7 @@ public: template <class T> static bool HasNonTrivialSerializer(...) { - return sizeof(std::declval<IBinSaver*>()->Add(0, std::declval<T*>())) != 1; + return sizeof(std::declval<IBinSaver*>()->Add(0, std::declval<T*>())) != 1; } public: @@ -625,19 +625,19 @@ struct TRegisterSaveLoadType { return 0; \ } -#define SAVELOAD_OVERRIDE_WITHOUT_BASE(...) \ - int operator&(IBinSaver& f) override { \ - f.AddMulti(__VA_ARGS__); \ - return 0; \ - } - -#define SAVELOAD_OVERRIDE(base, ...) \ - int operator&(IBinSaver& f) override { \ - base::operator&(f); \ - f.AddMulti(__VA_ARGS__); \ - return 0; \ +#define SAVELOAD_OVERRIDE_WITHOUT_BASE(...) \ + int operator&(IBinSaver& f) override { \ + f.AddMulti(__VA_ARGS__); \ + return 0; \ } +#define SAVELOAD_OVERRIDE(base, ...) \ + int operator&(IBinSaver& f) override { \ + base::operator&(f); \ + f.AddMulti(__VA_ARGS__); \ + return 0; \ + } + #define SAVELOAD_BASE(...) \ int operator&(IBinSaver& f) { \ TBase::operator&(f); \ diff --git a/library/cpp/binsaver/class_factory.h b/library/cpp/binsaver/class_factory.h index e83512331b..5e9958a3d8 100644 --- a/library/cpp/binsaver/class_factory.h +++ b/library/cpp/binsaver/class_factory.h @@ -2,7 +2,7 @@ #include <typeinfo> #include <util/generic/hash.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/ysafeptr.h> diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 37eba5406f..b8cffcf5e3 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -13,30 +13,30 @@ struct TBinarySerializable { struct TNonBinarySerializable { ui32 Data = 0; - TString StrData; + TString StrData; }; struct TCustomSerializer { ui32 Data = 0; - TString StrData; + TString StrData; SAVELOAD(StrData, Data); }; struct TCustomOuterSerializer { ui32 Data = 0; - TString StrData; + TString StrData; }; void operator&(TCustomOuterSerializer& s, IBinSaver& f); struct TCustomOuterSerializerTmpl { ui32 Data = 0; - TString StrData; + TString StrData; }; struct TCustomOuterSerializerTmplDerived: public TCustomOuterSerializerTmpl { ui32 Data = 0; - TString StrData; + TString StrData; }; struct TMoveOnlyType { @@ -52,7 +52,7 @@ struct TMoveOnlyType { struct TTypeWithArray { ui32 Data = 1; - TString Array[2][2]{{"test", "data"}, {"and", "more"}}; + TString Array[2][2]{{"test", "data"}, {"and", "more"}}; SAVELOAD(Data, Array); bool operator==(const TTypeWithArray& obj) const { diff --git a/library/cpp/bit_io/bitinout_ut.cpp b/library/cpp/bit_io/bitinout_ut.cpp index 23a1ddf344..2a95022605 100644 --- a/library/cpp/bit_io/bitinout_ut.cpp +++ b/library/cpp/bit_io/bitinout_ut.cpp @@ -19,8 +19,8 @@ namespace NBitIO { return bytes << 3ULL; } - inline TString PrintBits(const char* a, const char* b, bool reverse = false) { - TString s; + inline TString PrintBits(const char* a, const char* b, bool reverse = false) { + TString s; TStringOutput out(s); for (const char* it = a; it != b; ++it) { if (it != a) @@ -40,7 +40,7 @@ namespace NBitIO { } template <typename T> - inline TString PrintBits(T t, ui32 bits = Bits(sizeof(T))) { + inline TString PrintBits(T t, ui32 bits = Bits(sizeof(T))) { return PrintBits((char*)&t, ((char*)&t) + BytesUp(bits)); } } @@ -52,9 +52,9 @@ class TBitIOTest: public TTestBase { private: using TBi = NBitIO::TBitInput; - using TVec = TVector<char>; + using TVec = TVector<char>; - void static CheckBits(const TVec& v, const TString& ref, const TString& rem) { + void static CheckBits(const TVec& v, const TString& ref, const TString& rem) { UNIT_ASSERT_VALUES_EQUAL_C(NBitIO::PrintBits(v.begin(), v.end()), ref, rem); } @@ -80,7 +80,7 @@ private: } template <typename TBo> - void DoWrite1(TBo& out, const TString& rem) { + void DoWrite1(TBo& out, const TString& rem) { out.Write(0x0C, 3); UNIT_ASSERT_VALUES_EQUAL_C(out.GetOffset(), 1u, (rem + ", " + ToString(__LINE__))); out.Write(0x18, 4); @@ -94,7 +94,7 @@ private: } template <typename TBo> - void DoWrite2(TBo& out, const TString& rem) { + void DoWrite2(TBo& out, const TString& rem) { out.Write(0x0C, 3); UNIT_ASSERT_VALUES_EQUAL_C(out.GetOffset(), 8u, (rem + ", " + ToString(__LINE__))); @@ -120,7 +120,7 @@ private: UNIT_ASSERT_VALUES_EQUAL_C(out.GetOffset(), 41u, (rem + ", " + ToString(__LINE__))); } - void DoBitOutput(NBitIO::TBitOutputYVector& out, const TString& rem) { + void DoBitOutput(NBitIO::TBitOutputYVector& out, const TString& rem) { DoWrite1(out, rem); out.WriteWords<8>(0xabcdef); @@ -129,7 +129,7 @@ private: DoWrite2(out, rem); } - void DoBitOutput(NBitIO::TBitOutputArray& out, const TString& rem) { + void DoBitOutput(NBitIO::TBitOutputArray& out, const TString& rem) { DoWrite1(out, rem); out.WriteWords<8>(0xabcdef); @@ -138,7 +138,7 @@ private: DoWrite2(out, rem); } - void DoBitInput(TBi& in, const TString& rem) { + void DoBitInput(TBi& in, const TString& rem) { UNIT_ASSERT(!in.Eof()); { diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index 2b886c1f02..e7d205ad94 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -169,7 +169,7 @@ namespace NBitIO { } }; - using TBitOutputYVector = TBitOutputVector<TVector<char>>; + using TBitOutputYVector = TBitOutputVector<TVector<char>>; class TBitOutputStreamImpl { IOutputStream* Out; diff --git a/library/cpp/blockcodecs/codecs/brotli/brotli.cpp b/library/cpp/blockcodecs/codecs/brotli/brotli.cpp index 6e3cd971bd..a23765b0d4 100644 --- a/library/cpp/blockcodecs/codecs/brotli/brotli.cpp +++ b/library/cpp/blockcodecs/codecs/brotli/brotli.cpp @@ -59,7 +59,7 @@ namespace { struct TBrotliRegistrar { TBrotliRegistrar() { for (int i = 1; i <= TBrotliCodec::BEST_QUALITY; ++i) { - RegisterCodec(MakeHolder<TBrotliCodec>(i)); + RegisterCodec(MakeHolder<TBrotliCodec>(i)); } } }; diff --git a/library/cpp/blockcodecs/codecs/bzip/bzip.cpp b/library/cpp/blockcodecs/codecs/bzip/bzip.cpp index 3a5cfdd0e9..230165e817 100644 --- a/library/cpp/blockcodecs/codecs/bzip/bzip.cpp +++ b/library/cpp/blockcodecs/codecs/bzip/bzip.cpp @@ -53,7 +53,7 @@ namespace { struct TBZipRegistrar { TBZipRegistrar() { for (int i = 1; i < 10; ++i) { - RegisterCodec(MakeHolder<TBZipCodec>(i)); + RegisterCodec(MakeHolder<TBZipCodec>(i)); } RegisterAlias("bzip2", "bzip2-6"); } diff --git a/library/cpp/blockcodecs/codecs/fastlz/fastlz.cpp b/library/cpp/blockcodecs/codecs/fastlz/fastlz.cpp index da2831fbd2..49c8bb5902 100644 --- a/library/cpp/blockcodecs/codecs/fastlz/fastlz.cpp +++ b/library/cpp/blockcodecs/codecs/fastlz/fastlz.cpp @@ -45,7 +45,7 @@ namespace { struct TFastLZRegistrar { TFastLZRegistrar() { for (int i = 0; i < 3; ++i) { - RegisterCodec(MakeHolder<TFastLZCodec>(i)); + RegisterCodec(MakeHolder<TFastLZCodec>(i)); } RegisterAlias("fastlz", "fastlz-0"); } diff --git a/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp b/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp index 042f031679..0416ff964f 100644 --- a/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp +++ b/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp @@ -23,7 +23,7 @@ namespace { return ret; } - static inline size_t DoMaxCompressedLength(size_t l) noexcept { + static inline size_t DoMaxCompressedLength(size_t l) noexcept { return ZSTD_compressBound(l); } @@ -39,18 +39,18 @@ namespace { } } - TStringBuf Name() const noexcept override { + TStringBuf Name() const noexcept override { return MyName; } const unsigned Level; - const TString MyName; + const TString MyName; }; struct TZStd06Registrar { TZStd06Registrar() { for (unsigned i = 1; i <= ZSTD_maxCLevel(); ++i) { - RegisterCodec(MakeHolder<TZStd06Codec>(i)); + RegisterCodec(MakeHolder<TZStd06Codec>(i)); } } }; diff --git a/library/cpp/blockcodecs/codecs/lz4/lz4.cpp b/library/cpp/blockcodecs/codecs/lz4/lz4.cpp index fbf0fe110f..f800b50316 100644 --- a/library/cpp/blockcodecs/codecs/lz4/lz4.cpp +++ b/library/cpp/blockcodecs/codecs/lz4/lz4.cpp @@ -101,16 +101,16 @@ namespace { THolder<T2> t2(new T2(i)); if (t1->Methods) { - RegisterCodec(std::move(t1)); + RegisterCodec(std::move(t1)); } if (t2->Methods) { - RegisterCodec(std::move(t2)); + RegisterCodec(std::move(t2)); } } - RegisterCodec(MakeHolder<TLz4Codec<TLz4BestCompress, TLz4FastDecompress>>()); - RegisterCodec(MakeHolder<TLz4Codec<TLz4BestCompress, TLz4SafeDecompress>>()); + RegisterCodec(MakeHolder<TLz4Codec<TLz4BestCompress, TLz4FastDecompress>>()); + RegisterCodec(MakeHolder<TLz4Codec<TLz4BestCompress, TLz4SafeDecompress>>()); RegisterAlias("lz4-fast-safe", "lz4-fast14-safe"); RegisterAlias("lz4-fast-fast", "lz4-fast14-fast"); diff --git a/library/cpp/blockcodecs/codecs/lzma/lzma.cpp b/library/cpp/blockcodecs/codecs/lzma/lzma.cpp index 6c8d5fded4..ab3a2466f5 100644 --- a/library/cpp/blockcodecs/codecs/lzma/lzma.cpp +++ b/library/cpp/blockcodecs/codecs/lzma/lzma.cpp @@ -65,7 +65,7 @@ namespace { struct TLzmaRegistrar { TLzmaRegistrar() { for (int i = 0; i < 10; ++i) { - RegisterCodec(MakeHolder<TLzmaCodec>(i)); + RegisterCodec(MakeHolder<TLzmaCodec>(i)); } RegisterAlias("lzma", "lzma-5"); } diff --git a/library/cpp/blockcodecs/codecs/snappy/snappy.cpp b/library/cpp/blockcodecs/codecs/snappy/snappy.cpp index f6be05a05f..44d8c140a4 100644 --- a/library/cpp/blockcodecs/codecs/snappy/snappy.cpp +++ b/library/cpp/blockcodecs/codecs/snappy/snappy.cpp @@ -45,7 +45,7 @@ namespace { struct TSnappyRegistrar { TSnappyRegistrar() { - RegisterCodec(MakeHolder<TSnappyCodec>()); + RegisterCodec(MakeHolder<TSnappyCodec>()); } }; const TSnappyRegistrar Registrar{}; diff --git a/library/cpp/blockcodecs/codecs/zlib/zlib.cpp b/library/cpp/blockcodecs/codecs/zlib/zlib.cpp index cdb556c36d..fc1f602d9f 100644 --- a/library/cpp/blockcodecs/codecs/zlib/zlib.cpp +++ b/library/cpp/blockcodecs/codecs/zlib/zlib.cpp @@ -55,7 +55,7 @@ namespace { struct TZLibRegistrar { TZLibRegistrar() { for (int i = 0; i < 10; ++i) { - RegisterCodec(MakeHolder<TZLibCodec>(i)); + RegisterCodec(MakeHolder<TZLibCodec>(i)); } RegisterAlias("zlib", "zlib-6"); } diff --git a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp index 95299b3f6d..3f905c8687 100644 --- a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp +++ b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp @@ -50,7 +50,7 @@ namespace { struct TZStd08Registrar { TZStd08Registrar() { for (int i = 1; i <= ZSTD_maxCLevel(); ++i) { - RegisterCodec(MakeHolder<TZStd08Codec>(i)); + RegisterCodec(MakeHolder<TZStd08Codec>(i)); RegisterAlias("zstd_" + ToString(i), "zstd08_" + ToString(i)); } } diff --git a/library/cpp/blockcodecs/codecs_ut.cpp b/library/cpp/blockcodecs/codecs_ut.cpp index bfe5a23690..d5e167b85e 100644 --- a/library/cpp/blockcodecs/codecs_ut.cpp +++ b/library/cpp/blockcodecs/codecs_ut.cpp @@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } void TestAllAtOnce(size_t n, size_t m) { - TVector<TBuffer> datas; + TVector<TBuffer> datas; datas.emplace_back(); datas.push_back(Buffer("na gorshke sidel korol")); @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { for (size_t j = 0; j < datas.size(); ++j) { const TBuffer& data = datas[j]; - TString res; + TString res; try { TBuffer e, d; @@ -144,11 +144,11 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { } void TestStreams(size_t n, size_t m) { - TVector<TString> datas; - TString res; + TVector<TString> datas; + TString res; for (size_t i = 0; i < 256; ++i) { - datas.push_back(TString(i, (char)(i % 128))); + datas.push_back(TString(i, (char)(i % 128))); } for (size_t i = 0; i < datas.size(); ++i) { @@ -178,7 +178,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { out.Finish(); } - const TString resNew = TDecodedInput(&ss).ReadAll(); + const TString resNew = TDecodedInput(&ss).ReadAll(); try { UNIT_ASSERT_EQUAL(resNew, res); diff --git a/library/cpp/blockcodecs/core/codecs.cpp b/library/cpp/blockcodecs/core/codecs.cpp index 21506e812b..072da37087 100644 --- a/library/cpp/blockcodecs/core/codecs.cpp +++ b/library/cpp/blockcodecs/core/codecs.cpp @@ -61,8 +61,8 @@ namespace { TDeque<TString> Tmp; TNullCodec Null; - TVector<TCodecPtr> Codecs; - typedef THashMap<TStringBuf, ICodec*> TRegistry; + TVector<TCodecPtr> Codecs; + typedef THashMap<TStringBuf, ICodec*> TRegistry; TRegistry Registry; // SEARCH-8344: Global decompressed size limiter (to prevent remote DoS) @@ -82,7 +82,7 @@ TCodecList NBlockCodecs::ListAllCodecs() { return ret; } -TString NBlockCodecs::ListAllCodecsAsString() { +TString NBlockCodecs::ListAllCodecsAsString() { return JoinSeq(TStringBuf(","), ListAllCodecs()); } @@ -127,7 +127,7 @@ void ICodec::Decode(const TData& in, TBuffer& out) const { out.Resize(Decompress(in, out.Data())); } -void ICodec::Encode(const TData& in, TString& out) const { +void ICodec::Encode(const TData& in, TString& out) const { const size_t maxLen = MaxCompressedLength(in); out.ReserveAndResize(maxLen); @@ -136,7 +136,7 @@ void ICodec::Encode(const TData& in, TString& out) const { out.resize(actualLen); } -void ICodec::Decode(const TData& in, TString& out) const { +void ICodec::Decode(const TData& in, TString& out) const { const size_t maxLen = GetDecompressedLength(in); out.ReserveAndResize(maxLen); diff --git a/library/cpp/blockcodecs/core/codecs.h b/library/cpp/blockcodecs/core/codecs.h index 9c93c00274..878678d5c7 100644 --- a/library/cpp/blockcodecs/core/codecs.h +++ b/library/cpp/blockcodecs/core/codecs.h @@ -2,7 +2,7 @@ #include <util/generic/buffer.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/typetraits.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -45,25 +45,25 @@ namespace NBlockCodecs { virtual size_t Compress(const TData& in, void* out) const = 0; virtual size_t Decompress(const TData& in, void* out) const = 0; - virtual TStringBuf Name() const noexcept = 0; + virtual TStringBuf Name() const noexcept = 0; // some useful helpers void Encode(const TData& in, TBuffer& out) const; void Decode(const TData& in, TBuffer& out) const; - void Encode(const TData& in, TString& out) const; - void Decode(const TData& in, TString& out) const; + void Encode(const TData& in, TString& out) const; + void Decode(const TData& in, TString& out) const; - inline TString Encode(const TData& in) const { - TString out; + inline TString Encode(const TData& in) const { + TString out; Encode(in, out); return out; } - inline TString Decode(const TData& in) const { - TString out; + inline TString Decode(const TData& in) const { + TString out; Decode(in, out); @@ -78,9 +78,9 @@ namespace NBlockCodecs { const ICodec* Codec(const TStringBuf& name); // some aux methods - typedef TVector<TStringBuf> TCodecList; + typedef TVector<TStringBuf> TCodecList; TCodecList ListAllCodecs(); - TString ListAllCodecsAsString(); + TString ListAllCodecsAsString(); // SEARCH-8344: Get the size of max possible decompressed block size_t GetMaxPossibleDecompressedLength(); diff --git a/library/cpp/blockcodecs/core/common.h b/library/cpp/blockcodecs/core/common.h index f05df4d334..8e1dabb593 100644 --- a/library/cpp/blockcodecs/core/common.h +++ b/library/cpp/blockcodecs/core/common.h @@ -55,7 +55,7 @@ namespace NBlockCodecs { return in.size(); } - TStringBuf Name() const noexcept override { + TStringBuf Name() const noexcept override { return TStringBuf("null"); } }; @@ -98,7 +98,7 @@ namespace NBlockCodecs { return len; } - inline const T* Base() const noexcept { + inline const T* Base() const noexcept { return static_cast<const T*>(this); } }; diff --git a/library/cpp/blockcodecs/core/stream.cpp b/library/cpp/blockcodecs/core/stream.cpp index 4f7db3c32b..856400b5a1 100644 --- a/library/cpp/blockcodecs/core/stream.cpp +++ b/library/cpp/blockcodecs/core/stream.cpp @@ -51,7 +51,7 @@ namespace { ythrow yexception() << "can not find codec by id " << id; } - typedef THashMap<TCodecID, const ICodec*> TByID; + typedef THashMap<TCodecID, const ICodec*> TByID; TByID ByID; }; @@ -74,7 +74,7 @@ TCodedOutput::TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen) } } -TCodedOutput::~TCodedOutput() { +TCodedOutput::~TCodedOutput() { try { Finish(); } catch (...) { diff --git a/library/cpp/blockcodecs/core/stream.h b/library/cpp/blockcodecs/core/stream.h index fd44ef88f2..92ccd10333 100644 --- a/library/cpp/blockcodecs/core/stream.h +++ b/library/cpp/blockcodecs/core/stream.h @@ -12,7 +12,7 @@ namespace NBlockCodecs { class TCodedOutput: public IOutputStream { public: TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); - ~TCodedOutput() override; + ~TCodedOutput() override; private: void DoWrite(const void* buf, size_t len) override; @@ -33,7 +33,7 @@ namespace NBlockCodecs { TDecodedInput(IInputStream* in); TDecodedInput(IInputStream* in, const ICodec* codec); - ~TDecodedInput() override; + ~TDecodedInput() override; private: size_t DoUnboundedNext(const void** ptr) override; diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index 6dc997076d..f79be81fa5 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -81,7 +81,7 @@ public: } TItem* GetOldest() { - typename TListType::TIterator it = List.Begin(); + typename TListType::TIterator it = List.Begin(); Y_ASSERT(it != List.End()); return &*it; } @@ -116,8 +116,8 @@ public: } private: - typedef TIntrusiveList<TItem> TListType; - TListType List; + typedef TIntrusiveList<TItem> TListType; + TListType List; TSizeProvider SizeProvider; size_t ItemsAmount; size_t TotalSize; @@ -189,7 +189,7 @@ public: } TItem* GetLeastFrequentlyUsed() { - typename TListType::TIterator it = List.Begin(); + typename TListType::TIterator it = List.Begin(); Y_ASSERT(it != List.End()); return &*it; } @@ -201,7 +201,7 @@ public: void Promote(TItem* item) { size_t counter = ++item->Counter; - typename TListType::TIterator it = item; + typename TListType::TIterator it = item; while (it != List.End() && counter >= it->Counter) { ++it; } @@ -223,8 +223,8 @@ public: } private: - typedef TIntrusiveList<TItem> TListType; - TListType List; + typedef TIntrusiveList<TItem> TListType; + TListType List; size_t ListSize; size_t MaxSize; }; @@ -366,18 +366,18 @@ private: } private: - TVector<TItem*> Heap; - THashSet<TItem*> Removed; + TVector<TItem*> Heap; + THashSet<TItem*> Removed; size_t Size; size_t MaxSize; }; -template <typename TKey, typename TValue, typename TListType, typename TDeleter> +template <typename TKey, typename TValue, typename TListType, typename TDeleter> class TCache { - typedef typename TListType::TItem TItem; + typedef typename TListType::TItem TItem; typedef typename TItem::THash THash; - typedef THashMultiSet<TItem, THash> TIndex; + typedef THashMultiSet<TItem, THash> TIndex; typedef typename TIndex::iterator TIndexIterator; typedef typename TIndex::const_iterator TIndexConstIterator; @@ -418,7 +418,7 @@ public: return Iter->Value; } - friend class TCache<TKey, TValue, TListType, TDeleter>; + friend class TCache<TKey, TValue, TListType, TDeleter>; private: TIndexConstIterator Iter; @@ -547,7 +547,7 @@ public: protected: TIndex Index; - TListType List; + TListType List; bool MultiValue; TIterator FindByItem(TItem* item) { @@ -570,7 +570,7 @@ protected: struct TNoopDelete { template <class T> - static inline void Destroy(const T&) noexcept { + static inline void Destroy(const T&) noexcept { } }; diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index 329872cfde..33dacbc565 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> struct TStrokaWeighter { - static size_t Weight(const TString& s) { + static size_t Weight(const TString& s) { return s.size(); } }; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST(SimpleTest) { - typedef TLRUCache<int, TString> TCache; + typedef TLRUCache<int, TString> TCache; TCache s(2); // size 2 s.Insert(1, "abcd"); UNIT_ASSERT(s.Find(1) != s.End()); @@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST(MultiCacheTest) { - typedef TLRUCache<int, TString> TCache; + typedef TLRUCache<int, TString> TCache; TCache s(3, true); UNIT_ASSERT(s.Insert(1, "abcd")); UNIT_ASSERT(s.Insert(1, "bcde")); @@ -358,7 +358,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { - typedef TThreadSafeCache<ui32, TString, ui32> TCache; + typedef TThreadSafeCache<ui32, TString, ui32> TCache; const char* VALS[] = {"abcd", "defg", "hjkl"}; @@ -369,7 +369,7 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { } TValue* CreateObject(ui32 i) const override { Creations++; - return new TString(VALS[i]); + return new TString(VALS[i]); } mutable i32 Creations = 0; diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index f3277b8e4b..c5b735cffb 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -5,7 +5,7 @@ #include <util/generic/singleton.h> -TCgiParameters::TCgiParameters(std::initializer_list<std::pair<TString, TString>> il) { +TCgiParameters::TCgiParameters(std::initializer_list<std::pair<TString, TString>> il) { for (const auto& item : il) { insert(item); } @@ -14,7 +14,7 @@ TCgiParameters::TCgiParameters(std::initializer_list<std::pair<TString, TString> const TString& TCgiParameters::Get(const TStringBuf name, size_t numOfValue) const noexcept { const auto it = Find(name, numOfValue); - return end() == it ? Default<TString>() : it->second; + return end() == it ? Default<TString>() : it->second; } bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { @@ -63,10 +63,10 @@ void TCgiParameters::JoinUnescaped(const TStringBuf key, char sep, TStringBuf va if (it == pair.second) { // not found if (val.IsInited()) { - emplace_hint(it, TString(key), TString(val)); + emplace_hint(it, TString(key), TString(val)); } } else { - TString& dst = it->second; + TString& dst = it->second; for (++it; it != pair.second; erase(it++)) { dst += sep; @@ -80,8 +80,8 @@ void TCgiParameters::JoinUnescaped(const TStringBuf key, char sep, TStringBuf va } } -static inline TString DoUnescape(const TStringBuf s) { - TString res; +static inline TString DoUnescape(const TStringBuf s) { + TString res; res.reserve(CgiUnescapeBufLen(s.size())); res.ReserveAndResize(CgiUnescape(res.begin(), s).size()); @@ -139,8 +139,8 @@ void TCgiParameters::ScanAddAll(const TStringBuf query) { DoScan<true>(query, f); } -TString TCgiParameters::Print() const { - TString res; +TString TCgiParameters::Print() const { + TString res; res.reserve(PrintSize()); const char* end = Print(res.begin()); @@ -169,7 +169,7 @@ char* TCgiParameters::Print(char* res) const { return res; } -size_t TCgiParameters::PrintSize() const noexcept { +size_t TCgiParameters::PrintSize() const noexcept { size_t res = size(); // for '&' for (const auto& i : *this) { diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index 87d1ab0ad4..572393082c 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -5,18 +5,18 @@ #include <util/generic/iterator_range.h> #include <util/generic/map.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <initializer_list> struct TStringLess { template <class T1, class T2> - inline bool operator()(const T1& t1, const T2& t2) const noexcept { + inline bool operator()(const T1& t1, const T2& t2) const noexcept { return TStringBuf(t1) < TStringBuf(t2); } }; -class TCgiParameters: public TMultiMap<TString, TString> { +class TCgiParameters: public TMultiMap<TString, TString> { public: TCgiParameters() = default; @@ -24,7 +24,7 @@ public: Scan(cgiParamStr); } - TCgiParameters(std::initializer_list<std::pair<TString, TString>> il); + TCgiParameters(std::initializer_list<std::pair<TString, TString>> il); void Flush() { erase(begin(), end()); @@ -36,7 +36,7 @@ public: return count(name); } - TString operator()() const { + TString operator()() const { return Print(); } @@ -51,11 +51,11 @@ public: * @note The returned string has format <name1>=<value1>&<name2>=<value2>&... * @note Names and values in the returned string are CGI-escaped. */ - TString Print() const; + TString Print() const; char* Print(char* res) const; Y_PURE_FUNCTION - size_t PrintSize() const noexcept; + size_t PrintSize() const noexcept; /** The same as Print* except that RFC-3986 reserved characters are escaped. * @param safe - set of characters to be skipped in escaping diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a562342084..1c7f783a17 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { } Y_UNIT_TEST(TestScan2) { - const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd"); + const TString parsee("=000&aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { } Y_UNIT_TEST(TestScan3) { - const TString parsee("aaa=bbb&ag0=&ccc=ddd"); + const TString parsee("aaa=bbb&ag0=&ccc=ddd"); TCgiParameters c; c.Scan(parsee); diff --git a/library/cpp/cgiparam/fuzz/ya.make b/library/cpp/cgiparam/fuzz/ya.make index 8fb9d50d3b..4c549c7c1e 100644 --- a/library/cpp/cgiparam/fuzz/ya.make +++ b/library/cpp/cgiparam/fuzz/ya.make @@ -9,8 +9,8 @@ SRCS( main.cpp ) -PEERDIR( +PEERDIR( library/cpp/cgiparam -) - +) + END() diff --git a/library/cpp/cgiparam/ut/ya.make b/library/cpp/cgiparam/ut/ya.make index 1eee403951..894d4da1a9 100644 --- a/library/cpp/cgiparam/ut/ya.make +++ b/library/cpp/cgiparam/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/cgiparam) - -OWNER(g:util) - -SRCS( - cgiparam_ut.cpp -) - -END() + +OWNER(g:util) + +SRCS( + cgiparam_ut.cpp +) + +END() diff --git a/library/cpp/cgiparam/ya.make b/library/cpp/cgiparam/ya.make index fa1a6a13c0..d3fd5b5b50 100644 --- a/library/cpp/cgiparam/ya.make +++ b/library/cpp/cgiparam/ya.make @@ -1,16 +1,16 @@ -LIBRARY() - -OWNER(g:util) - -SRCS( - cgiparam.cpp - cgiparam.h -) - -PEERDIR( +LIBRARY() + +OWNER(g:util) + +SRCS( + cgiparam.cpp + cgiparam.h +) + +PEERDIR( library/cpp/iterator library/cpp/string_utils/quote library/cpp/string_utils/scan -) - -END() +) + +END() diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 6097e40131..9efa3e21cd 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -1,41 +1,41 @@ -#include "ci_string.h" - -int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { +#include "ci_string.h" + +int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { return cp.stricmp(s1.data(), s2.data()); -} - -int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { +} + +int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { return cp.stricmp(p, s2.data()); -} - -int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { +} + +int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { return cp.stricmp(s1.data(), p); -} - +} + int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { int rv = cp.strnicmp(p1.data(), p2.data(), Min(p1.size(), p2.size())); return rv ? rv : p1.size() < p2.size() ? -1 : p1.size() == p2.size() ? 0 : 1; -} - +} + bool TCiString::is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { size_t len = what.size(); return len <= of.size() && cp.strnicmp(what.data(), of.data(), len) == 0; -} - +} + bool TCiString::is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { size_t len = what.size(); size_t slen = of.size(); return (len <= slen) && (0 == cp.strnicmp(what.data(), of.data() + slen - len, len)); -} - -size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { - size_t h = len; - for (; /* (*s) && */ len--; ++s) - h = 5 * h + cp.ToLower(*s); - return h; -} - -template <> +} + +size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { + size_t h = len; + for (; /* (*s) && */ len--; ++s) + h = 5 * h + cp.ToLower(*s); + return h; +} + +template <> void Out<TCiString>(IOutputStream& o, const TCiString& p) { o.Write(p.data(), p.size()); -} +} diff --git a/library/cpp/charset/ci_string.h b/library/cpp/charset/ci_string.h index edf24c1b6f..aaa1e5627c 100644 --- a/library/cpp/charset/ci_string.h +++ b/library/cpp/charset/ci_string.h @@ -1,280 +1,280 @@ -#pragma once - -#include "codepage.h" - -#include <util/generic/string.h> -#include <util/str_stl.h> - -// Same as TString but uses CASE INSENSITIVE comparator and hash. Use with care. -class TCiString: public TString { -public: - TCiString() { - } - - TCiString(const TString& s) - : TString(s) - { - } - - TCiString(const TString& s, size_t pos, size_t n) - : TString(s, pos, n) - { - } - - TCiString(const char* pc) - : TString(pc) - { - } - - TCiString(const char* pc, size_t n) - : TString(pc, n) - { - } - - TCiString(const char* pc, size_t pos, size_t n) - : TString(pc, pos, n) - { - } - - TCiString(size_t n, char c) - : TString(n, c) - { - } - - TCiString(const TUninitialized& uninitialized) - : TString(uninitialized) - { - } - - TCiString(const char* b, const char* e) - : TString(b, e) - { - } - +#pragma once + +#include "codepage.h" + +#include <util/generic/string.h> +#include <util/str_stl.h> + +// Same as TString but uses CASE INSENSITIVE comparator and hash. Use with care. +class TCiString: public TString { +public: + TCiString() { + } + + TCiString(const TString& s) + : TString(s) + { + } + + TCiString(const TString& s, size_t pos, size_t n) + : TString(s, pos, n) + { + } + + TCiString(const char* pc) + : TString(pc) + { + } + + TCiString(const char* pc, size_t n) + : TString(pc, n) + { + } + + TCiString(const char* pc, size_t pos, size_t n) + : TString(pc, pos, n) + { + } + + TCiString(size_t n, char c) + : TString(n, c) + { + } + + TCiString(const TUninitialized& uninitialized) + : TString(uninitialized) + { + } + + TCiString(const char* b, const char* e) + : TString(b, e) + { + } + explicit TCiString(const TStringBuf& s) - : TString(s) - { - } - - // ~~~ Comparison ~~~ : FAMILY0(int, compare) - static int compare(const TCiString& s1, const TCiString& s2, const CodePage& cp = csYandex); - static int compare(const char* p, const TCiString& s2, const CodePage& cp = csYandex); - static int compare(const TCiString& s1, const char* p, const CodePage& cp = csYandex); + : TString(s) + { + } + + // ~~~ Comparison ~~~ : FAMILY0(int, compare) + static int compare(const TCiString& s1, const TCiString& s2, const CodePage& cp = csYandex); + static int compare(const char* p, const TCiString& s2, const CodePage& cp = csYandex); + static int compare(const TCiString& s1, const char* p, const CodePage& cp = csYandex); static int compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp = csYandex); - + // TODO: implement properly in TString via enum ECaseSensitivity static bool is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); static bool is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); - + bool StartsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { - return is_prefix(s, *this, cp); - } - + return is_prefix(s, *this, cp); + } + bool EndsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { - return is_suffix(s, *this, cp); - } - - friend bool operator==(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) == 0; - } - - friend bool operator==(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) == 0; - } - - friend bool operator==(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) == 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator==(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { - return TCiString::compare(s, pc) == 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator==(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { - return TCiString::compare(pc, s) == 0; - } - - friend bool operator!=(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) != 0; - } - - friend bool operator!=(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) != 0; - } - - friend bool operator!=(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) != 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator!=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { - return TCiString::compare(s, pc) != 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator!=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { - return TCiString::compare(pc, s) != 0; - } - - friend bool operator<(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) < 0; - } - - friend bool operator<(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) < 0; - } - - friend bool operator<(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) < 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator<(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { - return TCiString::compare(s, pc) < 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator<(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { - return TCiString::compare(pc, s) < 0; - } - - friend bool operator<=(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) <= 0; - } - - friend bool operator<=(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) <= 0; - } - - friend bool operator<=(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) <= 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator<=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { - return TCiString::compare(s, pc) <= 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator<=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { - return TCiString::compare(pc, s) <= 0; - } - - friend bool operator>(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) > 0; - } - - friend bool operator>(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) > 0; - } - - friend bool operator>(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) > 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator>(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) noexcept { - return TCiString::compare(s, pc) > 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator>(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) noexcept { - return TCiString::compare(pc, s) > 0; - } - - friend bool operator>=(const TCiString& s1, const TCiString& s2) { - return TCiString::compare(s1, s2) >= 0; - } - - friend bool operator>=(const TCiString& s, const char* pc) { - return TCiString::compare(s, pc) >= 0; - } - - friend bool operator>=(const char* pc, const TCiString& s) { - return TCiString::compare(pc, s) >= 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator>=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { - return TCiString::compare(s, pc) >= 0; - } - - template <typename TDerived2, typename TTraits2> - friend bool operator>=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { - return TCiString::compare(pc, s) >= 0; - } - - static size_t hashVal(const char* pc, size_t len, const CodePage& cp = csYandex); - - size_t hash() const { + return is_suffix(s, *this, cp); + } + + friend bool operator==(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) == 0; + } + + friend bool operator==(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) == 0; + } + + friend bool operator==(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) == 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator==(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { + return TCiString::compare(s, pc) == 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator==(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { + return TCiString::compare(pc, s) == 0; + } + + friend bool operator!=(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) != 0; + } + + friend bool operator!=(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) != 0; + } + + friend bool operator!=(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) != 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator!=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { + return TCiString::compare(s, pc) != 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator!=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { + return TCiString::compare(pc, s) != 0; + } + + friend bool operator<(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) < 0; + } + + friend bool operator<(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) < 0; + } + + friend bool operator<(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) < 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator<(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { + return TCiString::compare(s, pc) < 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator<(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { + return TCiString::compare(pc, s) < 0; + } + + friend bool operator<=(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) <= 0; + } + + friend bool operator<=(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) <= 0; + } + + friend bool operator<=(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) <= 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator<=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { + return TCiString::compare(s, pc) <= 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator<=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { + return TCiString::compare(pc, s) <= 0; + } + + friend bool operator>(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) > 0; + } + + friend bool operator>(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) > 0; + } + + friend bool operator>(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) > 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator>(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) noexcept { + return TCiString::compare(s, pc) > 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator>(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) noexcept { + return TCiString::compare(pc, s) > 0; + } + + friend bool operator>=(const TCiString& s1, const TCiString& s2) { + return TCiString::compare(s1, s2) >= 0; + } + + friend bool operator>=(const TCiString& s, const char* pc) { + return TCiString::compare(s, pc) >= 0; + } + + friend bool operator>=(const char* pc, const TCiString& s) { + return TCiString::compare(pc, s) >= 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator>=(const TCiString& s, const TStringBase<TDerived2, TChar, TTraits2>& pc) { + return TCiString::compare(s, pc) >= 0; + } + + template <typename TDerived2, typename TTraits2> + friend bool operator>=(const TStringBase<TDerived2, TChar, TTraits2>& pc, const TCiString& s) { + return TCiString::compare(pc, s) >= 0; + } + + static size_t hashVal(const char* pc, size_t len, const CodePage& cp = csYandex); + + size_t hash() const { return TCiString::hashVal(data(), length()); - } -}; - -struct ci_hash { - inline size_t operator()(const char* s) const { - return TCiString::hashVal(s, strlen(s)); - } + } +}; + +struct ci_hash { + inline size_t operator()(const char* s) const { + return TCiString::hashVal(s, strlen(s)); + } inline size_t operator()(const TStringBuf& s) const { return TCiString::hashVal(s.data(), s.size()); - } -}; - -struct ci_hash32 { // not the same as ci_hash under 64-bit - inline ui32 operator()(const char* s) const { - return (ui32)TCiString::hashVal(s, strlen(s)); - } -}; - -//template <class T> struct hash; - -template <> -struct hash<TCiString>: public ci_hash { -}; - -template <class T> -struct TCIHash { -}; - -template <> -struct TCIHash<const char*> { + } +}; + +struct ci_hash32 { // not the same as ci_hash under 64-bit + inline ui32 operator()(const char* s) const { + return (ui32)TCiString::hashVal(s, strlen(s)); + } +}; + +//template <class T> struct hash; + +template <> +struct hash<TCiString>: public ci_hash { +}; + +template <class T> +struct TCIHash { +}; + +template <> +struct TCIHash<const char*> { inline size_t operator()(const TStringBuf& s) const { return TCiString::hashVal(s.data(), s.size()); - } -}; - -template <> -struct TCIHash<TStringBuf> { - inline size_t operator()(const TStringBuf& s) const { + } +}; + +template <> +struct TCIHash<TStringBuf> { + inline size_t operator()(const TStringBuf& s) const { return TCiString::hashVal(s.data(), s.size()); - } -}; - -template <> -struct TCIHash<TString> { - inline size_t operator()(const TString& s) const { + } +}; + +template <> +struct TCIHash<TString> { + inline size_t operator()(const TString& s) const { return TCiString::hashVal(s.data(), s.size()); - } -}; - -struct ci_less { - inline bool operator()(const char* x, const char* y) const { - return csYandex.stricmp(x, y) < 0; - } -}; - -struct ci_equal_to { - inline bool operator()(const char* x, const char* y) const { - return csYandex.stricmp(x, y) == 0; - } - // this implementation is not suitable for strings with zero characters inside, sorry + } +}; + +struct ci_less { + inline bool operator()(const char* x, const char* y) const { + return csYandex.stricmp(x, y) < 0; + } +}; + +struct ci_equal_to { + inline bool operator()(const char* x, const char* y) const { + return csYandex.stricmp(x, y) == 0; + } + // this implementation is not suitable for strings with zero characters inside, sorry bool operator()(const TStringBuf& x, const TStringBuf& y) const { return x.size() == y.size() && csYandex.strnicmp(x.data(), y.data(), y.size()) == 0; - } -}; - -template <> -struct TEqualTo<TCiString>: public ci_equal_to { -}; + } +}; + +template <> +struct TEqualTo<TCiString>: public ci_equal_to { +}; diff --git a/library/cpp/charset/ci_string_ut.cpp b/library/cpp/charset/ci_string_ut.cpp index 3d2a53d5fe..693427184d 100644 --- a/library/cpp/charset/ci_string_ut.cpp +++ b/library/cpp/charset/ci_string_ut.cpp @@ -1,23 +1,23 @@ -#include "ci_string.h" - +#include "ci_string.h" + #include <util/generic/hash.h> -#include <util/generic/string_ut.h> - -class TCaseStringTest: public TTestBase, private TStringTestImpl<TCiString, TTestData<char>> { -public: - void TestSpecial() { - TCiString ss = Data._0123456(); // type 'TCiString' is used as is +#include <util/generic/string_ut.h> + +class TCaseStringTest: public TTestBase, private TStringTestImpl<TCiString, TTestData<char>> { +public: + void TestSpecial() { + TCiString ss = Data._0123456(); // type 'TCiString' is used as is size_t hash_val = ComputeHash(ss); - UNIT_ASSERT(hash_val == 1489244); - } - -public: - UNIT_TEST_SUITE(TCaseStringTest); - UNIT_TEST(TestOperators); - UNIT_TEST(TestOperatorsCI); - - UNIT_TEST(TestSpecial); - UNIT_TEST_SUITE_END(); -}; - -UNIT_TEST_SUITE_REGISTRATION(TCaseStringTest); + UNIT_ASSERT(hash_val == 1489244); + } + +public: + UNIT_TEST_SUITE(TCaseStringTest); + UNIT_TEST(TestOperators); + UNIT_TEST(TestOperatorsCI); + + UNIT_TEST(TestSpecial); + UNIT_TEST_SUITE_END(); +}; + +UNIT_TEST_SUITE_REGISTRATION(TCaseStringTest); diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index 0431bef31b..43c0650970 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -1,4 +1,4 @@ -#include "ci_string.h" +#include "ci_string.h" #include "wide.h" #include "recyr.hh" #include "codepage.h" @@ -9,7 +9,7 @@ #include <util/system/hi_lo.h> #include <util/system/yassert.h> #include <util/generic/hash.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/hash_set.h> #include <util/generic/singleton.h> @@ -128,13 +128,13 @@ const NCodepagePrivate::TCodepagesMap& NCodepagePrivate::TCodepagesMap::Instance class TCodePageHash { private: - using TData = THashMap<TStringBuf, ECharset, ci_hash, ci_equal_to>; + using TData = THashMap<TStringBuf, ECharset, ci_hash, ci_equal_to>; TData Data; TMemoryPool Pool; private: - inline void AddNameWithCheck(const TString& name, ECharset code) { + inline void AddNameWithCheck(const TString& name, ECharset code) { if (Data.find(name.c_str()) == Data.end()) { Data.insert(TData::value_type(Pool.Append(name.data(), name.size() + 1), code)); } else { @@ -142,10 +142,10 @@ private: } } - inline void AddName(const TString& name, ECharset code) { + inline void AddName(const TString& name, ECharset code) { AddNameWithCheck(name, code); - TString temp = name; + TString temp = name; RemoveAll(temp, '-'); RemoveAll(temp, '_'); AddNameWithCheck(temp, code); @@ -163,7 +163,7 @@ public: inline TCodePageHash() : Pool(20 * 1024) /* Currently used: 17KB. */ { - TString xPrefix = "x-"; + TString xPrefix = "x-"; const char* name; for (size_t i = 0; i != CODES_MAX; ++i) { @@ -285,7 +285,7 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { TxChar* s = str; TxChar* d = str; - TVector<char> buf; + TVector<char> buf; size_t read = 0; size_t written = 0; @@ -319,19 +319,19 @@ void DecodeUnknownPlane(wchar32* str, wchar32*& ee, const ECharset enc) { } namespace { - class THashSetType: public THashSet<TString> { + class THashSetType: public THashSet<TString> { public: - inline void Add(const TString& s) { + inline void Add(const TString& s) { insert(s); } - inline bool Has(const TString& s) const noexcept { + inline bool Has(const TString& s) const noexcept { return find(s) != end(); } }; } -class TWindowsPrefixesHashSet: public THashSetType { +class TWindowsPrefixesHashSet: public THashSetType { public: inline TWindowsPrefixesHashSet() { Add("win"); @@ -345,7 +345,7 @@ public: } }; -class TCpPrefixesHashSet: public THashSetType { +class TCpPrefixesHashSet: public THashSetType { public: inline TCpPrefixesHashSet() { Add("microsoft"); @@ -354,7 +354,7 @@ public: } }; -class TIsoPrefixesHashSet: public THashSetType { +class TIsoPrefixesHashSet: public THashSetType { public: inline TIsoPrefixesHashSet() { Add("iso"); @@ -363,7 +363,7 @@ public: } }; -class TLatinToIsoHash: public THashMap<const char*, TString, ci_hash, ci_equal_to> { +class TLatinToIsoHash: public THashMap<const char*, TString, ci_hash, ci_equal_to> { public: inline TLatinToIsoHash() { insert(value_type("latin1", "iso-8859-1")); @@ -379,12 +379,12 @@ public: } }; -static inline void NormalizeEncodingPrefixes(TString& enc) { +static inline void NormalizeEncodingPrefixes(TString& enc) { size_t preflen = enc.find_first_of("0123456789"); - if (preflen == TString::npos) + if (preflen == TString::npos) return; - TString prefix = enc.substr(0, preflen); + TString prefix = enc.substr(0, preflen); for (size_t i = 0; i < prefix.length(); ++i) { if (prefix[i] == '-') { prefix.remove(i--); @@ -410,7 +410,7 @@ static inline void NormalizeEncodingPrefixes(TString& enc) { if (Singleton<TIsoPrefixesHashSet>()->Has(prefix)) { if (enc.length() == preflen + 1 || enc.length() == preflen + 2) { - TString enccopy = enc.substr(preflen); + TString enccopy = enc.substr(preflen); enccopy.prepend("latin"); const TLatinToIsoHash* latinhash = Singleton<TLatinToIsoHash>(); TLatinToIsoHash::const_iterator it = latinhash->find(enccopy.data()); @@ -425,7 +425,7 @@ static inline void NormalizeEncodingPrefixes(TString& enc) { } } -class TEncodingNamesHashSet: public THashSetType { +class TEncodingNamesHashSet: public THashSetType { public: TEncodingNamesHashSet() { Add("iso-8859-1"); @@ -492,7 +492,7 @@ ECharset EncodingHintByName(const char* encname) { --lastpos; // Do some normalization - TString enc(encname, lastpos - encname + 1); + TString enc(encname, lastpos - encname + 1); enc.to_lower(); for (char* p = enc.begin(); p != enc.end(); ++p) { if (*p == ' ' || *p == '=' || *p == '_') diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h index 30a02a4610..8af579bdb5 100644 --- a/library/cpp/charset/codepage.h +++ b/library/cpp/charset/codepage.h @@ -5,7 +5,7 @@ #include <util/charset/recode_result.h> #include <util/charset/unidata.h> // all wchar32 functions #include <util/charset/utf8.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ylimits.h> #include <util/generic/yexception.h> #include <util/system/yassert.h> @@ -303,17 +303,17 @@ inline void ToUpper(char* s, size_t n, const CodePage& cp = csYandex) { *s = cp.ToUpper(*s); } -inline TString ToLower(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { +inline TString ToLower(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { s.Transform([&cp](size_t, char c) { return cp.ToLower(c); }, pos, n); return s; } -inline TString ToUpper(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { +inline TString ToUpper(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { s.Transform([&cp](size_t, char c) { return cp.ToUpper(c); }, pos, n); return s; } -inline TString ToTitle(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { +inline TString ToTitle(TString s, const CodePage& cp, size_t pos = 0, size_t n = TString::npos) { s.Transform( [pos, &cp](size_t i, char c) { return i == pos ? cp.ToTitle(c) : cp.ToLower(c); diff --git a/library/cpp/charset/codepage_ut.cpp b/library/cpp/charset/codepage_ut.cpp index c3ac3ac478..9015535324 100644 --- a/library/cpp/charset/codepage_ut.cpp +++ b/library/cpp/charset/codepage_ut.cpp @@ -253,7 +253,7 @@ void TCodepageTest::TestUTFFromUnknownPlane() { // test TChar version // bytebuffer of len writtenbytes contains sampletext of len samplelen chars in utf8 - TUtf16String wtr = CharToWide(TStringBuf(bytebuffer, writtenbytes), CODES_UNKNOWNPLANE); + TUtf16String wtr = CharToWide(TStringBuf(bytebuffer, writtenbytes), CODES_UNKNOWNPLANE); TChar* strend = wtr.begin() + wtr.size(); DecodeUnknownPlane(wtr.begin(), strend, CODES_UTF8); wtr.resize(strend - wtr.data(), 'Q'); diff --git a/library/cpp/charset/iconv_ut.cpp b/library/cpp/charset/iconv_ut.cpp index e8c56f6d49..eb6a0f64e0 100644 --- a/library/cpp/charset/iconv_ut.cpp +++ b/library/cpp/charset/iconv_ut.cpp @@ -4,13 +4,13 @@ #include <library/cpp/testing/unittest/registar.h> -static void TestIconv(const TString& utf8, const TString& other, ECharset enc) { - TUtf16String wide0 = CharToWide(utf8, CODES_UTF8); - TUtf16String wide1 = CharToWide(other, enc); +static void TestIconv(const TString& utf8, const TString& other, ECharset enc) { + TUtf16String wide0 = CharToWide(utf8, CODES_UTF8); + TUtf16String wide1 = CharToWide(other, enc); UNIT_ASSERT(wide0 == wide1); - TString temp = WideToUTF8(wide0); + TString temp = WideToUTF8(wide0); UNIT_ASSERT(temp == utf8); temp = WideToChar(wide0, enc); diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh index 5ec8734bcf..e0af996ae9 100644 --- a/library/cpp/charset/recyr.hh +++ b/library/cpp/charset/recyr.hh @@ -110,7 +110,7 @@ inline RECODE_RESULT Recode(ECharset from, ECharset to, const char* in, char* ou * @return false if conversion was not attempted (charsets were the same), * true if successful */ -inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& out) { +inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& out) { if (to == from) return false; @@ -132,23 +132,23 @@ inline bool Recode(ECharset from, ECharset to, const TStringBuf& in, TString& ou } /////////////////////////////////////////////////////////////////////////////////////// -// TString -> TString // +// TString -> TString // /////////////////////////////////////////////////////////////////////////////////////// -inline TString Recode(ECharset from, ECharset to, const TString& in) { - TString out; +inline TString Recode(ECharset from, ECharset to, const TString& in) { + TString out; return to != from && Recode(from, to, in, out) ? out : in; } -inline TString RecodeToYandex(ECharset from, const TString& in) { +inline TString RecodeToYandex(ECharset from, const TString& in) { return Recode(from, CODES_YANDEX, in); } -inline TString RecodeFromYandex(ECharset to, const TString& in) { +inline TString RecodeFromYandex(ECharset to, const TString& in) { return Recode(CODES_YANDEX, to, in); } -inline TString RecodeToHTMLEntities(ECharset from, const TString& in) { +inline TString RecodeToHTMLEntities(ECharset from, const TString& in) { RECODE_RESULT res; size_t outWritten, inRead; - TString out; + TString out; out.resize(in.length() * (4 + 4)); res = NCodepagePrivate::_recodeToHTMLEntities(from, in.c_str(), out.begin(), in.length(), out.length(), inRead, outWritten); if (res == RECODE_EOOUTPUT) { //input contains many 8-byte characters? diff --git a/library/cpp/charset/recyr_int.hh b/library/cpp/charset/recyr_int.hh index 353af53305..61239206bc 100644 --- a/library/cpp/charset/recyr_int.hh +++ b/library/cpp/charset/recyr_int.hh @@ -3,7 +3,7 @@ #include <util/charset/recode_result.h> #include <util/charset/utf8.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/system/defaults.h> #include "codepage.h" diff --git a/library/cpp/charset/wide.h b/library/cpp/charset/wide.h index 32d30e849e..46f7b16d76 100644 --- a/library/cpp/charset/wide.h +++ b/library/cpp/charset/wide.h @@ -7,7 +7,7 @@ #include <util/charset/unidata.h> #include <util/charset/utf8.h> #include <util/charset/wide.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/algorithm.h> #include <util/generic/yexception.h> #include <util/memory/tempbuf.h> @@ -123,7 +123,7 @@ namespace NDetail { struct TRecodeTraits<char> { using TCharTo = wchar16; using TStringBufTo = TWtringBuf; - using TStringTo = TUtf16String; + using TStringTo = TUtf16String; enum { ReserveSize = 4 }; // How many TCharFrom characters we should reserve for one TCharTo character in worst case // Here an unicode character can be converted up to 4 bytes of UTF8 }; @@ -132,14 +132,14 @@ namespace NDetail { struct TRecodeTraits<wchar16> { using TCharTo = char; using TStringBufTo = TStringBuf; - using TStringTo = TString; + using TStringTo = TString; enum { ReserveSize = 2 }; // possible surrogate pairs ? }; // Operations with destination buffer where recoded string will be written template <typename TResult> struct TRecodeResultOps { - // default implementation will work with TString and TUtf16String - 99% of usage + // default implementation will work with TString and TUtf16String - 99% of usage using TResultChar = typename TResult::char_type; static inline size_t Size(const TResult& dst) { @@ -223,18 +223,18 @@ inline TStringBuf WideToChar(const TWtringBuf src, TString& dst, ECharset encodi } //! calls either to @c WideToUTF8 or @c WideToChar depending on the encoding type -inline TString WideToChar(const wchar16* text, size_t len, ECharset enc) { +inline TString WideToChar(const wchar16* text, size_t len, ECharset enc) { if (NCodepagePrivate::NativeCodepage(enc)) { if (enc == CODES_UTF8) return WideToUTF8(text, len); - TString s = TString::Uninitialized(len); + TString s = TString::Uninitialized(len); s.remove(WideToChar(text, len, s.begin(), enc)); return s; } - TString s = TString::Uninitialized(len * 3); + TString s = TString::Uninitialized(len * 3); size_t read = 0; size_t written = 0; @@ -244,15 +244,15 @@ inline TString WideToChar(const wchar16* text, size_t len, ECharset enc) { return s; } -inline TUtf16String CharToWide(const char* text, size_t len, const CodePage& cp) { - TUtf16String w = TUtf16String::Uninitialized(len); +inline TUtf16String CharToWide(const char* text, size_t len, const CodePage& cp) { + TUtf16String w = TUtf16String::Uninitialized(len); CharToWide(text, len, w.begin(), cp); return w; } //! calls either to @c UTF8ToWide or @c CharToWide depending on the encoding type template <bool robust> -inline TUtf16String CharToWide(const char* text, size_t len, ECharset enc) { +inline TUtf16String CharToWide(const char* text, size_t len, ECharset enc) { if (NCodepagePrivate::NativeCodepage(enc)) { if (enc == CODES_UTF8) return UTF8ToWide<robust>(text, len); @@ -260,7 +260,7 @@ inline TUtf16String CharToWide(const char* text, size_t len, ECharset enc) { return CharToWide(text, len, *CodePageByCharset(enc)); } - TUtf16String w = TUtf16String::Uninitialized(len * 2); + TUtf16String w = TUtf16String::Uninitialized(len * 2); size_t read = 0; size_t written = 0; @@ -274,8 +274,8 @@ inline TUtf16String CharToWide(const char* text, size_t len, ECharset enc) { //! @param text text to be converted //! @param len length of the text in characters //! @param cp a codepage that is used in case of failed conversion from UTF8 -inline TUtf16String UTF8ToWide(const char* text, size_t len, const CodePage& cp) { - TUtf16String w = TUtf16String::Uninitialized(len); +inline TUtf16String UTF8ToWide(const char* text, size_t len, const CodePage& cp) { + TUtf16String w = TUtf16String::Uninitialized(len); size_t written = 0; if (UTF8ToWide(text, len, w.begin(), written)) w.remove(written); diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 78947d51ba..518b885b6c 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -32,16 +32,16 @@ namespace { "\xd1\x80\xd1\x81\xd1\x82\xd1\x83\xd1\x84\xd1\x85\xd1\x86\xd1\x87" "\xd1\x88\xd1\x89\xd1\x8a\xd1\x8b\xd1\x8c\xd1\x8d\xd1\x8e\xd1\x8f"; - TString CreateYandexText() { + TString CreateYandexText() { const int len = 256; char text[len] = {0}; for (int i = 0; i < len; ++i) { text[i] = static_cast<char>(i); } - return TString(text, len); + return TString(text, len); } - TUtf16String CreateUnicodeText() { + TUtf16String CreateUnicodeText() { const int len = 256; wchar16 text[len] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F @@ -65,10 +65,10 @@ namespace { text[i] = static_cast<wchar16>(i + 0x0350); // 0x0410 - 0x044F } } - return TUtf16String(text, len); + return TUtf16String(text, len); } - TString CreateUTF8Text() { + TString CreateUTF8Text() { char text[] = { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', @@ -95,12 +95,12 @@ namespace { '\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86', '\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e', '\xd1', '\x8f'}; - return TString(text, Y_ARRAY_SIZE(text)); + return TString(text, Y_ARRAY_SIZE(text)); } //! use this function to dump UTF8 text into a file in case of any changes // void DumpUTF8Text() { - // TString s = WideToUTF8(UnicodeText); + // TString s = WideToUTF8(UnicodeText); // std::ofstream f("utf8.txt"); // f << std::hex; // for (int i = 0; i < (int)s.size(); ++i) { @@ -117,9 +117,9 @@ namespace { class TConversionTest: public TTestBase { private: //! @note every of the text can have zeros in the middle - const TString YandexText; - const TUtf16String UnicodeText; - const TString UTF8Text; + const TString YandexText; + const TUtf16String UnicodeText; + const TString UTF8Text; private: UNIT_TEST_SUITE(TConversionTest); @@ -171,7 +171,7 @@ UNIT_TEST_SUITE_REGISTRATION(TConversionTest); } while (false) void TConversionTest::TestCharToWide() { - TUtf16String w = CharToWide(YandexText, CODES_YANDEX); + TUtf16String w = CharToWide(YandexText, CODES_YANDEX); UNIT_ASSERT(w.size() == 256); UNIT_ASSERT(w.size() == UnicodeText.size()); @@ -182,7 +182,7 @@ void TConversionTest::TestCharToWide() { } void TConversionTest::TestWideToChar() { - TString s = WideToChar(UnicodeText, CODES_YANDEX); + TString s = WideToChar(UnicodeText, CODES_YANDEX); UNIT_ASSERT(s.size() == 256); UNIT_ASSERT(s.size() == YandexText.size()); @@ -193,18 +193,18 @@ void TConversionTest::TestWideToChar() { } static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize, ECharset enc) { - TUtf16String w = UTF8ToWide(str); + TUtf16String w = UTF8ToWide(str); UNIT_ASSERT(w.size() == wideSize); UNIT_ASSERT(!memcmp(w.c_str(), wide, wideSize)); - TString s = WideToChar(w, enc); + TString s = WideToChar(w, enc); UNIT_ASSERT(s == str); } void TConversionTest::TestYandexEncoding() { - TUtf16String w = UTF8ToWide(utf8CyrillicAlphabet, strlen(utf8CyrillicAlphabet), csYandex); + TUtf16String w = UTF8ToWide(utf8CyrillicAlphabet, strlen(utf8CyrillicAlphabet), csYandex); UNIT_ASSERT(w == wideCyrillicAlphabet); w = UTF8ToWide(yandexCyrillicAlphabet, strlen(yandexCyrillicAlphabet), csYandex); UNIT_ASSERT(w == wideCyrillicAlphabet); @@ -217,7 +217,7 @@ void TConversionTest::TestYandexEncoding() { const char* yandexNonBMP2 = "ab?n"; UNIT_ASSERT(yandexNonBMP2 == WideToChar(wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_YANDEX)); - TString temp; + TString temp; temp.resize(Y_ARRAY_SIZE(wNonBMPDummy2)); size_t read = 0; size_t written = 0; @@ -229,7 +229,7 @@ void TConversionTest::TestYandexEncoding() { } void TConversionTest::TestRecodeIntoString() { - TString sYandex(UnicodeText.size() * 4, 'x'); + TString sYandex(UnicodeText.size() * 4, 'x'); const char* sdata = sYandex.data(); TStringBuf sres = NDetail::Recode<wchar16>(UnicodeText, sYandex, CODES_YANDEX); UNIT_ASSERT(sYandex == YandexText); // same content @@ -238,7 +238,7 @@ void TConversionTest::TestRecodeIntoString() { UNIT_ASSERT(sYandex.size() == sres.size()); // same size TEST_WCHAR32(sYandex, UnicodeText, CODES_YANDEX); - TUtf16String sUnicode; + TUtf16String sUnicode; sUnicode.reserve(YandexText.size() * 4); const wchar16* wdata = sUnicode.data(); TWtringBuf wres = NDetail::Recode<char>(YandexText, sUnicode, CODES_YANDEX); @@ -247,7 +247,7 @@ void TConversionTest::TestRecodeIntoString() { UNIT_ASSERT(sUnicode.data() == wres.data()); // same buffer UNIT_ASSERT(sUnicode.size() == wres.size()); // same size - TString sUtf8 = " "; + TString sUtf8 = " "; size_t scap = sUtf8.capacity(); sres = NDetail::Recode<wchar16>(UnicodeText, sUtf8, CODES_UTF8); UNIT_ASSERT(sUtf8 == UTF8Text); // same content @@ -258,7 +258,7 @@ void TConversionTest::TestRecodeIntoString() { sUnicode.clear(); wdata = sUnicode.data(); - TUtf16String copy = sUnicode; // increase ref-counter + TUtf16String copy = sUnicode; // increase ref-counter wres = NDetail::Recode<char>(UTF8Text, sUnicode, CODES_UTF8); UNIT_ASSERT(sUnicode == UnicodeText); // same content #ifndef TSTRING_IS_STD_STRING @@ -268,8 +268,8 @@ void TConversionTest::TestRecodeIntoString() { UNIT_ASSERT(sUnicode.size() == wres.size()); // same content } -static TString GenerateJunk(size_t seed) { - TString res; +static TString GenerateJunk(size_t seed) { + TString res; size_t hash = NumericHash(seed); size_t size = hash % 1024; res.reserve(size); @@ -280,8 +280,8 @@ static TString GenerateJunk(size_t seed) { void TConversionTest::TestRecodeAppend() { { - TString s1, s2; - NDetail::RecodeAppend<wchar16>(TUtf16String(), s1, CODES_YANDEX); + TString s1, s2; + NDetail::RecodeAppend<wchar16>(TUtf16String(), s1, CODES_YANDEX); UNIT_ASSERT(s1.empty()); NDetail::RecodeAppend<wchar16>(UnicodeText, s1, CODES_WIN); @@ -292,7 +292,7 @@ void TConversionTest::TestRecodeAppend() { s2 += WideToChar(UnicodeText, CODES_YANDEX); UNIT_ASSERT_EQUAL(s1, s2); - NDetail::RecodeAppend<wchar16>(TUtf16String(), s1, CODES_YANDEX); + NDetail::RecodeAppend<wchar16>(TUtf16String(), s1, CODES_YANDEX); UNIT_ASSERT_EQUAL(s1, s2); NDetail::RecodeAppend<wchar16>(UnicodeText, s1, CODES_UTF8); @@ -300,7 +300,7 @@ void TConversionTest::TestRecodeAppend() { UNIT_ASSERT_EQUAL(s1, s2); for (size_t i = 0; i < 100; ++i) { - TUtf16String junk = CharToWide(GenerateJunk(i), CODES_YANDEX); + TUtf16String junk = CharToWide(GenerateJunk(i), CODES_YANDEX); NDetail::RecodeAppend<wchar16>(junk, s1, CODES_UTF8); s2 += WideToUTF8(junk); UNIT_ASSERT_EQUAL(s1, s2); @@ -308,8 +308,8 @@ void TConversionTest::TestRecodeAppend() { } { - TUtf16String s1, s2; - NDetail::RecodeAppend<char>(TString(), s1, CODES_YANDEX); + TUtf16String s1, s2; + NDetail::RecodeAppend<char>(TString(), s1, CODES_YANDEX); UNIT_ASSERT(s1.empty()); NDetail::RecodeAppend<char>(YandexText, s1, CODES_WIN); @@ -320,7 +320,7 @@ void TConversionTest::TestRecodeAppend() { s2 += CharToWide(YandexText, CODES_YANDEX); UNIT_ASSERT_EQUAL(s1, s2); - NDetail::RecodeAppend<char>(TString(), s1, CODES_YANDEX); + NDetail::RecodeAppend<char>(TString(), s1, CODES_YANDEX); UNIT_ASSERT_EQUAL(s1, s2); NDetail::RecodeAppend<char>(UTF8Text, s1, CODES_UTF8); @@ -328,7 +328,7 @@ void TConversionTest::TestRecodeAppend() { UNIT_ASSERT_EQUAL(s1, s2); for (size_t i = 0; i < 100; ++i) { - TString junk = GenerateJunk(i); + TString junk = GenerateJunk(i); NDetail::RecodeAppend<char>(junk, s1, CODES_YANDEX); s2 += CharToWide(junk, CODES_YANDEX); UNIT_ASSERT_EQUAL(s1, s2); @@ -347,7 +347,7 @@ void TConversionTest::TestRecode() { if (!SingleByteCodepage(enc)) continue; - using THash = THashSet<char>; + using THash = THashSet<char>; THash hash; for (int i = 0; i != 256; ++i) { diff --git a/library/cpp/charset/ya.make b/library/cpp/charset/ya.make index 7565566bf0..61af7a3243 100644 --- a/library/cpp/charset/ya.make +++ b/library/cpp/charset/ya.make @@ -11,7 +11,7 @@ SRCS( iconv.cpp recyr.hh recyr_int.hh - ci_string.cpp + ci_string.cpp wide.cpp ) diff --git a/library/cpp/codecs/codecs_registry.cpp b/library/cpp/codecs/codecs_registry.cpp index 17d07062ab..c3a5a9839f 100644 --- a/library/cpp/codecs/codecs_registry.cpp +++ b/library/cpp/codecs/codecs_registry.cpp @@ -16,13 +16,13 @@ namespace NCodecs { return Singleton<NPrivate::TCodecRegistry>()->GetCodec(name); } - TVector<TString> ICodec::GetCodecsList() { + TVector<TString> ICodec::GetCodecsList() { return Singleton<NPrivate::TCodecRegistry>()->GetCodecsList(); } namespace NPrivate { void TCodecRegistry::RegisterFactory(TFactoryPtr fac) { - TVector<TString> names = fac->ListNames(); + TVector<TString> names = fac->ListNames(); for (const auto& name : names) { Y_VERIFY(!Registry.contains(name), "already has %s", name.data()); Registry[name] = fac; @@ -51,9 +51,9 @@ namespace NCodecs { } } - TVector<TString> TCodecRegistry::GetCodecsList() const { + TVector<TString> TCodecRegistry::GetCodecsList() const { using namespace NPrivate; - TVector<TString> vs; + TVector<TString> vs; vs.push_back("none"); for (const auto& it : Registry) { @@ -99,8 +99,8 @@ namespace NCodecs { ythrow TNoCodecException(name); } - TVector<TString> ListNames() const override { - TVector<TString> vs; + TVector<TString> ListNames() const override { + TVector<TString> vs; vs.push_back(ToString(TSolarCodec::MyName())); vs.push_back(ToString(TSolarCodec::MyName8k())); vs.push_back(ToString(TSolarCodec::MyName16k())); @@ -122,7 +122,7 @@ namespace NCodecs { return new TZStdDictCodec(TZStdDictCodec::ParseCompressionName(name)); } - TVector<TString> ListNames() const override { + TVector<TString> ListNames() const override { return TZStdDictCodec::ListCompressionNames(); } }; @@ -139,8 +139,8 @@ namespace NCodecs { } } - TVector<TString> ListNames() const override { - TVector<TString> vs; + TVector<TString> ListNames() const override { + TVector<TString> vs; vs.push_back(ToString(TCompTableCodec::MyNameHQ())); vs.push_back(ToString(TCompTableCodec::MyNameLQ())); return vs; @@ -155,7 +155,7 @@ namespace NCodecs { { } - TString GetName() const override { + TString GetName() const override { return ToString(Codec->Name()); } @@ -175,7 +175,7 @@ namespace NCodecs { }; struct TBlockCodecsFactory : ICodecFactory { - using TRegistry = THashMap<TString, TCodecPtr>; + using TRegistry = THashMap<TString, TCodecPtr>; TRegistry Registry; TBlockCodecsFactory() { @@ -196,8 +196,8 @@ namespace NCodecs { return Registry.find(name)->second; } - TVector<TString> ListNames() const override { - TVector<TString> res; + TVector<TString> ListNames() const override { + TVector<TString> res; for (const auto& it : Registry) { res.push_back(it.first); } diff --git a/library/cpp/codecs/codecs_registry.h b/library/cpp/codecs/codecs_registry.h index 53710310d5..1c82365d8f 100644 --- a/library/cpp/codecs/codecs_registry.h +++ b/library/cpp/codecs/codecs_registry.h @@ -13,7 +13,7 @@ namespace NCodecs { struct ICodecFactory : TAtomicRefCount<ICodecFactory> { virtual ~ICodecFactory() = default; virtual TCodecPtr MakeCodec(TStringBuf name) const = 0; - virtual TVector<TString> ListNames() const = 0; + virtual TVector<TString> ListNames() const = 0; }; typedef TIntrusivePtr<ICodecFactory> TCodecFactoryPtr; @@ -25,15 +25,15 @@ namespace NCodecs { return new TCodec; } - TVector<TString> ListNames() const override { - TVector<TString> vs; + TVector<TString> ListNames() const override { + TVector<TString> vs; vs.push_back(ToString(TCodec::MyName())); return vs; } }; class TCodecRegistry { - using TRegistry = THashMap<TString, TIntrusivePtr<ICodecFactory>>; + using TRegistry = THashMap<TString, TIntrusivePtr<ICodecFactory>>; TRegistry Registry; public: @@ -45,7 +45,7 @@ namespace NCodecs { TCodecPtr GetCodec(TStringBuf name) const; - TVector<TString> GetCodecsList() const; + TVector<TString> GetCodecsList() const; }; } diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp index 476b8ada80..a9ffacf35e 100644 --- a/library/cpp/codecs/comptable_codec.cpp +++ b/library/cpp/codecs/comptable_codec.cpp @@ -22,7 +22,7 @@ namespace NCodecs { return 0; } - TVector<char> result; + TVector<char> result; Compressor->Compress(in, &result); out.Assign(&result[0], result.size()); return 0; @@ -34,7 +34,7 @@ namespace NCodecs { return; } - TVector<char> result; + TVector<char> result; Decompressor->Decompress(in, &result); out.Assign(&result[0], result.size()); } @@ -81,7 +81,7 @@ namespace NCodecs { TCompTableCodec::~TCompTableCodec() = default; - TString TCompTableCodec::GetName() const { + TString TCompTableCodec::GetName() const { return ToString(Impl->Quality ? MyNameHQ() : MyNameLQ()); } diff --git a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp index 679089a11b..7adf8d4967 100644 --- a/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp +++ b/library/cpp/codecs/greedy_dict/ut/greedy_dict_ut.cpp @@ -125,7 +125,7 @@ class TGreedyDictTest: public TTestBase { data.insert(data.begin(), urls, urls + Y_ARRAY_SIZE(urls)); } - typedef THashMap<TStringBuf, NGreedyDict::TEntry> TDict; + typedef THashMap<TStringBuf, NGreedyDict::TEntry> TDict; TAutoPtr<NGreedyDict::TEntrySet> DoTestBuilder(const NGreedyDict::TBuildSettings& s, TDict& res) { @@ -159,7 +159,7 @@ class TGreedyDictTest: public TTestBase { void TestBuilder() { TAutoPtr<NGreedyDict::TEntrySet> set; - THashMap<TStringBuf, NGreedyDict::TEntry> res; + THashMap<TStringBuf, NGreedyDict::TEntry> res; NGreedyDict::TBuildSettings s; set = DoTestBuilder(s, res); diff --git a/library/cpp/codecs/huffman_codec.cpp b/library/cpp/codecs/huffman_codec.cpp index 650fe7cdfd..ff618fd955 100644 --- a/library/cpp/codecs/huffman_codec.cpp +++ b/library/cpp/codecs/huffman_codec.cpp @@ -496,10 +496,10 @@ namespace NCodecs { : Original(codec) { CacheEntries.resize(1 << CACHE_BITS_COUNT); - DecodeCache.reserve(CacheEntries.size() * 2); + DecodeCache.reserve(CacheEntries.size() * 2); char buffer[2]; TBuffer decoded; - for (size_t i = 0; i < CacheEntries.size(); i++) { + for (size_t i = 0; i < CacheEntries.size(); i++) { buffer[1] = i >> 8; buffer[0] = i; NBitIO::TBitInput bin(buffer, buffer + sizeof(buffer)); diff --git a/library/cpp/codecs/sample.h b/library/cpp/codecs/sample.h index 15f03afcc5..8aa62c7abd 100644 --- a/library/cpp/codecs/sample.h +++ b/library/cpp/codecs/sample.h @@ -30,11 +30,11 @@ namespace NCodecs { template <class TItem> class TSimpleSequenceReader: public ISequenceReader { - const TVector<TItem>& Items; + const TVector<TItem>& Items; size_t Idx = 0; public: - TSimpleSequenceReader(const TVector<TItem>& items) + TSimpleSequenceReader(const TVector<TItem>& items) : Items(items) { } @@ -64,13 +64,13 @@ namespace NCodecs { } template <class TIter, class TGetter> - TVector<TBuffer> GetSample(TIter begin, TIter end, size_t sampleSizeBytes, TGetter getter) { + TVector<TBuffer> GetSample(TIter begin, TIter end, size_t sampleSizeBytes, TGetter getter) { TFastRng64 rng{0x1ce1f2e507541a05, 0x07d45659, 0x7b8771030dd9917e, 0x2d6636ce}; size_t totalBytes = GetInputSize(begin, end, getter); double sampleProb = (double)sampleSizeBytes / Max<size_t>(1, totalBytes); - TVector<TBuffer> result; + TVector<TBuffer> result; for (TIter iter = begin; iter != end; ++iter) { if (sampleProb >= 1 || rng.GenRandReal1() < sampleProb) { TStringBuf reg = getter(iter); @@ -82,7 +82,7 @@ namespace NCodecs { } template <class TIter> - TVector<TBuffer> GetSample(TIter begin, TIter end, size_t sampleSizeBytes) { + TVector<TBuffer> GetSample(TIter begin, TIter end, size_t sampleSizeBytes) { return GetSample(begin, end, sampleSizeBytes, IterToStringBuf<TIter>); } diff --git a/library/cpp/codecs/static/builder.cpp b/library/cpp/codecs/static/builder.cpp index 93e34a3edb..3df19eeedf 100644 --- a/library/cpp/codecs/static/builder.cpp +++ b/library/cpp/codecs/static/builder.cpp @@ -9,7 +9,7 @@ #include <util/string/subst.h> namespace NCodecs { - TStaticCodecInfo BuildStaticCodec(const TVector<TString>& trainingData, const TCodecBuildInfo& info) { + TStaticCodecInfo BuildStaticCodec(const TVector<TString>& trainingData, const TCodecBuildInfo& info) { TStaticCodecInfo result; TCodecPtr codec = ICodec::GetInstance(info.CodecName); Y_ENSURE_EX(codec, TCodecException() << "empty codec is not allowed"); @@ -31,8 +31,8 @@ namespace NCodecs { return result; } - TString GetStandardFileName(const TStaticCodecInfo& info) { - TString cName = info.GetDebugInfo().GetCodecName(); + TString GetStandardFileName(const TStaticCodecInfo& info) { + TString cName = info.GetDebugInfo().GetCodecName(); SubstGlobal(cName, ':', '.'); return TStringBuilder() << cName << "." << info.GetDebugInfo().GetTimestamp() << ".codec_info"; } diff --git a/library/cpp/codecs/static/builder.h b/library/cpp/codecs/static/builder.h index d7533be4d5..f179d77861 100644 --- a/library/cpp/codecs/static/builder.h +++ b/library/cpp/codecs/static/builder.h @@ -5,25 +5,25 @@ #include <library/cpp/svnversion/svnversion.h> #include <util/datetime/base.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/string/builder.h> namespace NCodecs { struct TCodecBuildInfo { // optimal values from SEARCH-1655 - TString CodecName = "solar-8k-a:zstd08d-1"; + TString CodecName = "solar-8k-a:zstd08d-1"; float SampleSizeMultiplier = 1; // debug info: time_t Timestamp = TInstant::Now().TimeT(); - TString RevisionInfo = (TStringBuilder() << "r" << ToString(GetProgramSvnRevision())); - TString TrainingSetComment; // a human comment on the training data + TString RevisionInfo = (TStringBuilder() << "r" << ToString(GetProgramSvnRevision())); + TString TrainingSetComment; // a human comment on the training data TString TrainingSetResId; // sandbox resid of the training set }; - TStaticCodecInfo BuildStaticCodec(const TVector<TString>& trainingData, const TCodecBuildInfo&); + TStaticCodecInfo BuildStaticCodec(const TVector<TString>& trainingData, const TCodecBuildInfo&); - TString GetStandardFileName(const TStaticCodecInfo&); + TString GetStandardFileName(const TStaticCodecInfo&); } diff --git a/library/cpp/codecs/static/common.h b/library/cpp/codecs/static/common.h index 211de2a27d..588975b8de 100644 --- a/library/cpp/codecs/static/common.h +++ b/library/cpp/codecs/static/common.h @@ -12,10 +12,10 @@ namespace NCodecs { } template <class T> - TString HexWriteScalar(T t) { + TString HexWriteScalar(T t) { static_assert(std::is_scalar<T>::value, "scalars only"); t = LittleToBig(t); - TString res = HexEncode(&t, sizeof(t)); + TString res = HexEncode(&t, sizeof(t)); res.to_lower(); return res; } diff --git a/library/cpp/codecs/static/static.cpp b/library/cpp/codecs/static/static.cpp index 44a07dd73a..2c84c90d9c 100644 --- a/library/cpp/codecs/static/static.cpp +++ b/library/cpp/codecs/static/static.cpp @@ -50,7 +50,7 @@ namespace NCodecs { return result; } - TString SaveCodecInfoToString(const TStaticCodecInfo& info) { + TString SaveCodecInfoToString(const TStaticCodecInfo& info) { TStringStream s; SaveCodecInfoToStream(s, info); return s.Str(); @@ -61,7 +61,7 @@ namespace NCodecs { return LoadCodecInfoFromStream(m); } - TString FormatCodecInfo(const TStaticCodecInfo& ci) { + TString FormatCodecInfo(const TStaticCodecInfo& ci) { TStringBuilder s; s << "codec name: " << ci.GetDebugInfo().GetCodecName() << Endl; s << "codec hash: " << HexWriteScalar(ci.GetDebugInfo().GetStoredCodecHash()) << Endl; @@ -77,7 +77,7 @@ namespace NCodecs { return s; } - TString LoadStringFromArchive(const ui8* begin, size_t size) { + TString LoadStringFromArchive(const ui8* begin, size_t size) { TArchiveReader ar(TBlob::NoCopy(begin, size)); Y_VERIFY(ar.Count() == 1, "invalid number of entries"); auto blob = ar.ObjectBlobByKey(ar.KeyByIndex(0)); diff --git a/library/cpp/codecs/static/static.h b/library/cpp/codecs/static/static.h index c1eaed2a74..9a2fa5a1d7 100644 --- a/library/cpp/codecs/static/static.h +++ b/library/cpp/codecs/static/static.h @@ -3,7 +3,7 @@ #include <library/cpp/codecs/codecs.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/output.h> namespace NCodecs { @@ -15,13 +15,13 @@ namespace NCodecs { TStaticCodecInfo LoadCodecInfoFromString(TStringBuf data); - TString LoadStringFromArchive(const ui8* begin, size_t size); + TString LoadStringFromArchive(const ui8* begin, size_t size); TCodecConstPtr RestoreCodecFromArchive(const ui8* begin, size_t size); // save - TString SaveCodecInfoToString(const TStaticCodecInfo&); + TString SaveCodecInfoToString(const TStaticCodecInfo&); void SaveCodecInfoToStream(IOutputStream& out, const TStaticCodecInfo&); @@ -29,6 +29,6 @@ namespace NCodecs { TStaticCodecInfo LoadCodecInfoFromStream(IInputStream& in); - TString FormatCodecInfo(const TStaticCodecInfo&); + TString FormatCodecInfo(const TStaticCodecInfo&); } diff --git a/library/cpp/codecs/static/tools/common/ct_common.cpp b/library/cpp/codecs/static/tools/common/ct_common.cpp index fe77691280..ab4a2fac3f 100644 --- a/library/cpp/codecs/static/tools/common/ct_common.cpp +++ b/library/cpp/codecs/static/tools/common/ct_common.cpp @@ -9,7 +9,7 @@ #include <util/system/hp_timer.h> namespace NCodecs { - TString TComprStats::Format(const TStaticCodecInfo& info, bool checkMode) const { + TString TComprStats::Format(const TStaticCodecInfo& info, bool checkMode) const { TStringBuilder s; s << "raw size/item: " << RawSizePerRecord() << Endl; s << "enc.size/item: " << EncSizePerRecord() << Endl; @@ -26,7 +26,7 @@ namespace NCodecs { return s; } - TComprStats TestCodec(const ICodec& c, const TVector<TString>& input) { + TComprStats TestCodec(const ICodec& c, const TVector<TString>& input) { TComprStats stats; TBuffer encodeBuffer; @@ -51,10 +51,10 @@ namespace NCodecs { return stats; } - void ParseBlob(TVector<TString>& result, EDataStreamFormat fmt, const TBlob& blob) { + void ParseBlob(TVector<TString>& result, EDataStreamFormat fmt, const TBlob& blob) { TStringBuf bin(blob.AsCharPtr(), blob.Size()); TStringBuf line; - TString buffer; + TString buffer; while (bin.ReadLine(line)) { if (DSF_BASE64_LF == fmt) { Base64Decode(line, buffer); @@ -67,7 +67,7 @@ namespace NCodecs { } } - TBlob GetInputBlob(const TString& dataFile) { + TBlob GetInputBlob(const TString& dataFile) { return dataFile && dataFile != "-" ? TBlob::FromFile(dataFile) : TBlob::FromStream(Cin); } diff --git a/library/cpp/codecs/static/tools/common/ct_common.h b/library/cpp/codecs/static/tools/common/ct_common.h index 9d3dcbda93..a66c476c3d 100644 --- a/library/cpp/codecs/static/tools/common/ct_common.h +++ b/library/cpp/codecs/static/tools/common/ct_common.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/memory/blob.h> #include <cmath> @@ -57,10 +57,10 @@ namespace NCodecs { return PerRecord((1 - compr) * RawSize); } - TString Format(const TStaticCodecInfo&, bool checkMode) const; + TString Format(const TStaticCodecInfo&, bool checkMode) const; }; - TComprStats TestCodec(const ICodec&, const TVector<TString>& data); + TComprStats TestCodec(const ICodec&, const TVector<TString>& data); enum EDataStreamFormat { DSF_NONE, @@ -68,8 +68,8 @@ namespace NCodecs { DSF_BASE64_LF /* "base64" */, }; - void ParseBlob(TVector<TString>&, EDataStreamFormat, const TBlob&); + void ParseBlob(TVector<TString>&, EDataStreamFormat, const TBlob&); - TBlob GetInputBlob(const TString& dataFile); + TBlob GetInputBlob(const TString& dataFile); } diff --git a/library/cpp/codecs/static/tools/static_codec_checker/static_codec_checker.cpp b/library/cpp/codecs/static/tools/static_codec_checker/static_codec_checker.cpp index 9c8d568d82..1775a07303 100644 --- a/library/cpp/codecs/static/tools/static_codec_checker/static_codec_checker.cpp +++ b/library/cpp/codecs/static/tools/static_codec_checker/static_codec_checker.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { NCodecs::TCodecPtr codecPtr; NCodecs::EDataStreamFormat fmt = NCodecs::DSF_NONE; - TString codecFile; + TString codecFile; bool testCompression = false; auto opts = NLastGetopt::TOpts::Default(); @@ -50,7 +50,7 @@ int main(int argc, char** argv) { Cout << "Reading testing set data ... " << Flush; - TVector<TString> allData; + TVector<TString> allData; for (const auto& freeArg : res.GetFreeArgs()) { NCodecs::ParseBlob(allData, fmt, NCodecs::GetInputBlob(freeArg)); } diff --git a/library/cpp/codecs/static/tools/static_codec_generator/static_codec_generator.cpp b/library/cpp/codecs/static/tools/static_codec_generator/static_codec_generator.cpp index 45fdb5c5fe..c5b4f0fcde 100644 --- a/library/cpp/codecs/static/tools/static_codec_generator/static_codec_generator.cpp +++ b/library/cpp/codecs/static/tools/static_codec_generator/static_codec_generator.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) { NLastGetopt::TOptsParseResult res(&opts, argc, argv); Cout << "Reading training set data ... " << Flush; - TVector<TString> allData; + TVector<TString> allData; for (const auto& freeArg : res.GetFreeArgs()) { NCodecs::ParseBlob(allData, fmt, NCodecs::GetInputBlob(freeArg)); } @@ -61,7 +61,7 @@ int main(int argc, char** argv) { auto codec = NCodecs::BuildStaticCodec(allData, info); Cout << "Done" << Endl; - TString codecName = NCodecs::GetStandardFileName(codec); + TString codecName = NCodecs::GetStandardFileName(codec); NCodecs::TCodecPtr codecPtr = NCodecs::ICodec::RestoreFromString(codec.GetStoredCodec()); Cout << "Testing compression ... " << Flush; @@ -74,7 +74,7 @@ int main(int argc, char** argv) { Cout << "Saving as " << codecName << " ... " << Flush; { - TUnbufferedFileOutput fout{codecName}; + TUnbufferedFileOutput fout{codecName}; NCodecs::SaveCodecInfoToStream(fout, codec); fout.Finish(); } diff --git a/library/cpp/codecs/static/ut/builder_ut.cpp b/library/cpp/codecs/static/ut/builder_ut.cpp index b47c279ed1..e4b207d132 100644 --- a/library/cpp/codecs/static/ut/builder_ut.cpp +++ b/library/cpp/codecs/static/ut/builder_ut.cpp @@ -9,16 +9,16 @@ class TStaticCodecInfoBuilderTest: public NUnitTest::TTestBase { UNIT_TEST_SUITE_END(); private: - TVector<TString> PrepareData() { - TVector<TString> data; + TVector<TString> PrepareData() { + TVector<TString> data; for (ui32 i = 'a'; i <= 'z'; ++i) { - data.push_back(TString(1, (char)i)); + data.push_back(TString(1, (char)i)); } return data; } void TestBuild() { - TVector<TString> data; + TVector<TString> data; NCodecs::TCodecBuildInfo info; info.CodecName = "huffman"; info.SampleSizeMultiplier = 2; diff --git a/library/cpp/codecs/ut/codecs_ut.cpp b/library/cpp/codecs/ut/codecs_ut.cpp index caf6089aef..581650a65b 100644 --- a/library/cpp/codecs/ut/codecs_ut.cpp +++ b/library/cpp/codecs/ut/codecs_ut.cpp @@ -872,8 +872,8 @@ class TCodecsTest: public TTestBase { UNIT_TEST_SUITE_END(); private: - TString PrintError(TStringBuf learn, TStringBuf test, TStringBuf codec, ui32 i) { - TString s; + TString PrintError(TStringBuf learn, TStringBuf test, TStringBuf codec, ui32 i) { + TString s; TStringOutput sout(s); sout << codec << ": " << i << ", " << "\n"; @@ -882,7 +882,7 @@ private: sout << HexEncode(test.data(), test.size()); //NEscJ::EscapeJ<true>(test, sout); if (s.Size() > 1536) { - TString res = s.substr(0, 512); + TString res = s.substr(0, 512); res.append("...<skipped ").append(ToString(s.size() - 1024)).append(">..."); res.append(s.substr(s.size() - 512)); } @@ -895,13 +895,13 @@ private: } template <typename TCodec, bool testsaveload> - void TestCodec(const TVector<TBuffer>& inlearn = TVector<TBuffer>(), const TVector<TBuffer>& in = TVector<TBuffer>(), NCodecs::TCodecPtr c = new TCodec) { + void TestCodec(const TVector<TBuffer>& inlearn = TVector<TBuffer>(), const TVector<TBuffer>& in = TVector<TBuffer>(), NCodecs::TCodecPtr c = new TCodec) { using namespace NCodecs; TBuffer buff; { - TVector<TBuffer> out; + TVector<TBuffer> out; c->Learn(inlearn.begin(), inlearn.end()); @@ -973,7 +973,7 @@ private: void TestDelta() { using namespace NCodecs; - TVector<TBuffer> d; + TVector<TBuffer> d; // 1. common case d.emplace_back(); @@ -1016,7 +1016,7 @@ private: void TestPFor() { using namespace NCodecs; { - TVector<TBuffer> d; + TVector<TBuffer> d; d.emplace_back(); AppendTo(d.back(), -1LL); AppendTo(d.back(), -1LL); @@ -1054,7 +1054,7 @@ private: TestCodec<TPForCodec<ui64, true>, true>(d); } { - TVector<TBuffer> d; + TVector<TBuffer> d; d.emplace_back(); AppendTo(d.back(), -1); AppendTo(d.back(), -1); @@ -1084,7 +1084,7 @@ private: TestCodec<TPForCodec<ui32, true>, false>(d); } { - TVector<TBuffer> d; + TVector<TBuffer> d; d.emplace_back(); for (auto& textValue : TextValues) { AppendTo(d.back(), (ui32)strlen(textValue)); @@ -1094,7 +1094,7 @@ private: TestCodec<TPForCodec<ui32, true>, false>(d); } { - TVector<TBuffer> d; + TVector<TBuffer> d; d.emplace_back(); for (auto& textValue : TextValues) { AppendTo(d.back(), (ui64)strlen(textValue)); @@ -1109,7 +1109,7 @@ private: void DoTestSimpleCodec() { using namespace NCodecs; { - TVector<TBuffer> learn; + TVector<TBuffer> learn; for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); @@ -1122,11 +1122,11 @@ private: } { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); learn.back().Append('a'); - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 0; i < 256; ++i) { test.back().Append((ui8)i); @@ -1136,7 +1136,7 @@ private: } { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); for (ui32 i = 0; i < 256; ++i) { for (ui32 j = 0; j < i; ++j) { @@ -1144,7 +1144,7 @@ private: } } - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 0; i < 256; ++i) { test.back().Append((ui8)i); @@ -1154,7 +1154,7 @@ private: } { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); for (ui32 i = 0; i < 128; ++i) { for (ui32 j = 0; j < i; ++j) { @@ -1162,7 +1162,7 @@ private: } } - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 128; i < 256; ++i) { test.back().Append((ui8)i); @@ -1197,13 +1197,13 @@ private: void TestHuffmanLearnByFreqs() { using namespace NCodecs; - TVector<TBuffer> data; + TVector<TBuffer> data; for (auto& textValue : TextValues) { data.emplace_back(textValue, strlen(textValue)); } - TVector<TBuffer> outLearn; + TVector<TBuffer> outLearn; { THuffmanCodec codec; @@ -1215,7 +1215,7 @@ private: } } - TVector<TBuffer> outLearnByFreqs; + TVector<TBuffer> outLearnByFreqs; { THuffmanCodec codec; @@ -1251,30 +1251,30 @@ private: void TestSolar() { using namespace NCodecs; { - TVector<TBuffer> learn; + TVector<TBuffer> learn; for (auto& textValue : TextValues) { learn.emplace_back(textValue, strlen(textValue)); } - TestCodec<TSolarCodec, true>(learn, TVector<TBuffer>(), new TSolarCodec(512, 8)); - TestCodec<TAdaptiveSolarCodec, false>(learn, TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); - TestCodec<TAdaptiveSolarCodec, true>(learn, TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); - TestCodec<TSolarCodecShortInt, true>(learn, TVector<TBuffer>(), new TSolarCodecShortInt(512, 8)); + TestCodec<TSolarCodec, true>(learn, TVector<TBuffer>(), new TSolarCodec(512, 8)); + TestCodec<TAdaptiveSolarCodec, false>(learn, TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); + TestCodec<TAdaptiveSolarCodec, true>(learn, TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); + TestCodec<TSolarCodecShortInt, true>(learn, TVector<TBuffer>(), new TSolarCodecShortInt(512, 8)); } { - TestCodec<TSolarCodec, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TSolarCodec(512, 8)); - TestCodec<TAdaptiveSolarCodec, false>(TVector<TBuffer>(), TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); - TestCodec<TAdaptiveSolarCodec, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); - TestCodec<TSolarCodecShortInt, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TSolarCodecShortInt(512, 8)); + TestCodec<TSolarCodec, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TSolarCodec(512, 8)); + TestCodec<TAdaptiveSolarCodec, false>(TVector<TBuffer>(), TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); + TestCodec<TAdaptiveSolarCodec, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TAdaptiveSolarCodec(512, 8)); + TestCodec<TSolarCodecShortInt, true>(TVector<TBuffer>(), TVector<TBuffer>(), new TSolarCodecShortInt(512, 8)); } { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); learn.back().Append('a'); - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 0; i < 256; ++i) { test.back().Append((ui8)i); @@ -1287,7 +1287,7 @@ private: } { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); for (ui32 i = 0; i < 256; ++i) { for (ui32 j = 0; j < i; ++j) { @@ -1295,7 +1295,7 @@ private: } } - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 0; i < 256; ++i) { test.back().Append((ui8)i); @@ -1311,7 +1311,7 @@ private: void TestPipeline() { using namespace NCodecs; { - TVector<TBuffer> learn; + TVector<TBuffer> learn; learn.emplace_back(); for (ui32 i = 0; i < 256; ++i) { for (i32 j = i; j >= 0; --j) { @@ -1319,7 +1319,7 @@ private: } } - TVector<TBuffer> test; + TVector<TBuffer> test; test.emplace_back(); for (ui32 i = 0; i < 256; ++i) { test.back().Append((ui8)i); @@ -1329,7 +1329,7 @@ private: new TPipelineCodec(new TSolarCodec(512, 8), new TSolarCodec(512, 8), new THuffmanCodec)); } { - TVector<TBuffer> d; + TVector<TBuffer> d; d.emplace_back(); for (ui32 i = 0; i < 256; ++i) { for (i32 j = i; j >= 0; --j) { @@ -1337,14 +1337,14 @@ private: } } - TestCodec<TPipelineCodec, false>(d, TVector<TBuffer>(), + TestCodec<TPipelineCodec, false>(d, TVector<TBuffer>(), new TPipelineCodec(new TDeltaCodec<ui32, false>, new TPForCodec<ui32>)); } } void TestRegistry() { using namespace NCodecs; - TVector<TString> vs = ICodec::GetCodecsList(); + TVector<TString> vs = ICodec::GetCodecsList(); for (const auto& v : vs) { TCodecPtr p = ICodec::GetInstance(v); if (v == "none") { diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 3156fb1f46..d9bda02850 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -142,7 +142,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { } // Helper for dumping compressed values - void PrintCompressed(const TVector<ui8>& codedFactors) { + void PrintCompressed(const TVector<ui8>& codedFactors) { for (size_t i = 0; i < codedFactors.size(); ++i) { if (i % 0x10 == 0) Cerr << Endl; @@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { } // Helper for dumping decompressed values - void PrintDecompressed(const TVector<float>& factors) { + void PrintDecompressed(const TVector<float>& factors) { TStringStream result; TStringStream line; @@ -220,7 +220,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Y_UNIT_TEST(TestDecompressForgedData) { // this coredumps without end-of-coded-stream check, see SEARCH-1156 for details - TString brokenBase64Encoded = + TString brokenBase64Encoded = "NLjYltUWs5pqnd3d3f05Li4OAwCAEqrP6mv06jDt7PiAUVu7Y+PiMpuZmdzeM" "ArqOLxS2q4FKCII52dktcVs7y0zL+OKgeO9SOzEkFj7uPfFqqoCAAAAAADAtZ" "mZ2fdmICAgANQXhi1WVRUAAAAAAAAGjvcWq6oKAAAAAAAAA8d7qe4rV3Nxcd3" diff --git a/library/cpp/codecs/zstd_dict_codec.cpp b/library/cpp/codecs/zstd_dict_codec.cpp index c42a2879e6..d04ea57f3b 100644 --- a/library/cpp/codecs/zstd_dict_codec.cpp +++ b/library/cpp/codecs/zstd_dict_codec.cpp @@ -147,7 +147,7 @@ namespace NCodecs { bool Learn(ISequenceReader& in, bool throwOnError) { TBuffer data; - TVector<size_t> lens; + TVector<size_t> lens; data.Reserve(2 * SampleSize); TStringBuf r; @@ -233,7 +233,7 @@ namespace NCodecs { TZStdDictCodec::~TZStdDictCodec() { } - TString TZStdDictCodec::GetName() const { + TString TZStdDictCodec::GetName() const { return TStringBuilder() << MyName() << "-" << Impl->GetCompressionLevel(); } @@ -263,8 +263,8 @@ namespace NCodecs { Impl->Load(in); } - TVector<TString> TZStdDictCodec::ListCompressionNames() { - TVector<TString> res; + TVector<TString> TZStdDictCodec::ListCompressionNames() { + TVector<TString> res; for (int i = 1; i <= ZSTD_maxCLevel(); ++i) { res.emplace_back(TStringBuilder() << MyName() << "-" << i); } diff --git a/library/cpp/colorizer/colors.cpp b/library/cpp/colorizer/colors.cpp index decc5c9847..918cd57085 100644 --- a/library/cpp/colorizer/colors.cpp +++ b/library/cpp/colorizer/colors.cpp @@ -130,9 +130,9 @@ namespace { return "\033[0m\033[2;36m"; case DARK_WHITE: return "\033[0m\033[2;37m"; - - case INVALID: - default: + + case INVALID: + default: return ""; } } diff --git a/library/cpp/colorizer/colors.h b/library/cpp/colorizer/colors.h index 474a918994..8b64f4d90b 100644 --- a/library/cpp/colorizer/colors.h +++ b/library/cpp/colorizer/colors.h @@ -2,10 +2,10 @@ #include "fwd.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> -#include <cstdio> +#include <cstdio> namespace NColorizer { /** @@ -192,19 +192,19 @@ namespace NColorizer { TStringBuf YellowColor() const noexcept; TStringBuf WhiteColor() const noexcept; - inline bool IsTTY() const noexcept { + inline bool IsTTY() const noexcept { return IsTTY_; } - inline void SetIsTTY(bool value) noexcept { + inline void SetIsTTY(bool value) noexcept { IsTTY_ = value; } - inline void Enable() noexcept { + inline void Enable() noexcept { SetIsTTY(true); } - inline void Disable() noexcept { + inline void Disable() noexcept { SetIsTTY(false); } diff --git a/library/cpp/colorizer/output.h b/library/cpp/colorizer/output.h index 99afbd3427..0644daed85 100644 --- a/library/cpp/colorizer/output.h +++ b/library/cpp/colorizer/output.h @@ -12,7 +12,7 @@ namespace NColorizer { const TColors* C; TColorFunc F; - inline TColorHandle(const TColors* c, TColorFunc f) noexcept + inline TColorHandle(const TColors* c, TColorFunc f) noexcept : C(c) , F(f) { diff --git a/library/cpp/compproto/compproto_ut.cpp b/library/cpp/compproto/compproto_ut.cpp index 9393be967a..2a2a62a3fb 100644 --- a/library/cpp/compproto/compproto_ut.cpp +++ b/library/cpp/compproto/compproto_ut.cpp @@ -36,7 +36,7 @@ template <typename X> void TestSaveLoadMeta(NCompProto::TMetaInfo<X>& src) { TStringStream ss; src.Save(ss); - TString data = ss.Str(); + TString data = ss.Str(); NCompProto::TMetaInfo<X> loadedMeta(data); ss = TStringStream(); loadedMeta.Save(ss); @@ -44,7 +44,7 @@ void TestSaveLoadMeta(NCompProto::TMetaInfo<X>& src) { } template <typename TDecompressor, template <typename, typename> class TSerialize> -void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestParams& params) { +void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestParams& params) { using namespace NCompProto; FlushPseudoRandom(); @@ -74,7 +74,7 @@ void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestPa const size_t busyPages = (byteSize + (PAGESIZEX - 1)) / PAGESIZEX; const size_t allPages = busyPages + 1; const size_t allocSize = (allPages + 1) * PAGESIZEX; - TVector<ui8> readBuffer(allocSize); + TVector<ui8> readBuffer(allocSize); ui8* start = &readBuffer[0]; ui8* pageStart = reinterpret_cast<ui8*>((size_t(start) + PAGESIZEX) & ~(PAGESIZEX - 1)); // XX DATA DATA DATA DATA PROT @@ -97,7 +97,7 @@ void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestPa } template <typename TDecompressor, template <typename, typename> class TSerialize> -void Test(const TString& metainfo, const ECompMode mode) { +void Test(const TString& metainfo, const ECompMode mode) { for (size_t ds = 3; ds < 42; ds += (3 + PseudoRandom(5))) { for (size_t vas = 5; vas < 42; vas += (4 + PseudoRandom(10))) { TTestParams params; @@ -111,7 +111,7 @@ void Test(const TString& metainfo, const ECompMode mode) { Y_UNIT_TEST_SUITE(CompProtoTestBasic) { using namespace NCompProto; - const TString metainfo = + const TString metainfo = "\n\ repeated data id 0\n\ scalar clicks id 0 default const 0\n\ @@ -132,10 +132,10 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { ui32 Clicks; ui32 Shows; ui32 Extra; - TMap<ui32, TRegInfo> RegClicks; + TMap<ui32, TRegInfo> RegClicks; }; - TVector<TData> data; + TVector<TData> data; template <class TMeta, class TFunctor> struct TSerialize { @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { void EndSelf() { } void BeginElement(ui32 element) { - TMap<ui32, TRegInfo>::const_iterator it = Data->RegClicks.find(element); + TMap<ui32, TRegInfo>::const_iterator it = Data->RegClicks.find(element); if (it == Data->RegClicks.end()) { UNIT_ASSERT(0); } @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { EState State; ui32 DataInd; - TMap<ui32, TRegInfo>::iterator RegIter; + TMap<ui32, TRegInfo>::iterator RegIter; TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) { Y_UNUSED(index); @@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { Y_UNIT_TEST_SUITE(CompProtoTestExtended) { using namespace NCompProto; - const TString metainfo = + const TString metainfo = "\n\ repeated data id 0\n\ repeated second id 3\n\ @@ -383,7 +383,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestExtended) { scalar inner id 0 default const 0\n\ end\n\ end\n"; - TVector<std::pair<TVector<ui32>, TVector<ui32>>> data; + TVector<std::pair<TVector<ui32>, TVector<ui32>>> data; template <class TMeta, class TFunctor> struct TSerialize { diff --git a/library/cpp/comptable/comptable.cpp b/library/cpp/comptable/comptable.cpp index 8a92d4d1aa..d20ab6c7c4 100644 --- a/library/cpp/comptable/comptable.cpp +++ b/library/cpp/comptable/comptable.cpp @@ -1,6 +1,6 @@ #include <util/system/defaults.h> #include <util/system/filemap.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/string/cast.h> #include <util/stream/file.h> diff --git a/library/cpp/comptable/usage/usage.cpp b/library/cpp/comptable/usage/usage.cpp index 9997c83686..60de3515b4 100644 --- a/library/cpp/comptable/usage/usage.cpp +++ b/library/cpp/comptable/usage/usage.cpp @@ -10,8 +10,8 @@ using namespace NCompTable; template <bool HQ> void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { - TVector<char> compressed; - TVector<char> decompressed; + TVector<char> compressed; + TVector<char> decompressed; TChunkCompressor compressor(HQ, table); TChunkDecompressor deCompressor(HQ, table); @@ -42,18 +42,18 @@ void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { int main(int argc, const char* argv[]) { TReallyFastRng32 rr(17); - TVector<TString> lines; + TVector<TString> lines; /*FILE *fp = fopen("res", "rb"); while (!feof(fp)) { char buff[4096]; fscanf(fp, "%s", buff); - lines.push_back(TString(buff)); + lines.push_back(TString(buff)); }*/ //for (size_t i = 0; i < 10000000; ++i) { //for (size_t i = 0; i < 1000000; ++i) { for (size_t i = 0; i < 1000000; ++i) { size_t size = rr.Uniform(32); - TString res = "www.yandex.ru/yandsearch?text="; + TString res = "www.yandex.ru/yandsearch?text="; for (size_t j = 0; j < size; ++j) { res += "qwer"[rr.Uniform(4)]; } diff --git a/library/cpp/comptable/ut/comptable_ut.cpp b/library/cpp/comptable/ut/comptable_ut.cpp index 5901d0246f..4314e6baa0 100644 --- a/library/cpp/comptable/ut/comptable_ut.cpp +++ b/library/cpp/comptable/ut/comptable_ut.cpp @@ -8,8 +8,8 @@ using namespace NCompTable; template <bool HQ> void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { - TVector<char> compressed; - TVector<char> decompressed; + TVector<char> compressed; + TVector<char> decompressed; TChunkCompressor compressor(HQ, table); TStringStream tmp; @@ -42,10 +42,10 @@ void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { Y_UNIT_TEST_SUITE(TestComptable) { Y_UNIT_TEST(TestComptableCompressDecompress) { TReallyFastRng32 rr(17); - TVector<TString> lines; + TVector<TString> lines; for (size_t i = 0; i < 1000000; ++i) { size_t size = rr.Uniform(32); - TString res = "www.yandex.ru/yandsearch?text="; + TString res = "www.yandex.ru/yandsearch?text="; for (size_t j = 0; j < size; ++j) { res += "qwer"[rr.Uniform(4)]; } diff --git a/library/cpp/containers/atomizer/atomizer.h b/library/cpp/containers/atomizer/atomizer.h index 5e40f47ab9..bed0167a19 100644 --- a/library/cpp/containers/atomizer/atomizer.h +++ b/library/cpp/containers/atomizer/atomizer.h @@ -17,7 +17,7 @@ class super_atomizer; template <class HashFcn, class EqualTo> class atomizer: public string_hash<ui32, HashFcn, EqualTo> { private: - TVector<const char*> order; + TVector<const char*> order; public: using iterator = typename string_hash<ui32, HashFcn, EqualTo>::iterator; @@ -48,7 +48,7 @@ public: std::pair<iterator, bool> ins = insert_copy(key, ui32(size() + 1)); if (ins.second) { // new? if (pool.Begin() != old_begin) // repoint? - for (TVector<const char*>::iterator ptr = order.begin(); ptr != order.end(); ++ptr) + for (TVector<const char*>::iterator ptr = order.begin(); ptr != order.end(); ++ptr) if (old_begin <= *ptr && *ptr < old_end) // from old pool? *ptr += pool.Begin() - old_begin; order.push_back((*ins.first).first); // copy of 'key' @@ -108,7 +108,7 @@ public: template <class T, class HashFcn, class EqualTo> class super_atomizer: public string_hash<ui32, HashFcn, EqualTo> { private: - using TOrder = TVector<std::pair<const char*, T>>; + using TOrder = TVector<std::pair<const char*, T>>; TOrder order; public: diff --git a/library/cpp/containers/bitseq/bititerator_ut.cpp b/library/cpp/containers/bitseq/bititerator_ut.cpp index ed0925866f..8669410f5d 100644 --- a/library/cpp/containers/bitseq/bititerator_ut.cpp +++ b/library/cpp/containers/bitseq/bititerator_ut.cpp @@ -4,8 +4,8 @@ #include <util/generic/vector.h> Y_UNIT_TEST_SUITE(TBitIteratorTest) { - TVector<ui16> GenWords() { - TVector<ui16> words(1, 0); + TVector<ui16> GenWords() { + TVector<ui16> words(1, 0); for (ui16 word = 1; word; ++word) words.push_back(word); return words; @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { } Y_UNIT_TEST(TestForward) { - TVector<ui32> words; + TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); for (int i = 0; i < 3; ++i) @@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TBitIteratorTest) { } Y_UNIT_TEST(TestUnalignedReadAndPeek) { - TVector<ui32> words; + TVector<ui32> words; words.push_back((1 << 10) | (1 << 20) | (1 << 25)); words.push_back(1 | (1 << 5) | (1 << 6) | (1 << 30)); for (int i = 0; i < 5; ++i) diff --git a/library/cpp/containers/bitseq/bitvector.h b/library/cpp/containers/bitseq/bitvector.h index 3f8fd81ee5..7485b9a072 100644 --- a/library/cpp/containers/bitseq/bitvector.h +++ b/library/cpp/containers/bitseq/bitvector.h @@ -19,7 +19,7 @@ public: private: friend class TReadonlyBitVector<T>; ui64 Size_; - TVector<TWord> Data_; + TVector<TWord> Data_; public: TBitVector() diff --git a/library/cpp/containers/compact_vector/compact_vector.h b/library/cpp/containers/compact_vector/compact_vector.h index dbe7473f0c..94664aeb28 100644 --- a/library/cpp/containers/compact_vector/compact_vector.h +++ b/library/cpp/containers/compact_vector/compact_vector.h @@ -8,7 +8,7 @@ #include <cstdlib> -// vector that is 8 bytes when empty (TVector is 24 bytes) +// vector that is 8 bytes when empty (TVector is 24 bytes) template <typename T> class TCompactVector { diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cfa35f5ba2..e59d5f7263 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -139,7 +139,7 @@ public: #endif } - void Add(const TString& s, const T& value) { + void Add(const TString& s, const T& value) { ui64 intValue = 0; memcpy(&intValue, &value, sizeof(T)); Builder.Add(s.data(), s.size(), intValue); @@ -180,8 +180,8 @@ public: template <typename T> class TTrieSortedMapWriter { private: - typedef std::pair<TString, T> TValue; - typedef TVector<TValue> TValues; + typedef std::pair<TString, T> TValue; + typedef TVector<TValue> TValues; TValues Values; public: diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index cf7d2e39a3..815737bd36 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -61,8 +61,8 @@ public: return AddPtr(key.data(), key.size(), data); } - bool AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& filename); - bool AddSubtreeInFile(const TKeyBuf& key, const TString& filename) { + bool AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& filename); + bool AddSubtreeInFile(const TKeyBuf& key, const TString& filename) { return AddSubtreeInFile(key.data(), key.size(), filename); } @@ -83,8 +83,8 @@ public: size_t Save(IOutputStream& os) const; size_t SaveAndDestroy(IOutputStream& os); - size_t SaveToFile(const TString& fileName) const { - TFixedBufferFileOutput out(fileName); + size_t SaveToFile(const TString& fileName) const { + TFixedBufferFileOutput out(fileName); return Save(out); } diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index f273fa6571..8c9f681982 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -78,7 +78,7 @@ public: bool AddEntry(const TSymbol* key, size_t keylen, const TData& value); bool AddEntryPtr(const TSymbol* key, size_t keylen, const char* value); - bool AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& fileName); + bool AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& fileName); bool AddSubtreeInBuffer(const TSymbol* key, size_t keylen, TArrayWithSizeHolder<char>&& buffer); bool FindEntry(const TSymbol* key, size_t keylen, TData* value) const; bool FindLongestPrefix(const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const; @@ -269,12 +269,12 @@ public: struct TSubtreeInFile: public ISubtree { struct TData { - TString FileName; + TString FileName; ui64 Size; }; THolder<TData> Data; - TSubtreeInFile(const TString& fileName) { + TSubtreeInFile(const TString& fileName) { // stupid API TFile file(fileName, RdOnly); i64 size = file.GetLength(); @@ -321,7 +321,7 @@ public: } ui64 Save(const TBuilderImpl*, IOutputStream& os) const override { - TUnbufferedFileInput is(Data->FileName); + TUnbufferedFileInput is(Data->FileName); ui64 written = TransferData(&is, &os); if (written != Data->Size) ythrow yexception() << "file " << Data->FileName.Quote() << " size changed"; @@ -400,7 +400,7 @@ public: return pool.Allocate(); } - inline void operator delete(void* ptr, TFixedSizeAllocator& pool) noexcept { + inline void operator delete(void* ptr, TFixedSizeAllocator& pool) noexcept { pool.Release(ptr); } @@ -436,7 +436,7 @@ bool TCompactTrieBuilder<T, D, S>::AddPtr(const TSymbol* key, size_t keylen, con } template <class T, class D, class S> -bool TCompactTrieBuilder<T, D, S>::AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& fileName) { +bool TCompactTrieBuilder<T, D, S>::AddSubtreeInFile(const TSymbol* key, size_t keylen, const TString& fileName) { return Impl->AddSubtreeInFile(key, keylen, fileName); } @@ -566,7 +566,7 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddEntryPtr( template <class T, class D, class S> bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::AddSubtreeInFile( - const TSymbol* key, size_t keylen, const TString& fileName) { + const TSymbol* key, size_t keylen, const TString& fileName) { typedef typename TNode::ISubtree ISubtree; typedef typename TNode::TSubtreeInFile TSubtreeInFile; diff --git a/library/cpp/containers/comptrie/comptrie_impl.h b/library/cpp/containers/comptrie/comptrie_impl.h index f41c38311a..6effd9c909 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.h +++ b/library/cpp/containers/comptrie/comptrie_impl.h @@ -59,12 +59,12 @@ namespace NCompTriePrivate { template <> struct TStringForChar<char> { - typedef TString TResult; + typedef TString TResult; }; template <> struct TStringForChar<wchar16> { - typedef TUtf16String TResult; + typedef TUtf16String TResult; }; template <> diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 40ec1e52b3..bf47ec8cd0 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -41,7 +41,7 @@ public: typedef std::pair<TKey, TData> TValueType; typedef std::pair<size_t, TData> TPhraseMatch; - typedef TVector<TPhraseMatch> TPhraseMatchVector; + typedef TVector<TPhraseMatch> TPhraseMatchVector; typedef TCompactTrieBuilder<T, D, S> TBuilder; @@ -202,7 +202,7 @@ protected: bool hasNext; return LookupLongestPrefix(key, keylen, prefixLen, valuepos, hasNext); } - void LookupPhrases(const char* datapos, size_t len, const TSymbol* key, size_t keylen, TVector<TPhraseMatch>& matches, TSymbol separator) const; + void LookupPhrases(const char* datapos, size_t len, const TSymbol* key, size_t keylen, TVector<TPhraseMatch>& matches, TSymbol separator) const; }; template <class T = char, class D = ui64, class S = TCompactTriePacker<D>> diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 74bee09b5d..22e61adf83 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -138,19 +138,19 @@ private: template <class T, bool minimize> void TestRandom(const size_t n, const size_t maxKeySize); - void TestFindTailsImpl(const TString& prefix); + void TestFindTailsImpl(const TString& prefix); void TestUniqueImpl(bool isPrefixGrouped); - TVector<TUtf16String> GetSampleKeys(size_t nKeys) const; + TVector<TUtf16String> GetSampleKeys(size_t nKeys) const; template <class TContainer> - TVector<TContainer> GetSampleVectorData(size_t nValues); + TVector<TContainer> GetSampleVectorData(size_t nValues); template <class TContainer> - TVector<TContainer> GetSampleTextVectorData(size_t nValues); + TVector<TContainer> GetSampleTextVectorData(size_t nValues); template <class T> void CheckEquality(const T& value1, const T& value2) const; template <class TContainer> - void TestTrieWithContainers(const TVector<TUtf16String>& keys, const TVector<TContainer>& sampleData, TString methodName); + void TestTrieWithContainers(const TVector<TUtf16String>& keys, const TVector<TContainer>& sampleData, TString methodName); template <typename TChar> void TestSearchIterImpl(); @@ -287,7 +287,7 @@ typename TCompactTrie<T>::TKey MakeWideKey(const char* str, size_t len) { } template <class T> -typename TCompactTrie<T>::TKey MakeWideKey(const TString& str) { +typename TCompactTrie<T>::TKey MakeWideKey(const TString& str) { return MakeWideKey<T>(str.c_str(), str.length()); } @@ -321,7 +321,7 @@ void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFas } // Iterates over all strings of length <= 4 made of letters a-g. -static bool LexicographicStep(TString& s) { +static bool LexicographicStep(TString& s) { if (s.length() < 4) { s += "a"; return true; @@ -343,7 +343,7 @@ void TCompactTrieTest::CheckUpperBound(const char* data, size_t datalen) { typedef typename TCompactTrie<T>::TKey TKey; typedef typename TCompactTrie<T>::TData TData; - TString key; + TString key; do { const TKey wideKey = MakeWideKey<T>(key); typename TCompactTrie<T>::TConstIterator it = trie.UpperBound(wideKey); @@ -375,7 +375,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(len, prefixLen); UNIT_ASSERT_EQUAL(len * 2, value); - TString badkey("bb"); + TString badkey("bb"); badkey += i; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); @@ -400,7 +400,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(len, prefixLen); } - TString testkey("fbbaa"); + TString testkey("fbbaa"); typename TCompactTrie<T>::TKey key = MakeWideKey<T>(testkey); ui64 value = 0; size_t prefixLen = 0; @@ -423,7 +423,7 @@ template <class T> void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { typedef typename TCompactTrie<T>::TKey TKey; typedef typename TCompactTrie<T>::TValueType TValue; - TMap<TKey, ui64> stored; + TMap<TKey, ui64> stored; for (auto& i : SampleData) { size_t len = strlen(i); @@ -432,10 +432,10 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { } TCompactTrie<T> trie(data, datalen); - TVector<TValue> items; + TVector<TValue> items; typename TCompactTrie<T>::TConstIterator it = trie.Begin(); size_t entry_count = 0; - TMap<TKey, ui64> received; + TMap<TKey, ui64> received; while (it != trie.End()) { UNIT_ASSERT_VALUES_EQUAL(it.GetKeySize(), it.GetKey().size()); received.insert(*it); @@ -443,7 +443,7 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { entry_count++; it++; } - TMap<TKey, ui64> received2; + TMap<TKey, ui64> received2; for (std::pair<TKey, ui64> x : trie) { received2.insert(x); } @@ -573,7 +573,7 @@ void TCompactTrieTest::TestPhraseSearch() { builder.Save(bufout); TCompactTrie<char> trie(bufout.Buffer().Data(), bufout.Buffer().Size()); - TVector<TCompactTrie<char>::TPhraseMatch> matches; + TVector<TCompactTrie<char>::TPhraseMatch> matches; trie.FindPhrases(goodphrase, strlen(goodphrase), matches); UNIT_ASSERT(matches.size() == Y_ARRAY_SIZE(phrases)); @@ -650,9 +650,9 @@ static char RandChar() { return char(RandomNumber<size_t>() % 256); } -static TString RandStr(const size_t max) { +static TString RandStr(const size_t max) { size_t len = RandomNumber<size_t>() % max; - TString key; + TString key; for (size_t j = 0; j < len; ++j) key += RandChar(); return key; @@ -662,12 +662,12 @@ template <class T, bool minimize> void TCompactTrieTest::TestRandom(const size_t n, const size_t maxKeySize) { const TStringBuf EMPTY_KEY = TStringBuf("", 1); TCompactTrieBuilder<char, typename T::TData, T> builder; - typedef TMap<TString, typename T::TData> TKeys; + typedef TMap<TString, typename T::TData> TKeys; TKeys keys; typename T::TData dummy; for (size_t i = 0; i < n; ++i) { - const TString key = RandStr(maxKeySize); + const TString key = RandStr(maxKeySize); if (key != EMPTY_KEY && keys.find(key) == keys.end()) { const typename T::TData val = T::Data(key); keys[key] = val; @@ -729,13 +729,13 @@ void TCompactTrieTest::TestRandom() { TestRandom<TStrokaPacker, true>(100, 100); } -void TCompactTrieTest::TestFindTailsImpl(const TString& prefix) { +void TCompactTrieTest::TestFindTailsImpl(const TString& prefix) { TCompactTrieBuilder<> builder; - TMap<TString, ui64> input; + TMap<TString, ui64> input; for (auto& i : SampleData) { - TString temp = i; + TString temp = i; ui64 val = temp.size() * 2; builder.Add(temp.data(), temp.size(), val); if (temp.StartsWith(prefix)) { @@ -751,7 +751,7 @@ void TCompactTrieTest::TestFindTailsImpl(const TString& prefix) { TTrie subtrie = trie.FindTails(prefix.data(), prefix.size()); - TMap<TString, ui64> output; + TMap<TString, ui64> output; for (TTrie::TConstIterator i = subtrie.Begin(), mi = subtrie.End(); i != mi; ++i) { TTrie::TValueType val = *i; @@ -847,7 +847,7 @@ void TCompactTrieTest::TestMergeFromFile() { b.Add("yandex", 12); b.Add("google", 13); b.Add("mail", 14); - TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-ru"); + TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-ru"); b.Save(out); } @@ -856,7 +856,7 @@ void TCompactTrieTest::TestMergeFromFile() { b.Add("yandex", 112); b.Add("google", 113); b.Add("yahoo", 114); - TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-com"); + TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-com"); b.Save(out); } @@ -865,7 +865,7 @@ void TCompactTrieTest::TestMergeFromFile() { UNIT_ASSERT(b.AddSubtreeInFile("com.", GetSystemTempDir() + "/TCompactTrieTest-TestMerge-com")); UNIT_ASSERT(b.Add("org.kernel", 22)); UNIT_ASSERT(b.AddSubtreeInFile("ru.", GetSystemTempDir() + "/TCompactTrieTest-TestMerge-ru")); - TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-res"); + TUnbufferedFileOutput out(GetSystemTempDir() + "/TCompactTrieTest-TestMerge-res"); b.Save(out); } @@ -1026,7 +1026,7 @@ public: class TCompactTrieTest::TStrokaPacker: public TCompactTriePacker<TString> { public: - typedef TString TData; + typedef TString TData; static TString Data(const TString& str) { return str; @@ -1104,18 +1104,18 @@ void TCompactTrieTest::TestTrieSet() { // Tests for trie with vector (list, set) values -TVector<TUtf16String> TCompactTrieTest::GetSampleKeys(size_t nKeys) const { +TVector<TUtf16String> TCompactTrieTest::GetSampleKeys(size_t nKeys) const { Y_ASSERT(nKeys <= 10); - TString sampleKeys[] = {"a", "b", "ac", "bd", "abe", "bcf", "deg", "ah", "xy", "abc"}; - TVector<TUtf16String> result; + TString sampleKeys[] = {"a", "b", "ac", "bd", "abe", "bcf", "deg", "ah", "xy", "abc"}; + TVector<TUtf16String> result; for (size_t i = 0; i < nKeys; i++) result.push_back(ASCIIToWide(sampleKeys[i])); return result; } template <class TContainer> -TVector<TContainer> TCompactTrieTest::GetSampleVectorData(size_t nValues) { - TVector<TContainer> data; +TVector<TContainer> TCompactTrieTest::GetSampleVectorData(size_t nValues) { + TVector<TContainer> data; for (size_t i = 0; i < nValues; i++) { data.push_back(TContainer()); for (size_t j = 0; j < i; j++) @@ -1125,12 +1125,12 @@ TVector<TContainer> TCompactTrieTest::GetSampleVectorData(size_t nValues) { } template <class TContainer> -TVector<TContainer> TCompactTrieTest::GetSampleTextVectorData(size_t nValues) { - TVector<TContainer> data; +TVector<TContainer> TCompactTrieTest::GetSampleTextVectorData(size_t nValues) { + TVector<TContainer> data; for (size_t i = 0; i < nValues; i++) { data.push_back(TContainer()); for (size_t j = 0; j < i; j++) - data[i].insert(data[i].end(), TString("abc") + ToString<size_t>(j)); + data[i].insert(data[i].end(), TString("abc") + ToString<size_t>(j)); } return data; } @@ -1148,14 +1148,14 @@ void TCompactTrieTest::CheckEquality<TVector<i64>>(const TVector<i64>& value1, c } template <class TContainer> -void TCompactTrieTest::TestTrieWithContainers(const TVector<TUtf16String>& keys, const TVector<TContainer>& sampleData, TString methodName) { - TString fileName = GetSystemTempDir() + "/TCompactTrieTest-TestTrieWithContainers-" + methodName; +void TCompactTrieTest::TestTrieWithContainers(const TVector<TUtf16String>& keys, const TVector<TContainer>& sampleData, TString methodName) { + TString fileName = GetSystemTempDir() + "/TCompactTrieTest-TestTrieWithContainers-" + methodName; TCompactTrieBuilder<wchar16, TContainer> b; for (size_t i = 0; i < keys.size(); i++) { b.Add(keys[i], sampleData[i]); } - TUnbufferedFileOutput out(fileName); + TUnbufferedFileOutput out(fileName); b.Save(out); TCompactTrie<wchar16, TContainer> trie(TBlob::FromFileSingleThreaded(fileName)); @@ -1174,13 +1174,13 @@ void TCompactTrieTest::TestTrieWithContainers(const TVector<TUtf16String>& keys, template <> void TCompactTrieTest::TestTrieWithContainers<std::pair<TUtf16String, TVector<i64>>>(const TVector<TUtf16String>& keys, const TVector<std::pair<TUtf16String, TVector<i64>>>& sampleData, TString methodName) { typedef std::pair<TUtf16String, TVector<i64>> TContainer; - TString fileName = GetSystemTempDir() + "/TCompactTrieTest-TestTrieWithContainers-" + methodName; + TString fileName = GetSystemTempDir() + "/TCompactTrieTest-TestTrieWithContainers-" + methodName; TCompactTrieBuilder<wchar16, TContainer> b; for (size_t i = 0; i < keys.size(); i++) { b.Add(keys[i], sampleData[i]); } - TUnbufferedFileOutput out(fileName); + TUnbufferedFileOutput out(fileName); b.Save(out); TCompactTrie<wchar16, TContainer> trie(TBlob::FromFileSingleThreaded(fileName)); @@ -1221,7 +1221,7 @@ void TCompactTrieTest::TestTrieForVectorWtroka() { TVector<TVector<TString>> data = GetSampleTextVectorData<TVector<TString>>(10); TVector<TVector<TUtf16String>> wData; for (size_t i = 0; i < data.size(); i++) { - wData.push_back(TVector<TUtf16String>()); + wData.push_back(TVector<TUtf16String>()); for (size_t j = 0; j < data[i].size(); j++) wData[i].push_back(UTF8ToWide(data[i][j])); } @@ -1237,7 +1237,7 @@ void TCompactTrieTest::TestTrieForVectorDouble() { } void TCompactTrieTest::TestTrieForListVectorInt64() { - TVector<i64> tmp; + TVector<i64> tmp; tmp.push_back(0); TList<TVector<i64>> dataElement(5, tmp); TVector<TList<TVector<i64>>> data(10, dataElement); @@ -1245,7 +1245,7 @@ void TCompactTrieTest::TestTrieForListVectorInt64() { } void TCompactTrieTest::TestTrieForPairWtrokaVectorInt64() { - TVector<TUtf16String> keys = GetSampleKeys(10); + TVector<TUtf16String> keys = GetSampleKeys(10); TVector<TVector<i64>> values = GetSampleVectorData<TVector<i64>>(10); TVector<std::pair<TUtf16String, TVector<i64>>> data; for (size_t i = 0; i < 10; i++) @@ -1295,14 +1295,14 @@ void TCompactTrieTest::TestFindLongestPrefixWithEmptyValue() { template <typename TChar> struct TConvertKey { - static inline TString Convert(const TStringBuf& key) { + static inline TString Convert(const TStringBuf& key) { return ToString(key); } }; template <> struct TConvertKey<wchar16> { - static inline TUtf16String Convert(const TStringBuf& key) { + static inline TUtf16String Convert(const TStringBuf& key) { return UTF8ToWide(key); } }; @@ -1436,8 +1436,8 @@ void TCompactTrieTest::TestFirstSymbolIteratorChar32() { void TCompactTrieTest::TestArrayPacker() { using TDataInt = std::array<int, 2>; - const std::pair<TString, TDataInt> dataXxx{"xxx", {{15, 16}}}; - const std::pair<TString, TDataInt> dataYyy{"yyy", {{20, 30}}}; + const std::pair<TString, TDataInt> dataXxx{"xxx", {{15, 16}}}; + const std::pair<TString, TDataInt> dataYyy{"yyy", {{20, 30}}}; TCompactTrieBuilder<char, TDataInt> trieBuilderOne; trieBuilderOne.Add(dataXxx.first, dataXxx.second); @@ -1450,9 +1450,9 @@ void TCompactTrieTest::TestArrayPacker() { UNIT_ASSERT_VALUES_EQUAL(dataXxx.second, trieOne.Get(dataXxx.first)); UNIT_ASSERT_VALUES_EQUAL(dataYyy.second, trieOne.Get(dataYyy.first)); - using TDataStroka = std::array<TString, 2>; - const std::pair<TString, TDataStroka> dataZzz{"zzz", {{"hello", "there"}}}; - const std::pair<TString, TDataStroka> dataWww{"www", {{"half", "life"}}}; + using TDataStroka = std::array<TString, 2>; + const std::pair<TString, TDataStroka> dataZzz{"zzz", {{"hello", "there"}}}; + const std::pair<TString, TDataStroka> dataWww{"www", {{"half", "life"}}}; TCompactTrieBuilder<char, TDataStroka> trieBuilderTwo; trieBuilderTwo.Add(dataZzz.first, dataZzz.second); @@ -1480,8 +1480,8 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix() { } void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double branchProbability, bool isPrefixGrouped, bool hasEmptyKey) { - TVector<TString> keys; - TString keyToAdd; + TVector<TString> keys; + TString keyToAdd; for (size_t i = 0; i < keysCount; ++i) { const size_t prevKeyLen = keyToAdd.Size(); // add two random chars to prev key @@ -1500,16 +1500,16 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double bra else Shuffle(keys.begin(), keys.end()); - TCompactTrieBuilder<char, TString> builder(isPrefixGrouped ? CTBF_PREFIX_GROUPED : CTBF_NONE); - const TString EMPTY_VALUE = "empty"; + TCompactTrieBuilder<char, TString> builder(isPrefixGrouped ? CTBF_PREFIX_GROUPED : CTBF_NONE); + const TString EMPTY_VALUE = "empty"; if (hasEmptyKey) builder.Add(nullptr, 0, EMPTY_VALUE); for (size_t i = 0; i < keysCount; ++i) { - const TString& key = keys[i]; + const TString& key = keys[i]; for (size_t j = 0; j < keysCount; ++j) { - const TString& otherKey = keys[j]; + const TString& otherKey = keys[j]; const bool exists = j < i; size_t expectedSize = 0; if (exists) { @@ -1523,7 +1523,7 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double bra } size_t prefixSize = 0xfcfcfc; - TString value = "abcd"; + TString value = "abcd"; const bool expectedResult = hasEmptyKey || expectedSize != 0; UNIT_ASSERT_VALUES_EQUAL_C(expectedResult, builder.FindLongestPrefix(otherKey.data(), otherKey.size(), &prefixSize, &value), "otherKey = " << HexEncode(otherKey)); if (expectedResult) { @@ -1539,10 +1539,10 @@ void TCompactTrieTest::TestBuilderFindLongestPrefix(size_t keysCount, double bra } for (int c = 0; c < 10; ++c) { - TString extendedKey = otherKey; + TString extendedKey = otherKey; extendedKey += RandChar(); size_t extendedPrefixSize = 0xdddddd; - TString extendedValue = "dcba"; + TString extendedValue = "dcba"; UNIT_ASSERT_VALUES_EQUAL(expectedResult, builder.FindLongestPrefix(extendedKey.data(), extendedKey.size(), &extendedPrefixSize, &extendedValue)); if (expectedResult) { UNIT_ASSERT_VALUES_EQUAL(value, extendedValue); diff --git a/library/cpp/containers/comptrie/key_selector.h b/library/cpp/containers/comptrie/key_selector.h index 60466cef71..c4339d5a23 100644 --- a/library/cpp/containers/comptrie/key_selector.h +++ b/library/cpp/containers/comptrie/key_selector.h @@ -1,13 +1,13 @@ #pragma once #include <util/generic/vector.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> template <class T> struct TCompactTrieKeySelector { - typedef TVector<T> TKey; - typedef TVector<T> TKeyBuf; + typedef TVector<T> TKey; + typedef TVector<T> TKeyBuf; }; template <class TChar> diff --git a/library/cpp/containers/comptrie/loader/loader.h b/library/cpp/containers/comptrie/loader/loader.h index ee10e9b451..3c1efb79bb 100644 --- a/library/cpp/containers/comptrie/loader/loader.h +++ b/library/cpp/containers/comptrie/loader/loader.h @@ -1,13 +1,13 @@ #pragma once #include <library/cpp/archive/yarchive.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ptr.h> #include <util/generic/yexception.h> #include <util/memory/blob.h> template <class TrieType, size_t N> -TrieType LoadTrieFromArchive(const TString& key, +TrieType LoadTrieFromArchive(const TString& key, const unsigned char (&data)[N], bool ignoreErrors = false) { TArchiveReader archive(TBlob::NoCopy(data, sizeof(data))); diff --git a/library/cpp/containers/comptrie/prefix_iterator.h b/library/cpp/containers/comptrie/prefix_iterator.h index b369bb4f42..7157d54dc1 100644 --- a/library/cpp/containers/comptrie/prefix_iterator.h +++ b/library/cpp/containers/comptrie/prefix_iterator.h @@ -26,11 +26,11 @@ private: bool Next(); public: - TPrefixIterator(const TTrie& trie, const TSymbol* aKey, size_t aKeylen) + TPrefixIterator(const TTrie& trie, const TSymbol* aKey, size_t aKeylen) : Trie(trie) - , key(aKey) - , keylen(aKeylen) - , keyend(aKey + aKeylen) + , key(aKey) + , keylen(aKeylen) + , keyend(aKey + aKeylen) , prefixLen(0) , valuepos(nullptr) , datapos(trie.DataHolder.AsCharPtr()) diff --git a/library/cpp/containers/comptrie/write_trie_backwards.h b/library/cpp/containers/comptrie/write_trie_backwards.h index 634e6b811a..84f69f078f 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.h +++ b/library/cpp/containers/comptrie/write_trie_backwards.h @@ -2,7 +2,7 @@ #include "minimize.h" -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/stream/output.h> #include <cstddef> diff --git a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp index cab2365cce..8aef3cd5b9 100644 --- a/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp +++ b/library/cpp/containers/intrusive_avl_tree/ut/avltree_ut.cpp @@ -14,7 +14,7 @@ private: class TIt; struct TItCompare { - static inline bool Compare(const TIt& l, const TIt& r) noexcept; + static inline bool Compare(const TIt& l, const TIt& r) noexcept; }; class TIt: public TAvlTreeItem<TIt, TItCompare> { @@ -30,7 +30,7 @@ private: using TIts = TAvlTree<TIt, TItCompare>; }; -inline bool TAvlTreeTest::TItCompare::Compare(const TIt& l, const TIt& r) noexcept { +inline bool TAvlTreeTest::TItCompare::Compare(const TIt& l, const TIt& r) noexcept { return l.Val < r.Val; } @@ -80,12 +80,12 @@ void TAvlTreeTest::TestIterator() { its.Insert(&it6); its.Insert(&it2); - TVector<int> res; + TVector<int> res; for (const TIt& i : its) { res.push_back(i.Val); } - TVector<int> expected{1, 2, 3, 4, 5, 6, 7}; + TVector<int> expected{1, 2, 3, 4, 5, 6, 7}; UNIT_ASSERT_EQUAL(res, expected); res.clear(); diff --git a/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp b/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp index 92370760b5..9eeac01d2f 100644 --- a/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp +++ b/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp @@ -34,7 +34,7 @@ public: using TTree = TRbTree<TNode, TCmp>; extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - TDeque<TNode> records; + TDeque<TNode> records; const ui8 half = 128u; TTree tree; for (size_t i = 0; i < size; ++i) { diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree.h b/library/cpp/containers/intrusive_rb_tree/rb_tree.h index 0259452a14..9ed6edaf1b 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree.h +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree.h @@ -18,11 +18,11 @@ struct TRbTreeNodeBase { TBasePtr Right_; size_t Children_; - inline TRbTreeNodeBase() noexcept { + inline TRbTreeNodeBase() noexcept { ReInitNode(); } - inline void ReInitNode() noexcept { + inline void ReInitNode() noexcept { Color_ = RBTreeBlack; Parent_ = nullptr; Left_ = nullptr; @@ -82,7 +82,7 @@ struct TRbTreeBaseIterator { using TBasePtr = TRbTreeNodeBase*; TBasePtr Node_; - inline TRbTreeBaseIterator(TBasePtr x = nullptr) noexcept + inline TRbTreeBaseIterator(TBasePtr x = nullptr) noexcept : Node_(x) { } @@ -98,48 +98,48 @@ struct TRbTreeIterator: public TRbTreeBaseIterator { inline TRbTreeIterator() noexcept = default; template <class T1> - inline TRbTreeIterator(const T1& x) noexcept + inline TRbTreeIterator(const T1& x) noexcept : TRbTreeBaseIterator(x) { } - inline TReference operator*() const noexcept { + inline TReference operator*() const noexcept { return *static_cast<TValue*>(Node_); } - inline TPointer operator->() const noexcept { + inline TPointer operator->() const noexcept { return static_cast<TValue*>(Node_); } - inline TSelf& operator++() noexcept { + inline TSelf& operator++() noexcept { Node_ = TRbGlobalInst::IncrementNode(Node_); return *this; } - inline TSelf operator++(int) noexcept { + inline TSelf operator++(int) noexcept { TSelf tmp = *this; ++(*this); return tmp; } - inline TSelf& operator--() noexcept { + inline TSelf& operator--() noexcept { Node_ = TRbGlobalInst::DecrementNode(Node_); return *this; } - inline TSelf operator--(int) noexcept { + inline TSelf operator--(int) noexcept { TSelf tmp = *this; --(*this); return tmp; } template <class T1> - inline bool operator==(const T1& rhs) const noexcept { + inline bool operator==(const T1& rhs) const noexcept { return Node_ == rhs.Node_; } template <class T1> - inline bool operator!=(const T1& rhs) const noexcept { + inline bool operator!=(const T1& rhs) const noexcept { return Node_ != rhs.Node_; } }; @@ -149,7 +149,7 @@ class TRbTree { struct TCmpAdaptor: public TCmp { inline TCmpAdaptor() noexcept = default; - inline TCmpAdaptor(const TCmp& cmp) noexcept + inline TCmpAdaptor(const TCmp& cmp) noexcept : TCmp(cmp) { } @@ -182,11 +182,11 @@ public: { } - inline ~TRealNode() { + inline ~TRealNode() { UnLink(); } - inline void UnLink() noexcept { + inline void UnLink() noexcept { if (Tree_) { Tree_->EraseImpl(this); ReInitNode(); @@ -194,11 +194,11 @@ public: } } - inline void SetRbTreeParent(TRbTree* parent) noexcept { + inline void SetRbTreeParent(TRbTree* parent) noexcept { Tree_ = parent; } - inline TRbTree* ParentTree() const noexcept { + inline TRbTree* ParentTree() const noexcept { return Tree_; } @@ -209,17 +209,17 @@ public: using TIterator = TRbTreeIterator<TValue, TNonConstTraits>; using TConstIterator = TRbTreeIterator<TValue, TConstTraits>; - inline TRbTree() noexcept { + inline TRbTree() noexcept { Init(); } - inline TRbTree(const TCmp& cmp) noexcept + inline TRbTree(const TCmp& cmp) noexcept : KeyCompare_(cmp) { Init(); } - inline void Init() noexcept { + inline void Init() noexcept { Data_.Color_ = RBTreeRed; Data_.Parent_ = nullptr; Data_.Left_ = &Data_; @@ -228,17 +228,17 @@ public: } struct TDestroy { - inline void operator()(TValue& v) const noexcept { + inline void operator()(TValue& v) const noexcept { v.SetRbTreeParent(nullptr); v.ReInitNode(); } }; - inline ~TRbTree() { + inline ~TRbTree() { ForEachNoOrder(TDestroy()); } - inline void Clear() noexcept { + inline void Clear() noexcept { ForEachNoOrder(TDestroy()); Init(); } @@ -257,27 +257,27 @@ public: } } - inline TIterator Begin() noexcept { + inline TIterator Begin() noexcept { return LeftMost(); } - inline TConstIterator Begin() const noexcept { + inline TConstIterator Begin() const noexcept { return LeftMost(); } - inline TIterator End() noexcept { + inline TIterator End() noexcept { return &this->Data_; } - inline TConstIterator End() const noexcept { + inline TConstIterator End() const noexcept { return const_cast<TBasePtr>(&this->Data_); } - inline bool Empty() const noexcept { + inline bool Empty() const noexcept { return this->Begin() == this->End(); } - inline explicit operator bool() const noexcept { + inline explicit operator bool() const noexcept { return !this->Empty(); } @@ -314,19 +314,19 @@ public: } } - inline void Erase(TValue& val) noexcept { + inline void Erase(TValue& val) noexcept { val.UnLink(); } - inline void Erase(TValue* val) noexcept { + inline void Erase(TValue* val) noexcept { Erase(*val); } - inline void Erase(TIterator pos) noexcept { + inline void Erase(TIterator pos) noexcept { Erase(*pos); } - inline void EraseImpl(TNodeBase* val) noexcept { + inline void EraseImpl(TNodeBase* val) noexcept { TRbGlobalInst::RebalanceForErase(val, this->Data_.Parent_, this->Data_.Left_, this->Data_.Right_); } diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp index c34ed1fd9b..b1fb8d4a59 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp @@ -26,7 +26,7 @@ class TRedBlackTreeTest: public TTestBase { class TNode: public TRbTreeItem<TNode, TCmp> { public: - inline TNode(int n) noexcept + inline TNode(int n) noexcept : N(n) { } @@ -51,7 +51,7 @@ class TRedBlackTreeTest: public TTestBase { private: inline void TestStress() { - TVector<TSimpleSharedPtr<TNode>> nodes; + TVector<TSimpleSharedPtr<TNode>> nodes; for (int i = 0; i < 1000; ++i) { nodes.push_back(new TNode(i)); @@ -78,7 +78,7 @@ private: } inline void TestGettingIndexWithDifferentValues() { - TVector<TSimpleSharedPtr<TNode>> nodes; + TVector<TSimpleSharedPtr<TNode>> nodes; size_t N = 1000; for (size_t i = 0; i < N; ++i) { @@ -105,7 +105,7 @@ private: } inline void TestCheckChildrenAfterErase() { - TVector<TSimpleSharedPtr<TNode>> nodes; + TVector<TSimpleSharedPtr<TNode>> nodes; size_t N = 1000; for (size_t i = 0; i < N; ++i) { @@ -138,7 +138,7 @@ private: } inline void TestGettingIndexWithDifferentValuesAfterErase() { - TVector<TSimpleSharedPtr<TNode>> nodes; + TVector<TSimpleSharedPtr<TNode>> nodes; size_t N = 1000; for (size_t i = 0; i < N; ++i) { @@ -176,7 +176,7 @@ private: } inline void TestGettingIndexWithEqualValues() { - TVector<TSimpleSharedPtr<TNode>> nodes; + TVector<TSimpleSharedPtr<TNode>> nodes; size_t N = 1000; for (size_t i = 0; i < N; ++i) { diff --git a/library/cpp/containers/ring_buffer/ring_buffer.h b/library/cpp/containers/ring_buffer/ring_buffer.h index 41220dcf6b..a7e694b17c 100644 --- a/library/cpp/containers/ring_buffer/ring_buffer.h +++ b/library/cpp/containers/ring_buffer/ring_buffer.h @@ -68,7 +68,7 @@ private: private: size_t MaxSize; size_t Begin = 0; - TVector<T> Items; + TVector<T> Items; }; template <typename T, size_t maxSize> diff --git a/library/cpp/containers/sorted_vector/sorted_vector.h b/library/cpp/containers/sorted_vector/sorted_vector.h index 123539af9e..d9a242ab59 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector.h +++ b/library/cpp/containers/sorted_vector/sorted_vector.h @@ -50,9 +50,9 @@ namespace NSorted { // Sorted vector, which is order by the key. The key is extracted from the value by the provided key-extractor template <typename TValueType, typename TKeyType = TValueType, class TKeyExtractor = TIdentity, class TPredicate = TLess<TKeyType>, class A = std::allocator<TValueType>> - class TSortedVector: public TVector<TValueType, A> { + class TSortedVector: public TVector<TValueType, A> { private: - typedef TVector<TValueType, A> TBase; + typedef TVector<TValueType, A> TBase; typedef NPrivate::TKeyCompare<TValueType, TPredicate, TKeyExtractor> TKeyCompare; typedef NPrivate::TEqual<TKeyCompare> TValueEqual; typedef NPrivate::TEqual<TPredicate> TKeyEqual; @@ -364,7 +364,7 @@ namespace NSorted { inline TValueType& Get(const TKeyType& key) { typename TBase::iterator i = TBase::LowerBound(key); if (i == TBase::end() || key != i->first) - return TVector<std::pair<TKeyType, TValueType>, A>::insert(i, std::make_pair(key, TValueType()))->second; + return TVector<std::pair<TKeyType, TValueType>, A>::insert(i, std::make_pair(key, TValueType()))->second; else return i->second; } @@ -437,7 +437,7 @@ namespace NSorted { inline TValueType& Get(const TKeyType& key) { typename TBase::iterator i = TBase::LowerBound(key); if (i == TBase::end() || !TKeyEqual()(TKeyExtractor()(*i), key)) - i = TVector<TValueType, A>::insert(i, TValueType(key)); + i = TVector<TValueType, A>::insert(i, TValueType(key)); return *i; } diff --git a/library/cpp/containers/stack_array/range_ops.h b/library/cpp/containers/stack_array/range_ops.h index 1d40341aa1..7b61b15758 100644 --- a/library/cpp/containers/stack_array/range_ops.h +++ b/library/cpp/containers/stack_array/range_ops.h @@ -7,7 +7,7 @@ namespace NRangeOps { template <class T, bool isTrivial> struct TRangeOpsBase { - static inline void DestroyRange(T* b, T* e) noexcept { + static inline void DestroyRange(T* b, T* e) noexcept { while (e > b) { (--e)->~T(); } @@ -30,10 +30,10 @@ namespace NRangeOps { template <class T> struct TRangeOpsBase<T, true> { - static inline void DestroyRange(T*, T*) noexcept { + static inline void DestroyRange(T*, T*) noexcept { } - static inline void InitializeRange(T*, T*) noexcept { + static inline void InitializeRange(T*, T*) noexcept { } }; @@ -41,7 +41,7 @@ namespace NRangeOps { using TRangeOps = TRangeOpsBase<T, TTypeTraits<T>::IsPod>; template <class T> - static inline void DestroyRange(T* b, T* e) noexcept { + static inline void DestroyRange(T* b, T* e) noexcept { TRangeOps<T>::DestroyRange(b, e); } diff --git a/library/cpp/containers/stack_array/stack_array.h b/library/cpp/containers/stack_array/stack_array.h index 28e49bfc3c..9f097da72c 100644 --- a/library/cpp/containers/stack_array/stack_array.h +++ b/library/cpp/containers/stack_array/stack_array.h @@ -2,12 +2,12 @@ #include "range_ops.h" -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/system/defaults.h> /* For alloca. */ namespace NStackArray { /** - * A stack-allocated array. Should be used instead of � variable length + * A stack-allocated array. Should be used instead of � variable length * arrays that are not part of C++ standard. * * Example usage: @@ -31,7 +31,7 @@ namespace NStackArray { NRangeOps::InitializeRange(this->begin(), this->end()); } - inline ~TStackArray() { + inline ~TStackArray() { NRangeOps::DestroyRange(this->begin(), this->end()); } }; diff --git a/library/cpp/containers/stack_vector/stack_vec.h b/library/cpp/containers/stack_vector/stack_vec.h index fcc5d9a2a5..bb90c55381 100644 --- a/library/cpp/containers/stack_vector/stack_vec.h +++ b/library/cpp/containers/stack_vector/stack_vec.h @@ -7,7 +7,7 @@ // A vector preallocated on the stack. // After exceeding the preconfigured stack space falls back to the heap. -// Publicly inherits TVector, but disallows swap (and hence shrink_to_fit, also operator= is reimplemented via copying). +// Publicly inherits TVector, but disallows swap (and hence shrink_to_fit, also operator= is reimplemented via copying). // // Inspired by: http://qt-project.org/doc/qt-4.8/qvarlengtharray.html#details diff --git a/library/cpp/containers/str_map/str_map.h b/library/cpp/containers/str_map/str_map.h index 31b00d1b99..0be25902e6 100644 --- a/library/cpp/containers/str_map/str_map.h +++ b/library/cpp/containers/str_map/str_map.h @@ -35,12 +35,12 @@ pool_insert(Map* m, const char* key, const typename Map::mapped_type& data, TBuf #define AVERAGEWORD_BUF 10 template <class T, class HashFcn, class EqualTo, class Alloc> -class string_hash: public THashMap<const char*, T, HashFcn, EqualTo, Alloc> { +class string_hash: public THashMap<const char*, T, HashFcn, EqualTo, Alloc> { protected: TBuffer pool; public: - using yh = THashMap<const char*, T, HashFcn, EqualTo, Alloc>; + using yh = THashMap<const char*, T, HashFcn, EqualTo, Alloc>; using iterator = typename yh::iterator; using const_iterator = typename yh::const_iterator; using mapped_type = typename yh::mapped_type; @@ -50,7 +50,7 @@ public: pool.Reserve(HASH_SIZE_DEFAULT * AVERAGEWORD_BUF); // reserve here } string_hash(size_type hash_size, pool_size_type pool_size) - : THashMap<const char*, T, HashFcn, EqualTo, Alloc>(hash_size) + : THashMap<const char*, T, HashFcn, EqualTo, Alloc>(hash_size) { pool.Reserve(pool_size); // reserve here } @@ -68,14 +68,14 @@ public: } string_hash(const string_hash& sh) - : THashMap<const char*, T, HashFcn, EqualTo, Alloc>() + : THashMap<const char*, T, HashFcn, EqualTo, Alloc>() { for (const_iterator i = sh.begin(); i != sh.end(); ++i) insert_copy((*i).first, (*i).second); } /* May be faster? string_hash(const string_hash& sh) - : THashMap<const char *, T, HashFcn, EqualTo>(sh) + : THashMap<const char *, T, HashFcn, EqualTo>(sh) { pool = sh.pool; size_t delta = pool.begin() - sh.pool.begin(); @@ -101,12 +101,12 @@ public: }; template <class C, class T, class HashFcn, class EqualTo> -class THashWithSegmentedPoolForKeys: protected THashMap<const C*, T, HashFcn, EqualTo>, TNonCopyable { +class THashWithSegmentedPoolForKeys: protected THashMap<const C*, T, HashFcn, EqualTo>, TNonCopyable { protected: segmented_pool<C> pool; public: - using yh = THashMap<const C*, T, HashFcn, EqualTo>; + using yh = THashMap<const C*, T, HashFcn, EqualTo>; using iterator = typename yh::iterator; using const_iterator = typename yh::const_iterator; using mapped_type = typename yh::mapped_type; @@ -170,7 +170,7 @@ public: return yh::find(key); } - const yh& get_THashMap() const { + const yh& get_THashMap() const { return static_cast<const yh&>(*this); } }; diff --git a/library/cpp/containers/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper.h index 2f282b5a9e..d25adb079f 100644 --- a/library/cpp/containers/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper.h @@ -10,7 +10,7 @@ class TTopKeeper { private: class TVectorWithMin { private: - TVector<T, Alloc> Internal; + TVector<T, Alloc> Internal; size_t HalfMaxSize; TComparator Comparer; size_t MinElementIndex; diff --git a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h index 2f282b5a9e..d25adb079f 100644 --- a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h @@ -10,7 +10,7 @@ class TTopKeeper { private: class TVectorWithMin { private: - TVector<T, Alloc> Internal; + TVector<T, Alloc> Internal; size_t HalfMaxSize; TComparator Comparer; size_t MinElementIndex; diff --git a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp index a938279025..724132aed9 100644 --- a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp @@ -163,14 +163,14 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; - for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { + for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1; TLimitedHeap<TElementType> h1(desiredElementsCount); TTopKeeper<TElementType> h2(desiredElementsCount); const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount; UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); - for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { + for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { const auto f = RandomNumber<float>(); const auto id = RandomNumber<unsigned int>(); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); const auto n = h2.GetSize(); - for (size_t i3 = 0; i3 < n; ++i3) { + for (size_t i3 = 0; i3 < n; ++i3) { UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); h1.PopMin(); h2.Pop(); @@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; - TVector<TKeeper> v(2, TKeeper(200)); + TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; for (size_t i = 0; i < 100; ++i) { k.Insert(RandomNumber<float>()); diff --git a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp index a938279025..724132aed9 100644 --- a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp @@ -163,14 +163,14 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { typedef std::pair<float, unsigned int> TElementType; const size_t randomTriesCount = 128; - for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { + for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1; TLimitedHeap<TElementType> h1(desiredElementsCount); TTopKeeper<TElementType> h2(desiredElementsCount); const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount; UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); - for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { + for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { const auto f = RandomNumber<float>(); const auto id = RandomNumber<unsigned int>(); @@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); const auto n = h2.GetSize(); - for (size_t i3 = 0; i3 < n; ++i3) { + for (size_t i3 = 0; i3 < n; ++i3) { UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); h1.PopMin(); h2.Pop(); @@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { Y_UNIT_TEST(CopyKeeperRegressionCase) { using TKeeper = TTopKeeper<float>; - TVector<TKeeper> v(2, TKeeper(200)); + TVector<TKeeper> v(2, TKeeper(200)); auto& k = v[1]; for (size_t i = 0; i < 100; ++i) { k.Insert(RandomNumber<float>()); diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp index 8b372496a2..fcc9a5a641 100644 --- a/library/cpp/coroutine/engine/coroutine_ut.cpp +++ b/library/cpp/coroutine/engine/coroutine_ut.cpp @@ -125,11 +125,11 @@ void TCoroTest::TestException() { UNIT_ASSERT(!unc); } -static int i0; +static int i0; static void CoRun(TCont* c, void* /*run*/) { - while (i0 < 100000) { - ++i0; + while (i0 < 100000) { + ++i0; UNIT_ASSERT(RunningCont() == c); c->Yield(); UNIT_ASSERT(RunningCont() == c); @@ -137,7 +137,7 @@ static void CoRun(TCont* c, void* /*run*/) { } static void CoMain(TCont* c, void* /*arg*/) { - for (volatile size_t i2 = 0; i2 < 10; ++i2) { + for (volatile size_t i2 = 0; i2 < 10; ++i2) { UNIT_ASSERT(RunningCont() == c); c->Executor()->Create(CoRun, nullptr, "run"); UNIT_ASSERT(RunningCont() == c); @@ -192,7 +192,7 @@ public: }; void TCoroTest::TestMemFun() { - i0 = 0; + i0 = 0; TContExecutor e(32000); TTestObject obj; e.Create<TTestObject, &TTestObject::RunTask1>(&obj, "test1"); @@ -203,25 +203,25 @@ void TCoroTest::TestMemFun() { void TCoroTest::TestSimpleX2() { { - i0 = 0; + i0 = 0; { TContExecutor e(32000); e.Execute(CoMain); } - UNIT_ASSERT_EQUAL(i0, 100000); + UNIT_ASSERT_EQUAL(i0, 100000); } { - i0 = 0; + i0 = 0; { TContExecutor e(32000); e.Execute(CoMain); } - UNIT_ASSERT_EQUAL(i0, 100000); + UNIT_ASSERT_EQUAL(i0, 100000); } } @@ -243,7 +243,7 @@ void TCoroTest::TestSimpleX3() { TContExecutor e(32000); TRunner runner; - for (volatile size_t i3 = 0; i3 < 1000; ++i3) { + for (volatile size_t i3 = 0; i3 < 1000; ++i3) { e.Create(runner, "runner"); } @@ -252,7 +252,7 @@ void TCoroTest::TestSimpleX3() { UNIT_ASSERT_EQUAL(runner.Runs, 1000); } -static TString res; +static TString res; static TContMutex mutex; static void CoMutex(TCont* c, void* /*run*/) { @@ -289,7 +289,7 @@ static TContMutex m1; static TContCondVar c1; static void CoCondVar(TCont* c, void* /*run*/) { - for (size_t i4 = 0; i4 < 3; ++i4) { + for (size_t i4 = 0; i4 < 3; ++i4) { UNIT_ASSERT_EQUAL(m1.LockI(c), 0); UNIT_ASSERT_EQUAL(c1.WaitI(c, &m1), 0); res += c->Name(); @@ -311,8 +311,8 @@ static void CoCondVarTest(TCont* c, void* /*run*/) { c->Executor()->Create(CoCondVar, nullptr, "6"); c->Yield(); - for (size_t i5 = 0; i5 < 3; ++i5) { - res += ToString((size_t)i5) + "^"; + for (size_t i5 = 0; i5 < 3; ++i5) { + res += ToString((size_t)i5) + "^"; c1.BroadCast(); c->Yield(); } diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index 283a96ecf1..0abfa5582c 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -160,7 +160,7 @@ public: NCoro::ITime* time = nullptr ); - ~TContExecutor(); + ~TContExecutor(); // if we already have a coroutine to run void Execute() noexcept; diff --git a/library/cpp/coroutine/engine/poller.cpp b/library/cpp/coroutine/engine/poller.cpp index 61164fa56b..73398d8e65 100644 --- a/library/cpp/coroutine/engine/poller.cpp +++ b/library/cpp/coroutine/engine/poller.cpp @@ -128,11 +128,11 @@ namespace { } }; - typedef TIntrusiveList<TVal> TListType; + typedef TIntrusiveList<TVal> TListType; public: - typedef typename TListType::TIterator TIterator; - typedef typename TListType::TConstIterator TConstIterator; + typedef typename TListType::TIterator TIterator; + typedef typename TListType::TConstIterator TConstIterator; TIndexedArray() : P_(TMemoryPool::TExpGrow::Instance(), TDefaultAllocator::Instance()) @@ -184,7 +184,7 @@ namespace { using TValRef = THolder<TVal>; typename TVal::TPool P_; TSocketMap<TValRef> V_; - TListType I_; + TListType I_; }; @@ -306,7 +306,7 @@ namespace { private: typedef TIndexedArray<TChange> TFds; TFds S_; - typedef TVector<pollfd> TPollVec; + typedef TVector<pollfd> TPollVec; TPollVec T_; }; diff --git a/library/cpp/coroutine/engine/sockmap.h b/library/cpp/coroutine/engine/sockmap.h index fd189e1774..193ec2261b 100644 --- a/library/cpp/coroutine/engine/sockmap.h +++ b/library/cpp/coroutine/engine/sockmap.h @@ -19,6 +19,6 @@ public: } private: - TVector<T> V_; - THashMap<size_t, T> H_; + TVector<T> V_; + THashMap<size_t, T> H_; }; diff --git a/library/cpp/coroutine/engine/sockpool.h b/library/cpp/coroutine/engine/sockpool.h index 1ebb7e7b38..953f4f600c 100644 --- a/library/cpp/coroutine/engine/sockpool.h +++ b/library/cpp/coroutine/engine/sockpool.h @@ -77,7 +77,7 @@ class TPooledSocket { } private: - inline void ReturnToPool() noexcept; + inline void ReturnToPool() noexcept; private: TSocketPool* Pool_; @@ -222,7 +222,7 @@ private: TMutex Mutex_; }; -inline void TPooledSocket::TImpl::ReturnToPool() noexcept { +inline void TPooledSocket::TImpl::ReturnToPool() noexcept { Pool_->Release(this); } diff --git a/library/cpp/coroutine/listener/listen.cpp b/library/cpp/coroutine/listener/listen.cpp index 3d4e711d1d..58795e07e4 100644 --- a/library/cpp/coroutine/listener/listen.cpp +++ b/library/cpp/coroutine/listener/listen.cpp @@ -16,12 +16,12 @@ namespace { const sockaddr_in* In; const sockaddr_in6* In6; - inline TSa(const sockaddr* sa) noexcept + inline TSa(const sockaddr* sa) noexcept : Sa(sa) { } - inline bool operator==(const TSa& r) const noexcept { + inline bool operator==(const TSa& r) const noexcept { if (Sa->sa_family == r.Sa->sa_family) { switch (Sa->sa_family) { case AF_INET: @@ -34,7 +34,7 @@ namespace { return false; } - inline bool operator!=(const TSa& r) const noexcept { + inline bool operator!=(const TSa& r) const noexcept { return !(*this == r); } }; @@ -43,7 +43,7 @@ namespace { class TContListener::TImpl { private: struct TStoredAddrInfo: public TAddrInfo, private TNetworkAddress { - inline TStoredAddrInfo(const struct addrinfo* ai, const TNetworkAddress& addr) noexcept + inline TStoredAddrInfo(const struct addrinfo* ai, const TNetworkAddress& addr) noexcept : TAddrInfo(ai) , TNetworkAddress(addr) { @@ -84,12 +84,12 @@ private: } } - inline ~TOneSocketListener() { + inline ~TOneSocketListener() { Stop(); } public: - inline void Run(TCont* cont) noexcept { + inline void Run(TCont* cont) noexcept { C_ = cont; DoRun(); C_ = nullptr; @@ -111,11 +111,11 @@ private: } } - inline const IRemoteAddr* Addr() const noexcept { + inline const IRemoteAddr* Addr() const noexcept { return Addr_.Get(); } - inline void Stop() noexcept { + inline void Stop() noexcept { if (C_) { C_->Cancel(); @@ -126,7 +126,7 @@ private: } private: - inline void DoRun() noexcept { + inline void DoRun() noexcept { while (!C_->Cancelled()) { try { TOpaqueAddr remote; @@ -208,7 +208,7 @@ private: }; public: - inline TImpl(ICallBack* cb, TContExecutor* e, const TOptions& opts) noexcept + inline TImpl(ICallBack* cb, TContExecutor* e, const TOptions& opts) noexcept : E_(e) , Cb_(cb) , Opts_(opts) @@ -274,7 +274,7 @@ TContListener::TContListener(ICallBack* cb, TContExecutor* e, const TOptions& op { } -TContListener::~TContListener() { +TContListener::~TContListener() { } namespace { @@ -315,7 +315,7 @@ void TContListener::Bind(const TNetworkAddress& addr) { CheckImpl(Impl_)->Bind(addr); } -void TContListener::Stop() noexcept { +void TContListener::Stop() noexcept { Impl_.Destroy(); } diff --git a/library/cpp/coroutine/listener/listen.h b/library/cpp/coroutine/listener/listen.h index 3a89cd3ecc..22d3da85f3 100644 --- a/library/cpp/coroutine/listener/listen.h +++ b/library/cpp/coroutine/listener/listen.h @@ -15,7 +15,7 @@ namespace NAddr { class TContListener { public: struct TOptions { - inline TOptions() noexcept + inline TOptions() noexcept : ListenQueue(Max<size_t>()) , SendBufSize(0) , RecvBufSize(0) @@ -24,31 +24,31 @@ public: { } - inline TOptions& SetListenQueue(size_t len) noexcept { + inline TOptions& SetListenQueue(size_t len) noexcept { ListenQueue = len; return *this; } - inline TOptions& SetDeferAccept(bool enable) noexcept { + inline TOptions& SetDeferAccept(bool enable) noexcept { EnableDeferAccept = enable; return *this; } - inline TOptions& SetSendBufSize(unsigned size) noexcept { + inline TOptions& SetSendBufSize(unsigned size) noexcept { SendBufSize = size; return *this; } - inline TOptions& SetRecvBufSize(unsigned size) noexcept { + inline TOptions& SetRecvBufSize(unsigned size) noexcept { RecvBufSize = size; return *this; } - inline TOptions& SetReusePort(bool reusePort) noexcept { + inline TOptions& SetReusePort(bool reusePort) noexcept { ReusePort = reusePort; return *this; @@ -93,7 +93,7 @@ public: }; TContListener(ICallBack* cb, TContExecutor* e, const TOptions& opts = TOptions()); - ~TContListener(); + ~TContListener(); /// start listener threads void Listen(); @@ -107,7 +107,7 @@ public: void Bind(const TIpAddress& addr); void Bind(const TNetworkAddress& addr); - void Stop() noexcept; + void Stop() noexcept; void StopListenAddr(const NAddr::IRemoteAddr& addr); void StopListenAddr(const TIpAddress& addr); diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index c7efa105ee..d80209c4d0 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -59,7 +59,7 @@ namespace NPrivate { } } - THashSet<size_t> Visited; + THashSet<size_t> Visited; }; }; @@ -77,7 +77,7 @@ namespace NPrivate { d << *T_; } - inline TDbgDump& SetIndent(bool v) noexcept { + inline TDbgDump& SetIndent(bool v) noexcept { Indent = v; return *this; diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index 4868e97da0..d37b1fe652 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -4,7 +4,7 @@ #include <util/generic/fwd.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> //smart pointers template <class T, class D> @@ -91,7 +91,7 @@ struct TDumper<std::pair<A, B>> { //sequences template <class T, class A> -struct TDumper<TVector<T, A>>: public TSeqDumper { +struct TDumper<TVector<T, A>>: public TSeqDumper { }; template <class T, class A> @@ -107,49 +107,49 @@ struct TDumper<std::array<T, N>>: public TSeqDumper { }; template <class T, class A> -struct TDumper<TDeque<T, A>>: public TSeqDumper { +struct TDumper<TDeque<T, A>>: public TSeqDumper { }; template <class T, class A> -struct TDumper<TList<T, A>>: public TSeqDumper { +struct TDumper<TList<T, A>>: public TSeqDumper { }; //associatives template <class K, class V, class P, class A> -struct TDumper<TMap<K, V, P, A>>: public TAssocDumper { +struct TDumper<TMap<K, V, P, A>>: public TAssocDumper { }; template <class K, class V, class P, class A> -struct TDumper<TMultiMap<K, V, P, A>>: public TAssocDumper { +struct TDumper<TMultiMap<K, V, P, A>>: public TAssocDumper { }; template <class T, class P, class A> -struct TDumper<TSet<T, P, A>>: public TAssocDumper { +struct TDumper<TSet<T, P, A>>: public TAssocDumper { }; template <class T, class P, class A> -struct TDumper<TMultiSet<T, P, A>>: public TAssocDumper { +struct TDumper<TMultiSet<T, P, A>>: public TAssocDumper { }; template <class K, class V, class H, class P, class A> -struct TDumper<THashMap<K, V, H, P, A>>: public TAssocDumper { +struct TDumper<THashMap<K, V, H, P, A>>: public TAssocDumper { }; template <class K, class V, class H, class P, class A> -struct TDumper<THashMultiMap<K, V, H, P, A>>: public TAssocDumper { +struct TDumper<THashMultiMap<K, V, H, P, A>>: public TAssocDumper { }; template <class T, class H, class P, class A> -struct TDumper<THashSet<T, H, P, A>>: public TAssocDumper { +struct TDumper<THashSet<T, H, P, A>>: public TAssocDumper { }; template <class T, class H, class P, class A> -struct TDumper<THashMultiSet<T, H, P, A>>: public TAssocDumper { +struct TDumper<THashMultiSet<T, H, P, A>>: public TAssocDumper { }; //strings template <> -struct TDumper<TString>: public TStrDumper { +struct TDumper<TString>: public TStrDumper { }; template <> @@ -157,7 +157,7 @@ struct TDumper<const char*>: public TStrDumper { }; template <> -struct TDumper<TUtf16String>: public TStrDumper { +struct TDumper<TUtf16String>: public TStrDumper { }; template <> diff --git a/library/cpp/dbg_output/engine.cpp b/library/cpp/dbg_output/engine.cpp index dcb9f02522..2057b41436 100644 --- a/library/cpp/dbg_output/engine.cpp +++ b/library/cpp/dbg_output/engine.cpp @@ -9,7 +9,7 @@ DBGDUMP_INLINE_IF_INCLUDED void TDumpBase::String(const TStringBuf& s) { if (s) { - Raw(TString(s).Quote()); + Raw(TString(s).Quote()); } else { Raw("(empty)"); } diff --git a/library/cpp/dbg_output/engine.h b/library/cpp/dbg_output/engine.h index f13c728c39..a0e9f1c5ad 100644 --- a/library/cpp/dbg_output/engine.h +++ b/library/cpp/dbg_output/engine.h @@ -62,7 +62,7 @@ struct TIndentScope { ++(D->IndentLevel); } - inline ~TIndentScope() { + inline ~TIndentScope() { --(D->IndentLevel); } @@ -80,7 +80,7 @@ static inline TRawLiteral<TChar> DumpRaw(const TBasicStringBuf<TChar>& s) noexce } template <class TChar> -static inline TRawLiteral<TChar> DumpRaw(const TChar* s) noexcept { +static inline TRawLiteral<TChar> DumpRaw(const TChar* s) noexcept { return {s}; } @@ -95,7 +95,7 @@ struct TDumper<TRawLiteral<C>> { struct TIndentNewLine { }; -static inline TIndentNewLine IndentNewLine() noexcept { +static inline TIndentNewLine IndentNewLine() noexcept { return {}; } diff --git a/library/cpp/dbg_output/ut/dbg_output_ut.cpp b/library/cpp/dbg_output/ut/dbg_output_ut.cpp index 7b285c84cb..45a9512040 100644 --- a/library/cpp/dbg_output/ut/dbg_output_ut.cpp +++ b/library/cpp/dbg_output/ut/dbg_output_ut.cpp @@ -34,14 +34,14 @@ DEFINE_DUMPER(TMyNS::TMyStruct, A, B) Y_UNIT_TEST_SUITE(TContainerPrintersTest) { Y_UNIT_TEST(TestVectorInt) { TStringStream out; - out << DbgDump(TVector<int>({1, 2, 3, 4, 5})); + out << DbgDump(TVector<int>({1, 2, 3, 4, 5})); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[1, 2, 3, 4, 5]"); } Y_UNIT_TEST(TestMapCharToCharArray) { TStringStream out; - TMap<char, const char*> m; + TMap<char, const char*> m; m['a'] = "SMALL LETTER A"; m['b'] = nullptr; @@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { Y_UNIT_TEST(TestVectorOfVectors) { TStringStream out; - TVector<TVector<wchar16>> vec(2); + TVector<TVector<wchar16>> vec(2); vec[0].push_back(0); vec[1] = {wchar16('a')}; out << DbgDump(vec); @@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { } Y_UNIT_TEST(TestColors) { - using TComplex = TMap<TString, TMap<int, char>>; + using TComplex = TMap<TString, TMap<int, char>>; TComplex test; test["a"][1] = '7'; test["b"][2] = '6'; diff --git a/library/cpp/deprecated/accessors/accessors.h b/library/cpp/deprecated/accessors/accessors.h index 6d4b1da3ad..744dcb15d5 100644 --- a/library/cpp/deprecated/accessors/accessors.h +++ b/library/cpp/deprecated/accessors/accessors.h @@ -8,7 +8,7 @@ namespace NAccessors { * * i.e. this will work: * - * TString t; + * TString t; * const char* beg = NAccessors::Begin(t); // t.begin() * const char* end = NAccessors::End(t); // t.end() * size_t sz = NAccessors::Size(t); // t.size() diff --git a/library/cpp/deprecated/accessors/accessors_ut.cpp b/library/cpp/deprecated/accessors/accessors_ut.cpp index a9bdc9fcc4..2008c9edb9 100644 --- a/library/cpp/deprecated/accessors/accessors_ut.cpp +++ b/library/cpp/deprecated/accessors/accessors_ut.cpp @@ -58,27 +58,27 @@ private: TestRead(sbuf, "TStringBuf"); - TUtf16String wtr; + TUtf16String wtr; wtr.resize(10, 1024); - TestRead(wtr, "TUtf16String"); + TestRead(wtr, "TUtf16String"); TBuffer buf; buf.Resize(30); TestRead(buf, "TBuffer"); - TVector<ui64> vec(10, 100); + TVector<ui64> vec(10, 100); - TestRead(vec, "TVector<ui64>"); + TestRead(vec, "TVector<ui64>"); - TestWrite<TString>("TString"); - TestWrite<TVector<char>>("TVector<char>"); + TestWrite<TString>("TString"); + TestWrite<TVector<char>>("TVector<char>"); TestWrite<TBuffer>("TBuffer"); - TestWrite<TVector<ui64>>("TVector<ui64>"); - TestWrite<TUtf16String>("TUtf16String"); + TestWrite<TVector<ui64>>("TVector<ui64>"); + TestWrite<TUtf16String>("TUtf16String"); - std::array<TString, 10> sarr; + std::array<TString, 10> sarr; NAccessors::Init(sarr); NAccessors::Clear(sarr); diff --git a/library/cpp/deprecated/accessors/memory_traits.h b/library/cpp/deprecated/accessors/memory_traits.h index aa837705d3..1d19b9de33 100644 --- a/library/cpp/deprecated/accessors/memory_traits.h +++ b/library/cpp/deprecated/accessors/memory_traits.h @@ -5,7 +5,7 @@ #include <util/memory/tempbuf.h> #include <util/generic/buffer.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/typetraits.h> @@ -108,7 +108,7 @@ struct TMemoryTraits<std::vector<T, TAlloc>>: public TElementDependentMemoryTrai }; template <typename T, typename TAlloc> -struct TMemoryTraits<TVector<T, TAlloc>>: public TMemoryTraits<std::vector<T, TAlloc>> { +struct TMemoryTraits<TVector<T, TAlloc>>: public TMemoryTraits<std::vector<T, TAlloc>> { }; template <typename T> @@ -126,7 +126,7 @@ struct TMemoryTraits<std::basic_string<T, TCharTraits, TAlloc>>: public TElement }; template <> -struct TMemoryTraits<TString>: public TElementDependentMemoryTraits<char> { +struct TMemoryTraits<TString>: public TElementDependentMemoryTraits<char> { enum { OwnsMemory = true }; diff --git a/library/cpp/deprecated/kmp/kmp.cpp b/library/cpp/deprecated/kmp/kmp.cpp index d02074c94a..cb577b139f 100644 --- a/library/cpp/deprecated/kmp/kmp.cpp +++ b/library/cpp/deprecated/kmp/kmp.cpp @@ -8,7 +8,7 @@ TKMPMatcher::TKMPMatcher(const char* patternBegin, const char* patternEnd) ComputePrefixFunction(); } -TKMPMatcher::TKMPMatcher(const TString& pattern) +TKMPMatcher::TKMPMatcher(const TString& pattern) : Pattern(pattern) { ComputePrefixFunction(); diff --git a/library/cpp/deprecated/kmp/kmp.h b/library/cpp/deprecated/kmp/kmp.h index a7f72eece6..287382821d 100644 --- a/library/cpp/deprecated/kmp/kmp.h +++ b/library/cpp/deprecated/kmp/kmp.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -32,13 +32,13 @@ void ComputePrefixFunction(const T* begin, const T* end, ssize_t** result) { class TKMPMatcher { private: TArrayHolder<ssize_t> PrefixFunction; - TString Pattern; + TString Pattern; void ComputePrefixFunction(); public: TKMPMatcher(const char* patternBegin, const char* patternEnd); - TKMPMatcher(const TString& pattern); + TKMPMatcher(const TString& pattern); bool SubStr(const char* begin, const char* end, const char*& result) const { Y_ASSERT(begin <= end); @@ -70,7 +70,7 @@ public: private: ICallback* Callback; TArrayHolder<ssize_t> PrefixFunction; - using TTVector = TVector<T>; + using TTVector = TVector<T>; TTVector Pattern; ssize_t State; TTVector Candidate; diff --git a/library/cpp/deprecated/kmp/kmp_ut.cpp b/library/cpp/deprecated/kmp/kmp_ut.cpp index c2eda83c57..04e7cf2701 100644 --- a/library/cpp/deprecated/kmp/kmp_ut.cpp +++ b/library/cpp/deprecated/kmp/kmp_ut.cpp @@ -4,8 +4,8 @@ #include <util/stream/output.h> -static TVector<int> FindAll(const TString& pattern, const TString& string) { - TVector<int> result; +static TVector<int> FindAll(const TString& pattern, const TString& string) { + TVector<int> result; TKMPMatcher kmp(pattern); const char* pResult; const char* begin = string.begin(); @@ -25,7 +25,7 @@ class TTestKMP: public TTestBase { public: void Test() { - TVector<int> ans = {0, 2}; + TVector<int> ans = {0, 2}; UNIT_ASSERT_EQUAL(FindAll("a", "aba"), ans); ans = {0}; UNIT_ASSERT_EQUAL(FindAll("aba", "aba"), ans); diff --git a/library/cpp/deprecated/kmp/ut/ya.make b/library/cpp/deprecated/kmp/ut/ya.make index 9c54ee2715..e19f716c82 100644 --- a/library/cpp/deprecated/kmp/ut/ya.make +++ b/library/cpp/deprecated/kmp/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/deprecated/kmp) - -OWNER(g:util) - -SRCS( - kmp_ut.cpp -) - -END() + +OWNER(g:util) + +SRCS( + kmp_ut.cpp +) + +END() diff --git a/library/cpp/deprecated/kmp/ya.make b/library/cpp/deprecated/kmp/ya.make index 7c1c557934..f8969a33a5 100644 --- a/library/cpp/deprecated/kmp/ya.make +++ b/library/cpp/deprecated/kmp/ya.make @@ -1,10 +1,10 @@ -LIBRARY() - -OWNER(g:util) - -SRCS( - kmp.cpp - kmp.h -) - -END() +LIBRARY() + +OWNER(g:util) + +SRCS( + kmp.cpp + kmp.h +) + +END() diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index b0e4511299..e6b9504969 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -27,7 +27,7 @@ void TMappedFile::precharge(size_t off, size_t size) const { Map_->Precharge(off, size); } -void TMappedFile::init(const TString& name) { +void TMappedFile::init(const TString& name) { THolder<TFileMap> map(new TFileMap(name)); TMappedFile newFile(map.Get(), name.data()); Y_UNUSED(map.Release()); @@ -35,7 +35,7 @@ void TMappedFile::init(const TString& name) { newFile.term(); } -void TMappedFile::init(const TString& name, size_t length, TFileMap::EOpenMode om) { +void TMappedFile::init(const TString& name, size_t length, TFileMap::EOpenMode om) { THolder<TFileMap> map(new TFileMap(name, length, om)); TMappedFile newFile(map.Get(), name.data()); Y_UNUSED(map.Release()); @@ -51,7 +51,7 @@ void TMappedFile::init(const TFile& file, TFileMap::EOpenMode om, const char* db newFile.term(); } -void TMappedFile::init(const TString& name, TFileMap::EOpenMode om) { +void TMappedFile::init(const TString& name, TFileMap::EOpenMode om) { THolder<TFileMap> map(new TFileMap(name, om)); TMappedFile newFile(map.Get(), name.data()); Y_UNUSED(map.Release()); diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 45859ed65a..1675ccc3f7 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -30,18 +30,18 @@ public: term(); } - explicit TMappedFile(const TString& name) { + explicit TMappedFile(const TString& name) { Map_ = nullptr; init(name, TFileMap::oRdOnly); } TMappedFile(const TFile& file, TFileMap::EOpenMode om = TFileMap::oRdOnly, const char* dbgName = "unknown"); - void init(const TString& name); + void init(const TString& name); - void init(const TString& name, TFileMap::EOpenMode om); + void init(const TString& name, TFileMap::EOpenMode om); - void init(const TString& name, size_t length, TFileMap::EOpenMode om); + void init(const TString& name, size_t length, TFileMap::EOpenMode om); void init(const TFile&, TFileMap::EOpenMode om = TFileMap::oRdOnly, const char* dbgName = "unknown"); @@ -66,7 +66,7 @@ public: void precharge(size_t pos = 0, size_t size = (size_t)-1) const; - void swap(TMappedFile& file) noexcept { + void swap(TMappedFile& file) noexcept { DoSwap(Map_, file.Map_); } }; diff --git a/library/cpp/deprecated/split/delim_string_iter.cpp b/library/cpp/deprecated/split/delim_string_iter.cpp index af418c5bfb..af4147c18b 100644 --- a/library/cpp/deprecated/split/delim_string_iter.cpp +++ b/library/cpp/deprecated/split/delim_string_iter.cpp @@ -8,7 +8,7 @@ void TKeyValueDelimStringIter::ReadKeyAndValue() { TStringBuf currentToken(*DelimIter); size_t pos = currentToken.find('='); - if (pos == TString::npos) { + if (pos == TString::npos) { ChunkValue.Clear(); ChunkKey = currentToken; } else { diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index 18a8b2a160..c3adb53964 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> /// Test that TDelimStringIter build on top of given string and delimeter will produce expected sequence -static void AssertStringSplit(const TString& str, const TString& delim, const TVector<TString>& expected) { +static void AssertStringSplit(const TString& str, const TString& delim, const TVector<TString>& expected) { TDelimStringIter it(str, delim); // test iterator invariants @@ -40,8 +40,8 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { } Y_UNIT_TEST(ForIter) { - TVector<TStringBuf> expected = {"1", "", "3@4", ""}; - TVector<TStringBuf> got; + TVector<TStringBuf> expected = {"1", "", "3@4", ""}; + TVector<TStringBuf> got; for (TStringBuf x : TDelimStroka("1@@@@3@4@@", "@@")) { got.push_back(x); @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { static void AssertKeyValueStringSplit( const TStringBuf str, const TStringBuf delim, - const TVector<std::pair<TStringBuf, TStringBuf>>& expected) { + const TVector<std::pair<TStringBuf, TStringBuf>>& expected) { TKeyValueDelimStringIter it(str, delim); for (const auto& expectedKeyValue : expected) { diff --git a/library/cpp/deprecated/split/split_iterator.cpp b/library/cpp/deprecated/split/split_iterator.cpp index 32262d25bd..c56a80e722 100644 --- a/library/cpp/deprecated/split/split_iterator.cpp +++ b/library/cpp/deprecated/split/split_iterator.cpp @@ -21,7 +21,7 @@ TSplitBase::TSplitBase(const char* str, size_t length) { } -TSplitBase::TSplitBase(const TString& s) +TSplitBase::TSplitBase(const TString& s) : Str(s.data()) , Len(s.size()) { @@ -35,7 +35,7 @@ TDelimitersSplit::TDelimitersSplit(const char* str, size_t length, const TSplitD { } -TDelimitersSplit::TDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters) +TDelimitersSplit::TDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters) : TSplitBase(s) , Delimiters(delimiters) { @@ -72,7 +72,7 @@ TDelimitersStrictSplit::TDelimitersStrictSplit(const char* str, size_t length, c { } -TDelimitersStrictSplit::TDelimitersStrictSplit(const TString& s, const TSplitDelimiters& delimiters) +TDelimitersStrictSplit::TDelimitersStrictSplit(const TString& s, const TSplitDelimiters& delimiters) : TSplitBase(s) , Delimiters(delimiters) { @@ -100,7 +100,7 @@ size_t TDelimitersStrictSplit::Begin() const { /****************** TScreenedDelimitersSplit ******************/ -TScreenedDelimitersSplit::TScreenedDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters, const TSplitDelimiters& screens) +TScreenedDelimitersSplit::TScreenedDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters, const TSplitDelimiters& screens) : TSplitBase(s) , Delimiters(delimiters) , Screens(screens) @@ -148,7 +148,7 @@ TDelimitersSplitWithoutTags::TDelimitersSplitWithoutTags(const char* str, size_t { } -TDelimitersSplitWithoutTags::TDelimitersSplitWithoutTags(const TString& s, const TSplitDelimiters& delimiters) +TDelimitersSplitWithoutTags::TDelimitersSplitWithoutTags(const TString& s, const TSplitDelimiters& delimiters) : TSplitBase(s) , Delimiters(delimiters) { @@ -204,7 +204,7 @@ TCharSplit::TCharSplit(const char* str, size_t length) { } -TCharSplit::TCharSplit(const TString& s) +TCharSplit::TCharSplit(const TString& s) : TSplitBase(s) { } @@ -230,7 +230,7 @@ TCharSplitWithoutTags::TCharSplitWithoutTags(const char* str, size_t length) { } -TCharSplitWithoutTags::TCharSplitWithoutTags(const TString& s) +TCharSplitWithoutTags::TCharSplitWithoutTags(const TString& s) : TSplitBase(s) { } @@ -274,7 +274,7 @@ TCharSplitWithoutTags::TIterator TCharSplitWithoutTags::Iterator() const { return TIterator(*this); } -TSubstringSplitDelimiter::TSubstringSplitDelimiter(const TString& s) +TSubstringSplitDelimiter::TSubstringSplitDelimiter(const TString& s) : Matcher(s) , Len(s.size()) { @@ -288,7 +288,7 @@ TSubstringSplit::TSubstringSplit(const char* str, size_t length, const TSubstrin { } -TSubstringSplit::TSubstringSplit(const TString& str, const TSubstringSplitDelimiter& delimiter) +TSubstringSplit::TSubstringSplit(const TString& str, const TSubstringSplitDelimiter& delimiter) : TSplitBase(str) , Delimiter(delimiter) { diff --git a/library/cpp/deprecated/split/split_iterator.h b/library/cpp/deprecated/split/split_iterator.h index 0eacc29228..23ba85bbec 100644 --- a/library/cpp/deprecated/split/split_iterator.h +++ b/library/cpp/deprecated/split/split_iterator.h @@ -8,7 +8,7 @@ #include <util/system/yassert.h> #include <util/system/defaults.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -45,12 +45,12 @@ using TSizeTRegion = TNumPair<size_t>; using TUi32Region = TNumPair<ui32>; template <> -inline TString ToString(const TUi32Region& r) { +inline TString ToString(const TUi32Region& r) { return TStringBuilder() << "(" << r.Begin << ", " << r.End << ")"; } template <> -inline TUi32Region FromString(const TString& s) { +inline TUi32Region FromString(const TString& s) { TUi32Region result; sscanf(s.data(), "(%" PRIu32 ", %" PRIu32 ")", &result.Begin, &result.End); return result; @@ -78,7 +78,7 @@ protected: public: TSplitBase(const char* str, size_t length); - TSplitBase(const TString& s); + TSplitBase(const TString& s); Y_FORCE_INLINE const char* GetString() const { return Str; @@ -90,7 +90,7 @@ public: private: // we don't own Str, make sure that no one calls us with temporary object - TSplitBase(TString&&) = delete; + TSplitBase(TString&&) = delete; }; #ifdef _MSC_VER @@ -107,7 +107,7 @@ public: friend class TSplitIterator<TDelimitersSplit>; TDelimitersSplit(const char* str, size_t length, const TSplitDelimiters& delimiters); - TDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters); + TDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; @@ -115,8 +115,8 @@ public: private: // we don't own Delimiters, make sure that no one calls us with temporary object TDelimitersSplit(const char*, size_t, TSplitDelimiters&&) = delete; - TDelimitersSplit(const TString&, TSplitDelimiters&&) = delete; - TDelimitersSplit(TString&&, const TSplitDelimiters&) = delete; + TDelimitersSplit(const TString&, TSplitDelimiters&&) = delete; + TDelimitersSplit(TString&&, const TSplitDelimiters&) = delete; }; class TDelimitersStrictSplit: public TSplitBase { @@ -128,7 +128,7 @@ public: friend class TSplitIterator<TDelimitersStrictSplit>; TDelimitersStrictSplit(const char* str, size_t length, const TSplitDelimiters& delimiters); - TDelimitersStrictSplit(const TString& s, const TSplitDelimiters& delimiters); + TDelimitersStrictSplit(const TString& s, const TSplitDelimiters& delimiters); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; @@ -136,8 +136,8 @@ public: private: // we don't own Delimiters, make sure that no one calls us with temporary object TDelimitersStrictSplit(const char*, size_t, TSplitDelimiters&&) = delete; - TDelimitersStrictSplit(const TString&, TSplitDelimiters&&) = delete; - TDelimitersStrictSplit(TString&&, const TSplitDelimiters&) = delete; + TDelimitersStrictSplit(const TString&, TSplitDelimiters&&) = delete; + TDelimitersStrictSplit(TString&&, const TSplitDelimiters&) = delete; }; class TScreenedDelimitersSplit: public TSplitBase { @@ -150,16 +150,16 @@ public: friend class TSplitIterator<TScreenedDelimitersSplit>; TScreenedDelimitersSplit(const char*, size_t, const TSplitDelimiters& delimiters, const TSplitDelimiters& screens); - TScreenedDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters, const TSplitDelimiters& screens); + TScreenedDelimitersSplit(const TString& s, const TSplitDelimiters& delimiters, const TSplitDelimiters& screens); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; private: // we don't own Delimiters and Screens, make sure that no one calls us with temporary object - TScreenedDelimitersSplit(TString&&, const TSplitDelimiters&, const TSplitDelimiters&) = delete; - TScreenedDelimitersSplit(const TString&, TSplitDelimiters&&, const TSplitDelimiters&) = delete; - TScreenedDelimitersSplit(const TString&, const TSplitDelimiters&, TSplitDelimiters&&) = delete; + TScreenedDelimitersSplit(TString&&, const TSplitDelimiters&, const TSplitDelimiters&) = delete; + TScreenedDelimitersSplit(const TString&, TSplitDelimiters&&, const TSplitDelimiters&) = delete; + TScreenedDelimitersSplit(const TString&, const TSplitDelimiters&, TSplitDelimiters&&) = delete; }; class TDelimitersSplitWithoutTags: public TSplitBase { @@ -173,7 +173,7 @@ public: friend class TSplitIterator<TDelimitersSplitWithoutTags>; TDelimitersSplitWithoutTags(const char* str, size_t length, const TSplitDelimiters& delimiters); - TDelimitersSplitWithoutTags(const TString& s, const TSplitDelimiters& delimiters); + TDelimitersSplitWithoutTags(const TString& s, const TSplitDelimiters& delimiters); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; @@ -181,8 +181,8 @@ public: private: // we don't own Delimiters, make sure that no one calls us with temporary object TDelimitersSplitWithoutTags(const char*, size_t, TSplitDelimiters&&) = delete; - TDelimitersSplitWithoutTags(const TString&, TSplitDelimiters&&) = delete; - TDelimitersSplitWithoutTags(TString&&, const TSplitDelimiters&) = delete; + TDelimitersSplitWithoutTags(const TString&, TSplitDelimiters&&) = delete; + TDelimitersSplitWithoutTags(TString&&, const TSplitDelimiters&) = delete; }; class TCharSplit: public TSplitBase { @@ -191,14 +191,14 @@ public: friend class TSplitIterator<TCharSplit>; TCharSplit(const char* str, size_t length); - TCharSplit(const TString& s); + TCharSplit(const TString& s); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; private: // we don't own Str, make sure that no one calls us with temporary object - TCharSplit(TString&&) = delete; + TCharSplit(TString&&) = delete; }; #ifdef _MSC_VER @@ -215,14 +215,14 @@ public: friend class TSplitIterator<TCharSplitWithoutTags>; TCharSplitWithoutTags(const char* str, size_t length); - TCharSplitWithoutTags(const TString& s); + TCharSplitWithoutTags(const TString& s); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; private: // we don't own Str, make sure that no one calls us with temporary object - TCharSplitWithoutTags(TString&&) = delete; + TCharSplitWithoutTags(TString&&) = delete; }; class TSubstringSplitDelimiter { @@ -230,7 +230,7 @@ public: TKMPMatcher Matcher; size_t Len; - TSubstringSplitDelimiter(const TString& s); + TSubstringSplitDelimiter(const TString& s); }; class TSubstringSplit: public TSplitBase { @@ -242,15 +242,15 @@ public: friend class TSplitIterator<TSubstringSplit>; TSubstringSplit(const char* str, size_t length, const TSubstringSplitDelimiter& delimiter); - TSubstringSplit(const TString& str, const TSubstringSplitDelimiter& delimiter); + TSubstringSplit(const TString& str, const TSubstringSplitDelimiter& delimiter); TIterator Iterator() const; TSizeTRegion Next(size_t& pos) const; size_t Begin() const; private: // we don't own Delimiters, make sure that no one calls us with temporary object - TSubstringSplit(TString&&, const TSubstringSplitDelimiter&) = delete; - TSubstringSplit(const TString&, TSubstringSplitDelimiter&&) = delete; + TSubstringSplit(TString&&, const TSubstringSplitDelimiter&) = delete; + TSubstringSplit(const TString&, TSubstringSplitDelimiter&&) = delete; }; template <class TSplit> @@ -258,7 +258,7 @@ class TSplitIterator { protected: const TSplit& Split; size_t Pos; - TString* CurrentStroka; + TString* CurrentStroka; public: TSplitIterator(const TSplit& split) @@ -286,7 +286,7 @@ public: const TString& NextString() { if (!CurrentStroka) - CurrentStroka = new TString(); + CurrentStroka = new TString(); TSizeTRegion region = Next(); CurrentStroka->assign(Split.Str, region.Begin, region.Length() - 1); return *CurrentStroka; @@ -296,8 +296,8 @@ public: return Pos >= Split.Len; } - TString GetTail() const { - return TString(Split.Str + Pos); + TString GetTail() const { + return TString(Split.Str + Pos); } void Skip(size_t count) { @@ -306,7 +306,7 @@ public: } }; -using TSplitTokens = TVector<TString>; +using TSplitTokens = TVector<TString>; template <typename TSplit> void Split(const TSplit& split, TSplitTokens* words) { diff --git a/library/cpp/deprecated/split/split_iterator_ut.cpp b/library/cpp/deprecated/split/split_iterator_ut.cpp index be5069c4be..2508479383 100644 --- a/library/cpp/deprecated/split/split_iterator_ut.cpp +++ b/library/cpp/deprecated/split/split_iterator_ut.cpp @@ -33,7 +33,7 @@ void TSplitIteratorTest::TestDelimiters() { void TSplitIteratorTest::TestDelimitersSplit() { { - TString s = "1a3b45cd"; + TString s = "1a3b45cd"; TSplitDelimiters delims("abcd"); TDelimitersSplit split(s, delims); TSplitTokens tokens; @@ -42,7 +42,7 @@ void TSplitIteratorTest::TestDelimitersSplit() { UNIT_ASSERT(tokens == pattern); } { - TString s = "aaaaaa"; + TString s = "aaaaaa"; TSplitDelimiters delims("abcd"); TDelimitersSplit split(s, delims); TSplitTokens tokens; @@ -54,7 +54,7 @@ void TSplitIteratorTest::TestDelimitersSplit() { void TSplitIteratorTest::TestDelimitersStrictSplit() { { - TString s = "grp@2"; + TString s = "grp@2"; TSplitDelimiters delims("@"); TDelimitersStrictSplit split(s, delims); TSplitTokens tokens; @@ -64,7 +64,7 @@ void TSplitIteratorTest::TestDelimitersStrictSplit() { } { - TString s = "@grp@2@@"; + TString s = "@grp@2@@"; TSplitDelimiters delims("@"); TDelimitersStrictSplit split(s, delims); TSplitTokens tokens; @@ -75,7 +75,7 @@ void TSplitIteratorTest::TestDelimitersStrictSplit() { } void TSplitIteratorTest::TestTail() { - TString s = "grp@2@4"; + TString s = "grp@2@4"; TSplitDelimiters delims("@"); TDelimitersSplit split(s, delims); TDelimitersSplit::TIterator it = split.Iterator(); @@ -90,7 +90,7 @@ void TSplitIteratorTest::TestTail() { void TSplitIteratorTest::TestScreenedDelimitersSplit() { { - const TString s = "77.88.58.91 - - [28/Aug/2008:00:08:07 +0400] \"GET /export/mordashka.tgz HTTP/1.1\" 304 - \"-\" \"libwww-perl/5.805\" \"news.yandex.ru,80\" \"-\" \"-\" 1219867687 \"0\" 3283 2"; + const TString s = "77.88.58.91 - - [28/Aug/2008:00:08:07 +0400] \"GET /export/mordashka.tgz HTTP/1.1\" 304 - \"-\" \"libwww-perl/5.805\" \"news.yandex.ru,80\" \"-\" \"-\" 1219867687 \"0\" 3283 2"; const TSplitDelimiters delims(" "); const TSplitDelimiters screens("\"[]"); const TScreenedDelimitersSplit splitter(s, delims, screens); @@ -113,7 +113,7 @@ void TSplitIteratorTest::TestScreenedDelimitersSplit() { UNIT_ASSERT_EQUAL(it.NextString(), "2"); } { - const TString s = "77.88.58.91 - - [28/Aug/2008:00:08:07 +0400] \"GET /export/mordashka.tgz HTTP/1.1\" 304 - \"-\" \"libwww-perl/5.805\" \"news.yandex.ru,80\" \"-\" \"-\" 1219867687 \"0\" 3283 2"; + const TString s = "77.88.58.91 - - [28/Aug/2008:00:08:07 +0400] \"GET /export/mordashka.tgz HTTP/1.1\" 304 - \"-\" \"libwww-perl/5.805\" \"news.yandex.ru,80\" \"-\" \"-\" 1219867687 \"0\" 3283 2"; const TSplitDelimiters delims(" "); const TSplitDelimiters screens("\"[]"); const TScreenedDelimitersSplit splitter(s.Data(), s.Size(), delims, screens); @@ -138,7 +138,7 @@ void TSplitIteratorTest::TestScreenedDelimitersSplit() { } void TSplitIteratorTest::TestSubstringDelimiter() { - const TString s = "a@@bb@@cc@c.d@@r"; + const TString s = "a@@bb@@cc@c.d@@r"; static const TSubstringSplitDelimiter delimiter("@@"); const TSubstringSplit splitter(s, delimiter); TSubstringSplit::TIterator it = splitter.Iterator(); diff --git a/library/cpp/deprecated/split/ya.make b/library/cpp/deprecated/split/ya.make index 946e685ac8..fbe94578b7 100644 --- a/library/cpp/deprecated/split/ya.make +++ b/library/cpp/deprecated/split/ya.make @@ -7,8 +7,8 @@ SRCS( split_iterator.cpp ) -PEERDIR( +PEERDIR( library/cpp/deprecated/kmp -) - +) + END() diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 6c753f68a9..35d16e9cd8 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -18,8 +18,8 @@ RECURSE( ipreg1/ut_full ipreg1/util iter - kmp - kmp/ut + kmp + kmp/ut mapped_file mapped_file/ut mbitmap @@ -37,8 +37,8 @@ RECURSE( datawork/conf calc_module iterators_heap - parse_utils - parse_utils/ut + parse_utils + parse_utils/ut small_array solartrie solartrie/indexed_region/ut diff --git a/library/cpp/diff/diff.cpp b/library/cpp/diff/diff.cpp index be57da7f39..581afc29ac 100644 --- a/library/cpp/diff/diff.cpp +++ b/library/cpp/diff/diff.cpp @@ -7,8 +7,8 @@ template <typename T> struct TCollectionImpl { - TVector<TConstArrayRef<T>> Words; - TVector<ui64> Keys; + TVector<TConstArrayRef<T>> Words; + TVector<ui64> Keys; inline bool Consume(const T* b, const T* e, const T*) { if (b < e) { @@ -64,7 +64,7 @@ size_t NDiff::InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, } TCollection<char> c1(left, delims); TCollection<char> c2(right, delims); - TVector<TChunk<ui64>> diff; + TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); for (const auto& it : diff) { chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); @@ -78,7 +78,7 @@ size_t NDiff::InlineDiff(TVector<TChunk<wchar16>>& chunks, const TWtringBuf& lef } TCollection<wchar16> c1(left, delims); TCollection<wchar16> c2(right, delims); - TVector<TChunk<ui64>> diff; + TVector<TChunk<ui64>> diff; const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); for (const auto& it : diff) { chunks.push_back(TChunk<wchar16>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); diff --git a/library/cpp/diff/diff.h b/library/cpp/diff/diff.h index 94fb00cd0b..5a4f2e4314 100644 --- a/library/cpp/diff/diff.h +++ b/library/cpp/diff/diff.h @@ -3,7 +3,7 @@ #include <library/cpp/lcs/lcs_via_lis.h> #include <util/generic/algorithm.h> -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/generic/strbuf.h> #include <util/generic/vector.h> #include <util/stream/output.h> @@ -39,7 +39,7 @@ namespace NDiff { swapped = true; } - TVector<T> lcs; + TVector<T> lcs; NLCS::TLCSCtx<T> ctx; NLCS::MakeLCS<T>(s1, s2, &lcs, &ctx); @@ -91,8 +91,8 @@ namespace NDiff { } template <typename TFormatter, typename T> - void PrintChunks(IOutputStream& out, const TFormatter& fmt, const TVector<TChunk<T>>& chunks) { - for (typename TVector<TChunk<T>>::const_iterator chunk = chunks.begin(); chunk != chunks.end(); ++chunk) { + void PrintChunks(IOutputStream& out, const TFormatter& fmt, const TVector<TChunk<T>>& chunks) { + for (typename TVector<TChunk<T>>::const_iterator chunk = chunks.begin(); chunk != chunks.end(); ++chunk) { if (!chunk->Left.empty() || !chunk->Right.empty()) { out << fmt.Special("("); out << fmt.Left(chunk->Left); diff --git a/library/cpp/diff/diff_ut.cpp b/library/cpp/diff/diff_ut.cpp index b82a7b000e..d409faf4e3 100644 --- a/library/cpp/diff/diff_ut.cpp +++ b/library/cpp/diff/diff_ut.cpp @@ -6,7 +6,7 @@ using namespace NDiff; struct TDiffTester { TStringStream Res; - TVector<TChunk<char>> Chunks; + TVector<TChunk<char>> Chunks; TStringBuf Special(const TStringBuf& str) const { return str; @@ -24,14 +24,14 @@ struct TDiffTester { return TStringBuf(str.begin(), str.end()); } - void Test(const TStringBuf& a, const TStringBuf& b, const TString& delims = " \t\n") { + void Test(const TStringBuf& a, const TStringBuf& b, const TString& delims = " \t\n") { Chunks.clear(); InlineDiff(Chunks, a, b, delims); Res.clear(); PrintChunks(Res, *this, Chunks); } - const TString& Result() const { + const TString& Result() const { return Res.Str(); } }; diff --git a/library/cpp/digest/argonish/internal/argon2/argon2_base.h b/library/cpp/digest/argonish/internal/argon2/argon2_base.h index 2385cc947c..9b02d1efbb 100644 --- a/library/cpp/digest/argonish/internal/argon2/argon2_base.h +++ b/library/cpp/digest/argonish/internal/argon2/argon2_base.h @@ -153,19 +153,19 @@ namespace NArgonish { ui8 in_buffer[BLAKE2B_OUTBYTES]; ui32 toproduce = outlen - BLAKE2B_OUTBYTES / 2; - TBlake2B<instructionSet> hash1(BLAKE2B_OUTBYTES); - hash1.Update(outlen); - hash1.Update(in, inlen); - hash1.Final(out_buffer, BLAKE2B_OUTBYTES); + TBlake2B<instructionSet> hash1(BLAKE2B_OUTBYTES); + hash1.Update(outlen); + hash1.Update(in, inlen); + hash1.Final(out_buffer, BLAKE2B_OUTBYTES); memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); out += BLAKE2B_OUTBYTES / 2; while (toproduce > BLAKE2B_OUTBYTES) { memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - TBlake2B<instructionSet> hash2(BLAKE2B_OUTBYTES); - hash2.Update(in_buffer, BLAKE2B_OUTBYTES); - hash2.Final(out_buffer, BLAKE2B_OUTBYTES); + TBlake2B<instructionSet> hash2(BLAKE2B_OUTBYTES); + hash2.Update(in_buffer, BLAKE2B_OUTBYTES); + hash2.Final(out_buffer, BLAKE2B_OUTBYTES); memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); out += BLAKE2B_OUTBYTES / 2; toproduce -= BLAKE2B_OUTBYTES / 2; @@ -173,9 +173,9 @@ namespace NArgonish { memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); { - TBlake2B<instructionSet> hash3(toproduce); - hash3.Update(in_buffer, BLAKE2B_OUTBYTES); - hash3.Final(out_buffer, toproduce); + TBlake2B<instructionSet> hash3(toproduce); + hash3.Update(in_buffer, BLAKE2B_OUTBYTES); + hash3.Final(out_buffer, toproduce); memcpy(out, out_buffer, toproduce); } } diff --git a/library/cpp/digest/lower_case/hash_ops.h b/library/cpp/digest/lower_case/hash_ops.h index 83ebf7aca4..8bc3171390 100644 --- a/library/cpp/digest/lower_case/hash_ops.h +++ b/library/cpp/digest/lower_case/hash_ops.h @@ -2,7 +2,7 @@ #include <util/generic/strbuf.h> -// can be used for caseless hashes like: THashMap<TStringBuf, T, TCIOps, TCIOps> +// can be used for caseless hashes like: THashMap<TStringBuf, T, TCIOps, TCIOps> struct TCIOps { size_t operator()(const char* s) const noexcept; diff --git a/library/cpp/digest/lower_case/hash_ops_ut.cpp b/library/cpp/digest/lower_case/hash_ops_ut.cpp index a7ab0b86ea..610f89f246 100644 --- a/library/cpp/digest/lower_case/hash_ops_ut.cpp +++ b/library/cpp/digest/lower_case/hash_ops_ut.cpp @@ -4,7 +4,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { Y_UNIT_TEST(TestYHash1) { - THashMap<TStringBuf, int, TCIOps, TCIOps> h; + THashMap<TStringBuf, int, TCIOps, TCIOps> h; h["Ab"] = 1; h["aB"] = 2; @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TestCIHash) { } Y_UNIT_TEST(TestYHash2) { - THashMap<const char*, int, TCIOps, TCIOps> h; + THashMap<const char*, int, TCIOps, TCIOps> h; h["Ab"] = 1; h["aB"] = 2; diff --git a/library/cpp/digest/lower_case/lchash.h b/library/cpp/digest/lower_case/lchash.h index 6a287d9479..5cc13bc612 100644 --- a/library/cpp/digest/lower_case/lchash.h +++ b/library/cpp/digest/lower_case/lchash.h @@ -6,13 +6,13 @@ #include <util/generic/strbuf.h> template <class T> -static inline T FnvCaseLess(const char* b, size_t l, T t = 0) noexcept { +static inline T FnvCaseLess(const char* b, size_t l, T t = 0) noexcept { using TIter = TLowerCaseIterator<const char>; return FnvHash(TIter(b), TIter(b + l), t); } template <class T> -static inline T FnvCaseLess(const TStringBuf& s, T t = 0) noexcept { +static inline T FnvCaseLess(const TStringBuf& s, T t = 0) noexcept { return FnvCaseLess(s.data(), s.size(), t); } diff --git a/library/cpp/digest/lower_case/lciter.h b/library/cpp/digest/lower_case/lciter.h index 9538e57932..72f639605e 100644 --- a/library/cpp/digest/lower_case/lciter.h +++ b/library/cpp/digest/lower_case/lciter.h @@ -7,24 +7,24 @@ template <class T> struct TLowerCaseIterator: public std::iterator<std::input_iterator_tag, T> { - using TNonConst = std::remove_const_t<T>; + using TNonConst = std::remove_const_t<T>; inline TLowerCaseIterator(T* c) : C(c) { } - inline TLowerCaseIterator& operator++() noexcept { + inline TLowerCaseIterator& operator++() noexcept { ++C; return *this; } - inline TLowerCaseIterator operator++(int) noexcept { + inline TLowerCaseIterator operator++(int) noexcept { return C++; } - inline TNonConst operator*() const noexcept { + inline TNonConst operator*() const noexcept { return AsciiToLower(*C); } @@ -32,11 +32,11 @@ struct TLowerCaseIterator: public std::iterator<std::input_iterator_tag, T> { }; template <class T> -inline bool operator==(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept { +inline bool operator==(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept { return l.C == r.C; } template <class T> -inline bool operator!=(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept { +inline bool operator!=(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept { return !(l == r); } diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 24a5b69eef..181fbcc812 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -38,7 +38,7 @@ namespace { char* MD5::File(const char* filename, char* buf) { try { - TUnbufferedFileInput fi(filename); + TUnbufferedFileInput fi(filename); return Stream(&fi, buf); } catch (...) { @@ -47,7 +47,7 @@ char* MD5::File(const char* filename, char* buf) { return nullptr; } -TString MD5::File(const TString& filename) { +TString MD5::File(const TString& filename) { TString buf; buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); auto result = MD5::File(filename.data(), buf.begin()); @@ -225,7 +225,7 @@ TString MD5::CalcRaw(TStringBuf data) { } TString MD5::CalcRaw(const TArrayRef<const ui8>& data) { - TString result; + TString result; result.ReserveAndResize(16); MD5().Update(data).Final(reinterpret_cast<ui8*>(result.begin())); return result; diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 2c17aa0518..c2aab90e4a 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -46,7 +46,7 @@ public: * Return nullptr / empty string if the file does not exist. */ static char* File(const char* filename, char* buf); - static TString File(const TString& filename); + static TString File(const TString& filename); static char* Data(const void* data, size_t len, char* buf); static char* Data(const TArrayRef<const ui8>& data, char* buf); diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 1c3e4ad0a9..70c2946f03 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { r.Update((const unsigned char*)b + 15, strlen(b) - 15); char rs[33]; - TString s(r.End(rs)); + TString s(r.End(rs)); s.to_lower(); UNIT_ASSERT_NO_DIFF(s, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); @@ -26,11 +26,11 @@ Y_UNIT_TEST_SUITE(TMD5Test) { } Y_UNIT_TEST(TestFile) { - TString s = NUnitTest::RandomString(1000000, 1); - const TString tmpFile = "tmp"; + TString s = NUnitTest::RandomString(1000000, 1); + const TString tmpFile = "tmp"; { - TFixedBufferFileOutput fo(tmpFile); + TFixedBufferFileOutput fo(tmpFile); fo.Write(s.data(), s.size()); } diff --git a/library/cpp/digest/old_crc/gencrc/main.cpp b/library/cpp/digest/old_crc/gencrc/main.cpp index d5821304ce..d7816d9631 100644 --- a/library/cpp/digest/old_crc/gencrc/main.cpp +++ b/library/cpp/digest/old_crc/gencrc/main.cpp @@ -16,10 +16,10 @@ static void crc16init() { else crc >>= 1; - for (size_t k = 0; k < 256; ++k) { - Cout << " ULL(" << CRCTAB16[k] << ")"; + for (size_t k = 0; k < 256; ++k) { + Cout << " ULL(" << CRCTAB16[k] << ")"; - if (k != 255) { + if (k != 255) { Cout << ",\n"; } } @@ -37,10 +37,10 @@ static void crc32init() { else crc >>= 1; - for (size_t k = 0; k < 256; ++k) { - Cout << " ULL(" << CRCTAB32[k] << ")"; + for (size_t k = 0; k < 256; ++k) { + Cout << " ULL(" << CRCTAB32[k] << ")"; - if (k != 255) { + if (k != 255) { Cout << ",\n"; } } diff --git a/library/cpp/digest/sfh/sfh.h b/library/cpp/digest/sfh/sfh.h index 372938654c..3e998d8848 100644 --- a/library/cpp/digest/sfh/sfh.h +++ b/library/cpp/digest/sfh/sfh.h @@ -3,7 +3,7 @@ #include <util/system/defaults.h> #include <util/system/unaligned_mem.h> -inline ui32 SuperFastHash(const void* d, size_t l) noexcept { +inline ui32 SuperFastHash(const void* d, size_t l) noexcept { ui32 hash = (ui32)l; ui32 tmp; diff --git a/library/cpp/digest/ya.make b/library/cpp/digest/ya.make index 61d4b50903..64dcbc7c87 100644 --- a/library/cpp/digest/ya.make +++ b/library/cpp/digest/ya.make @@ -1,8 +1,8 @@ RECURSE( - argonish - argonish/benchmark - argonish/ut_fat - argonish/ut + argonish + argonish/benchmark + argonish/ut_fat + argonish/ut benchmark fast lower_case diff --git a/library/cpp/dns/cache.cpp b/library/cpp/dns/cache.cpp index 05c14e82fc..a1031fed02 100644 --- a/library/cpp/dns/cache.cpp +++ b/library/cpp/dns/cache.cpp @@ -80,7 +80,7 @@ namespace { } } - void AddAlias(const TString& host, const TString& alias) noexcept { + void AddAlias(const TString& host, const TString& alias) noexcept { TWriteGuard guard(LA_); A_[host] = alias; @@ -92,8 +92,8 @@ namespace { private: inline TResolvedHostPtr ResolveA(const TResolveTask& rt) { - TString originalHost(rt.Info.Host); - TString host(originalHost); + TString originalHost(rt.Info.Host); + TString host(originalHost); //3. replace host to alias, if exist if (A_.size()) { @@ -129,10 +129,10 @@ namespace { return new TResolvedHost(originalHost, *na); } - typedef THashMap<TResolveInfo, TResolvedHostPtr, THashResolveInfo, TCompareResolveInfo> TCache; + typedef THashMap<TResolveInfo, TResolvedHostPtr, THashResolveInfo, TCompareResolveInfo> TCache; TCache C_; TRWMutex L_; - typedef THashMap<TString, TString> TAliases; + typedef THashMap<TString, TString> TAliases; TAliases A_; TRWMutex LA_; }; @@ -162,7 +162,7 @@ namespace { } private: - typedef THashMap<TResolveInfo, const TResolvedHost*, THashResolveInfo, TCompareResolveInfo> TCache; + typedef THashMap<TResolveInfo, const TResolvedHost*, THashResolveInfo, TCompareResolveInfo> TCache; TCache C_; IDns* S_; }; @@ -192,7 +192,7 @@ namespace NDns { return ThrDns()->Resolve(rt); } - void AddHostAlias(const TString& host, const TString& alias) { + void AddHostAlias(const TString& host, const TString& alias) { TGlobalCachedDns::Instance()->AddAlias(host, alias); } } diff --git a/library/cpp/dns/cache.h b/library/cpp/dns/cache.h index eda5dc4070..01c5da298f 100644 --- a/library/cpp/dns/cache.h +++ b/library/cpp/dns/cache.h @@ -2,7 +2,7 @@ #include <util/network/socket.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace NDns { struct TResolveInfo { @@ -17,14 +17,14 @@ namespace NDns { }; struct TResolvedHost { - inline TResolvedHost(const TString& host, const TNetworkAddress& addr) noexcept + inline TResolvedHost(const TString& host, const TNetworkAddress& addr) noexcept : Host(host) , Addr(addr) , Id(0) { } - TString Host; //resolved hostname (from TResolveInfo, - before aliasing) + TString Host; //resolved hostname (from TResolveInfo, - before aliasing) TNetworkAddress Addr; size_t Id; //cache record id }; @@ -41,5 +41,5 @@ namespace NDns { const TResolvedHost* CachedThrResolve(const TResolveInfo& ri); //create alias for host, which can be used for static resolving (when alias is ip address) - void AddHostAlias(const TString& host, const TString& alias); + void AddHostAlias(const TString& host, const TString& alias); } diff --git a/library/cpp/dns/thread.cpp b/library/cpp/dns/thread.cpp index 8b27d2d527..a8441d7c90 100644 --- a/library/cpp/dns/thread.cpp +++ b/library/cpp/dns/thread.cpp @@ -14,7 +14,7 @@ using namespace NDns; namespace { class TThreadedResolver: public IThreadFactory::IThreadAble, public TNonCopyable { struct TResolveRequest { - inline TResolveRequest(const TString& host, ui16 port) + inline TResolveRequest(const TString& host, ui16 port) : Host(host) , Port(port) { @@ -36,7 +36,7 @@ namespace { ythrow TNetworkResolutionError(EAI_FAIL) << TStringBuf(": shit happen"); } - inline void Resolve() noexcept { + inline void Resolve() noexcept { try { Result = new TNetworkAddress(Host, Port); } catch (...) { @@ -46,11 +46,11 @@ namespace { Wake(); } - inline void Wake() noexcept { + inline void Wake() noexcept { E.Signal(); } - TString Host; + TString Host; ui16 Port; TManualEvent E; TNetworkAddressPtr Result; @@ -64,7 +64,7 @@ namespace { T_.push_back(SystemThreadFactory()->Run(this)); } - inline ~TThreadedResolver() override { + inline ~TThreadedResolver() override { Schedule(nullptr); for (size_t i = 0; i < T_.size(); ++i) { @@ -86,7 +86,7 @@ namespace { return Singleton<TThreadedResolver>(); } - inline TNetworkAddressPtr Resolve(const TString& host, ui16 port) { + inline TNetworkAddressPtr Resolve(const TString& host, ui16 port) { TResolveRequest rr(host, port); Schedule(&rr); @@ -122,12 +122,12 @@ namespace { TLockFreeQueue<TResolveRequest*> Q_; TSystemEvent E_; typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; - TVector<IThreadRef> T_; + TVector<IThreadRef> T_; }; } namespace NDns { - TNetworkAddressPtr ThreadedResolve(const TString& host, ui16 port) { + TNetworkAddressPtr ThreadedResolve(const TString& host, ui16 port) { return TThreadedResolver::Instance()->Resolve(host, port); } } diff --git a/library/cpp/dns/thread.h b/library/cpp/dns/thread.h index 06b41d78ce..f831b6bd0b 100644 --- a/library/cpp/dns/thread.h +++ b/library/cpp/dns/thread.h @@ -2,11 +2,11 @@ #include <util/network/socket.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ptr.h> namespace NDns { typedef TAutoPtr<TNetworkAddress> TNetworkAddressPtr; - TNetworkAddressPtr ThreadedResolve(const TString& host, ui16 port); + TNetworkAddressPtr ThreadedResolve(const TString& host, ui16 port); } diff --git a/library/cpp/enumbitset/enumbitset.h b/library/cpp/enumbitset/enumbitset.h index 41864c3a04..bd82474633 100644 --- a/library/cpp/enumbitset/enumbitset.h +++ b/library/cpp/enumbitset/enumbitset.h @@ -285,13 +285,13 @@ public: return t; } - TString ToString() const { + TString ToString() const { static_assert(sizeof(typename TParent::TChunk) <= sizeof(ui64), "expect sizeof(typename TParent::TChunk) <= sizeof(ui64)"); static const size_t chunkSize = sizeof(typename TParent::TChunk) * 8; static const size_t numDig = chunkSize / 4; - static const TString templ = Sprintf("%%0%lulX", numDig); + static const TString templ = Sprintf("%%0%lulX", numDig); static const size_t numOfChunks = (BitsetSize + chunkSize - 1) / chunkSize; - TString ret; + TString ret; for (int pos = numOfChunks * chunkSize; pos >= 0; pos -= chunkSize) { ui64 t = 0; this->Export(pos, t); @@ -473,13 +473,13 @@ public: Init(c1, c2, r...); } - static TSfEnumBitSet GetFromString(const TString& s) { + static TSfEnumBitSet GetFromString(const TString& s) { TSfEnumBitSet ebs; ebs.FromString(s); return ebs; } - static TSfEnumBitSet TryGetFromString(const TString& s) { + static TSfEnumBitSet TryGetFromString(const TString& s) { TSfEnumBitSet ebs; ebs.TryFromString(s); return ebs; diff --git a/library/cpp/execprofile/profile.cpp b/library/cpp/execprofile/profile.cpp index d05de20203..5af8845f63 100644 --- a/library/cpp/execprofile/profile.cpp +++ b/library/cpp/execprofile/profile.cpp @@ -19,7 +19,7 @@ #include <util/generic/map.h> #include <util/generic/noncopyable.h> #include <util/generic/algorithm.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/stream/file.h> #include <util/string/util.h> #include <util/system/datetime.h> diff --git a/library/cpp/getopt/print.cpp b/library/cpp/getopt/print.cpp index 8cf1c62e4d..57c244f333 100644 --- a/library/cpp/getopt/print.cpp +++ b/library/cpp/getopt/print.cpp @@ -10,7 +10,7 @@ #include <library/cpp/build_info/build_info.h> namespace NLastGetoptPrivate { - TString InitVersionString() { + TString InitVersionString() { TString ts = GetProgramSvnVersion(); ts += "\n"; ts += GetBuildInfo(); @@ -27,7 +27,7 @@ namespace NLastGetoptPrivate { return ts; } - TString& VersionString(); + TString& VersionString(); TString& ShortVersionString(); struct TInit { diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h index a8dd5adca9..fe6c2c064d 100644 --- a/library/cpp/getopt/small/last_getopt_opt.h +++ b/library/cpp/getopt/small/last_getopt_opt.h @@ -5,7 +5,7 @@ #include <util/string/split.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/maybe.h> #include <util/generic/vector.h> #include <util/string/cast.h> diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp index 03c432849f..13c327af12 100644 --- a/library/cpp/getopt/small/last_getopt_opts.cpp +++ b/library/cpp/getopt/small/last_getopt_opts.cpp @@ -11,8 +11,8 @@ #include <stdlib.h> namespace NLastGetoptPrivate { - TString& VersionString() { - static TString data; + TString& VersionString() { + static TString data; return data; } TString& ShortVersionString() { diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 7668b12a03..cf04841fd4 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -124,7 +124,7 @@ namespace NLastGetopt { if (opt->GetHasArg() == NO_ARGUMENT) { return Commit(opt, nullptr, pos, p); } - return Commit(opt, arg.SubStr(p), pos + 1, 0); + return Commit(opt, arg.SubStr(p), pos + 1, 0); } bool TOptsParser::ParseShortOptArg(size_t pos) { diff --git a/library/cpp/getopt/small/last_getopt_support.h b/library/cpp/getopt/small/last_getopt_support.h index 17bed3e614..72474578c5 100644 --- a/library/cpp/getopt/small/last_getopt_support.h +++ b/library/cpp/getopt/small/last_getopt_support.h @@ -1,7 +1,7 @@ #pragma once #include <util/string/cast.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/utility.h> #include <util/generic/yexception.h> diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 2fa5cfd070..f6e091fb2d 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -128,11 +128,11 @@ void TModChooser::AddAlias(const TString& alias, const TString& mode) { Modes[alias] = Modes[mode]; } -void TModChooser::SetDescription(const TString& descr) { +void TModChooser::SetDescription(const TString& descr) { Description = descr; } -void TModChooser::SetModesHelpOption(const TString& helpOption) { +void TModChooser::SetModesHelpOption(const TString& helpOption) { ModesHelpOption = helpOption; } @@ -144,7 +144,7 @@ void TModChooser::SetSeparatedMode(bool separated) { ShowSeparated = separated; } -void TModChooser::SetSeparationString(const TString& str) { +void TModChooser::SetSeparationString(const TString& str) { SeparationString = str; } @@ -277,7 +277,7 @@ TString TModChooser::TMode::FormatFullName(size_t pad) const { return name; } -void TModChooser::PrintHelp(const TString& progName) const { +void TModChooser::PrintHelp(const TString& progName) const { Cerr << Description << Endl << Endl; Cerr << NColorizer::StdErr().BoldColor() << "Usage" << NColorizer::StdErr().OldColor() << ": " << progName << " MODE [MODE_OPTIONS]" << Endl; Cerr << Endl; diff --git a/library/cpp/getopt/small/modchooser.h b/library/cpp/getopt/small/modchooser.h index 0a8de6d50b..656e007489 100644 --- a/library/cpp/getopt/small/modchooser.h +++ b/library/cpp/getopt/small/modchooser.h @@ -3,7 +3,7 @@ #include "last_getopt_opts.h" #include <util/generic/map.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <functional> @@ -63,10 +63,10 @@ public: void AddAlias(const TString& alias, const TString& mode); //! Set main program description. - void SetDescription(const TString& descr); + void SetDescription(const TString& descr); //! Set modes help option name (-? is by default) - void SetModesHelpOption(const TString& helpOption); + void SetModesHelpOption(const TString& helpOption); //! Specify handler for '--version' parameter void SetVersionHandler(TVersionHandlerPtr handler); @@ -75,7 +75,7 @@ public: void SetSeparatedMode(bool separated = true); //! Set separation string - void SetSeparationString(const TString& str); + void SetSeparationString(const TString& str); //! Set short command representation in Usage block void SetPrintShortCommandInUsage(bool printShortCommandInUsage); @@ -100,12 +100,12 @@ public: //! Run appropriate mode. Same as Run(const int, const char**) int Run(const TVector<TString>& argv) const; - void PrintHelp(const TString& progName) const; + void PrintHelp(const TString& progName) const; struct TMode { - TString Name; + TString Name; TMainClass* Main; - TString Description; + TString Description; bool Hidden; bool NoCompletion; TVector<TString> Aliases; @@ -136,10 +136,10 @@ public: private: //! Main program description. - TString Description; + TString Description; //! Help option for modes. - TString ModesHelpOption; + TString ModesHelpOption; //! Wrappers around all modes. TVector<THolder<TMainClass>> Wrappers; @@ -162,7 +162,7 @@ private: bool PrintShortCommandInUsage; //! Text string used when displaying each separator - TString SeparationString; + TString SeparationString; //! Unsorted list of options TVector<THolder<TMode>> UnsortedModes; diff --git a/library/cpp/getopt/small/opt.h b/library/cpp/getopt/small/opt.h index ecb57439bc..b18f06d6e0 100644 --- a/library/cpp/getopt/small/opt.h +++ b/library/cpp/getopt/small/opt.h @@ -93,7 +93,7 @@ public: return Arg; } - TVector<TString> GetFreeArgs() const { + TVector<TString> GetFreeArgs() const { return NLastGetopt::TOptsParseResult(&*Opts_, GetArgC(), GetArgV()).GetFreeArgs(); } diff --git a/library/cpp/getopt/small/opt2.cpp b/library/cpp/getopt/small/opt2.cpp index 0cdc774e78..2816aef7a5 100644 --- a/library/cpp/getopt/small/opt2.cpp +++ b/library/cpp/getopt/small/opt2.cpp @@ -57,7 +57,7 @@ void Opt2::EatArgv(const char* optspec, const char* long_alias) { // long_alias has a form "long-name1=A,long-name2=B", etc. // This implementation is limited to aliasing a single long option // with single short option (extend it if you really need). - THashMap<const char*, char> long2short; + THashMap<const char*, char> long2short; long2short["help"] = '?'; long_alias = long_alias ? long_alias : ""; alias_copy = long_alias; @@ -105,7 +105,7 @@ void Opt2::EatArgv(const char* optspec, const char* long_alias) { } // long option always spans one argv (--switch or --option-name=value) const char* eq = strchr(s, '='); - TString lname(s, eq ? (size_t)(eq - s) : (size_t)strlen(s)); + TString lname(s, eq ? (size_t)(eq - s) : (size_t)strlen(s)); THashMap<const char*, char>::iterator i = long2short.find(lname.data()); if (i == long2short.end()) { UnknownLongOption = strdup(lname.data()); // free'd in AutoUsage() diff --git a/library/cpp/getopt/small/opt2.h b/library/cpp/getopt/small/opt2.h index 4d9d943237..70b2701122 100644 --- a/library/cpp/getopt/small/opt2.h +++ b/library/cpp/getopt/small/opt2.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/defaults.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> // simplified options parser @@ -31,9 +31,9 @@ struct Opt2Param { bool IsRequired; bool MultipleUse; const char* DefValue; - TString DefValueStr; - TString HelpUsage; - TVector<const char*> ActualValue; + TString DefValueStr; + TString HelpUsage; + TVector<const char*> ActualValue; const char* LongOptName; Opt2Param() : HasArg(false) @@ -112,7 +112,7 @@ public: public: // non-option args - TVector<char*> Pos; + TVector<char*> Pos; bool HasErrors; private: @@ -122,15 +122,15 @@ private: char OptionMissingArg; char OptionWrongArg; char RequiredOptionMissing; - TVector<TString> UserErrorMessages; + TVector<TString> UserErrorMessages; protected: int Argc; char* const* Argv; int MinArgs, MaxArgs; ui8 SpecsMap[256]; - TVector<Opt2Param> Specs; - TString alias_copy; + TVector<Opt2Param> Specs; + TString alias_copy; void EatArgv(const char* optspec, const char* long_alias); void Clear(); Opt2Param& GetInternal(char opt, const char* defValue, const char* helpUsage, bool required); diff --git a/library/cpp/getopt/small/ygetopt.cpp b/library/cpp/getopt/small/ygetopt.cpp index 1f52827f74..f11e39588e 100644 --- a/library/cpp/getopt/small/ygetopt.cpp +++ b/library/cpp/getopt/small/ygetopt.cpp @@ -1,7 +1,7 @@ #include "opt.h" #include "ygetopt.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -67,7 +67,7 @@ private: const char* Arg_; }; -TGetOpt::TIterator::TIterator() noexcept +TGetOpt::TIterator::TIterator() noexcept : Impl_(nullptr) { } @@ -82,11 +82,11 @@ void TGetOpt::TIterator::Next() { Impl_->Next(); } -char TGetOpt::TIterator::Key() const noexcept { +char TGetOpt::TIterator::Key() const noexcept { return Impl_->Key(); } -bool TGetOpt::TIterator::AtEnd() const noexcept { +bool TGetOpt::TIterator::AtEnd() const noexcept { if (Impl_.Get()) { return Impl_->AtEnd(); } @@ -94,7 +94,7 @@ bool TGetOpt::TIterator::AtEnd() const noexcept { return true; } -const char* TGetOpt::TIterator::Arg() const noexcept { +const char* TGetOpt::TIterator::Arg() const noexcept { if (Impl_.Get()) { return Impl_->Arg(); } @@ -102,7 +102,7 @@ const char* TGetOpt::TIterator::Arg() const noexcept { return nullptr; } -TGetOpt::TGetOpt(int argc, const char* const* argv, const TString& format) +TGetOpt::TGetOpt(int argc, const char* const* argv, const TString& format) : Impl_(new TImpl(argc, argv, format)) { } diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index c99a1d053d..d35a493021 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -19,22 +19,22 @@ namespace { }; class TOptsParseResultTestWrapper: public TOptsParseResultException { - TVector<const char*> Argv_; + TVector<const char*> Argv_; public: - TOptsParseResultTestWrapper(const TOpts* opts, TVector<const char*> argv) + TOptsParseResultTestWrapper(const TOpts* opts, TVector<const char*> argv) : Argv_(argv) { Init(opts, (int)Argv_.size(), Argv_.data()); } }; - using V = TVector<const char*>; + using V = TVector<const char*>; } struct TOptsParserTester { TOptsNoDefault Opts_; - TVector<const char*> Argv_; + TVector<const char*> Argv_; THolder<TOptsParser> Parser_; @@ -58,13 +58,13 @@ struct TOptsParserTester { UNIT_ASSERT(Parser_->CurOpt()->CharIs(c)); } - void AcceptOption(const TString& optName) { + void AcceptOption(const TString& optName) { AcceptOption(); UNIT_ASSERT(Parser_->CurOpt()->NameIs(optName)); } template <typename TOpt> - void AcceptOptionWithValue(TOpt optName, const TString& value) { + void AcceptOptionWithValue(TOpt optName, const TString& value) { AcceptOption(optName); UNIT_ASSERT_VALUES_EQUAL_C(value, Parser_->CurValStr(), "; option " << optName); } @@ -75,7 +75,7 @@ struct TOptsParserTester { UNIT_ASSERT_C(!Parser_->CurVal(), ": opt " << optName << " must have no param"); } - void AcceptFreeArgInOrder(const TString& expected) { + void AcceptFreeArgInOrder(const TString& expected) { Accept(); UNIT_ASSERT(!Parser_->CurOpt()); UNIT_ASSERT_VALUES_EQUAL(expected, Parser_->CurValStr()); @@ -114,7 +114,7 @@ struct TOptsParserTester { UNIT_ASSERT_VALUES_EQUAL(sop, Parser_->Sop_); } - void AcceptFreeArg(const TString& expected) { + void AcceptFreeArg(const TString& expected) { UNIT_ASSERT(Pos_ < Parser_->Argc_); UNIT_ASSERT_VALUES_EQUAL(expected, Parser_->Argv_[Pos_]); ++Pos_; @@ -417,7 +417,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { Y_UNIT_TEST(TestStoreResult) { TOptsNoDefault opts; - TString data; + TString data; int number; TMaybe<TString> optionalString0, optionalString1; TMaybe<int> optionalNumber0, optionalNumber1; @@ -483,10 +483,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { Y_UNIT_TEST(TestSplitValue) { TOptsNoDefault opts; - TVector<TString> vals; + TVector<TString> vals; opts.AddLongOption('s', "split").SplitHandler(&vals, ','); TOptsParseResultTestWrapper r(&opts, V({"prog", "--split=a,b,c"})); - UNIT_ASSERT_EQUAL(vals.size(), 3); + UNIT_ASSERT_EQUAL(vals.size(), 3); UNIT_ASSERT_EQUAL(vals[0], "a"); UNIT_ASSERT_EQUAL(vals[1], "b"); UNIT_ASSERT_EQUAL(vals[2], "c"); @@ -494,10 +494,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { Y_UNIT_TEST(TestRangeSplitValue) { TOptsNoDefault opts; - TVector<ui32> vals; + TVector<ui32> vals; opts.AddLongOption('s', "split").RangeSplitHandler(&vals, ',', '-'); TOptsParseResultTestWrapper r(&opts, V({"prog", "--split=1,8-10", "--split=12-14"})); - UNIT_ASSERT_EQUAL(vals.size(), 7); + UNIT_ASSERT_EQUAL(vals.size(), 7); UNIT_ASSERT_EQUAL(vals[0], 1); UNIT_ASSERT_EQUAL(vals[1], 8); UNIT_ASSERT_EQUAL(vals[2], 9); @@ -577,7 +577,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { Y_UNIT_TEST(TestTitleAndPrintUsage) { TOpts opts; const char* prog = "my_program"; - TString title = TString("Sample ") + TString(prog).Quote() + " application"; + TString title = TString("Sample ") + TString(prog).Quote() + " application"; opts.SetTitle(title); int argc = 2; const char* cmd[] = {prog}; @@ -585,15 +585,15 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { TStringStream out; parser.PrintUsage(out); // find title - UNIT_ASSERT(out.Str().find(title) != TString::npos); + UNIT_ASSERT(out.Str().find(title) != TString::npos); // find usage - UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos); + UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos); } Y_UNIT_TEST(TestCustomCmdLineDescr) { TOpts opts; const char* prog = "my_program"; - TString customDescr = "<FILE|TABLE> USER [OPTIONS]"; + TString customDescr = "<FILE|TABLE> USER [OPTIONS]"; int argc = 2; const char* cmd[] = {prog}; opts.SetCmdLineDescr(customDescr); @@ -601,7 +601,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { TStringStream out; parser.PrintUsage(out); // find custom usage - UNIT_ASSERT(out.Str().find(customDescr) != TString::npos); + UNIT_ASSERT(out.Str().find(customDescr) != TString::npos); } Y_UNIT_TEST(TestColorPrint) { @@ -622,28 +622,28 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { parser.PrintUsage(out, colors); // find options and green color - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--long_option" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--other" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-o" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-d" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-s" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--long_option" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--other" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-o" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-d" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-s" << colors.OldColor()) != TString::npos); // find default values - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "42" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "\"str_default\"" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "42" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "\"str_default\"" << colors.OldColor()) != TString::npos); // find free args - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "123" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "456" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "first_free_arg" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "123" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "456" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "first_free_arg" << colors.OldColor()) != TString::npos); // free args without help not rendered even if they have custom title UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "second_free_arg" << colors.OldColor()) == TString::npos); // find signatures - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Usage" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Required parameters" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Optional parameters" << colors.OldColor()) != TString::npos); - UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Free args" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Usage" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Required parameters" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Optional parameters" << colors.OldColor()) != TString::npos); + UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Free args" << colors.OldColor()) != TString::npos); // find sections UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Section" << colors.OldColor() << ":") != TString::npos); @@ -652,10 +652,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { // print without colors TStringStream out2; opts.PrintUsage(prog, out2); - UNIT_ASSERT(out2.Str().find(colors.GreenColor()) == TString::npos); - UNIT_ASSERT(out2.Str().find(colors.CyanColor()) == TString::npos); - UNIT_ASSERT(out2.Str().find(colors.BoldColor()) == TString::npos); - UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos); + UNIT_ASSERT(out2.Str().find(colors.GreenColor()) == TString::npos); + UNIT_ASSERT(out2.Str().find(colors.CyanColor()) == TString::npos); + UNIT_ASSERT(out2.Str().find(colors.BoldColor()) == TString::npos); + UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos); } Y_UNIT_TEST(TestPadding) { @@ -675,21 +675,21 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { NColorizer::TColors colors(withColors); parser.PrintUsage(out, colors); - TString printed = out.Str(); + TString printed = out.Str(); if (withColors) { // remove not printable characters - SubstGlobal(printed, TString(colors.BoldColor()), ""); - SubstGlobal(printed, TString(colors.GreenColor()), ""); - SubstGlobal(printed, TString(colors.CyanColor()), ""); - SubstGlobal(printed, TString(colors.OldColor()), ""); + SubstGlobal(printed, TString(colors.BoldColor()), ""); + SubstGlobal(printed, TString(colors.GreenColor()), ""); + SubstGlobal(printed, TString(colors.CyanColor()), ""); + SubstGlobal(printed, TString(colors.OldColor()), ""); } - TVector<TString> lines; + TVector<TString> lines; StringSplitter(printed).Split('\n').SkipEmpty().Collect(&lines); UNIT_ASSERT(!lines.empty()); - TVector<size_t> indents; - for (const TString& line : lines) { + TVector<size_t> indents; + for (const TString& line : lines) { const size_t indent = line.find("description "); - if (indent != TString::npos) + if (indent != TString::npos) indents.push_back(indent); } UNIT_ASSERT_VALUES_EQUAL(indents.size(), 7); @@ -701,7 +701,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } Y_UNIT_TEST(TestAppendTo) { - TVector<int> ints; + TVector<int> ints; TOptsNoDefault opts; opts.AddLongOption("size").AppendTo(&ints); diff --git a/library/cpp/getopt/ut/opt_ut.cpp b/library/cpp/getopt/ut/opt_ut.cpp index 441aa493a0..aad842a46e 100644 --- a/library/cpp/getopt/ut/opt_ut.cpp +++ b/library/cpp/getopt/ut/opt_ut.cpp @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(OptTest) { int argc = 5; Opt opts(argc, argv, "", options); - UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3"); + UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3"); } Y_UNIT_TEST(TestLongOption) { @@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(OptTest) { int argc = 5; Opt opts(argc, argv, "", options); - TString optionValue = ""; + TString optionValue = ""; int optlet = 0; while ((optlet = opts.Get()) != EOF) { if (optlet == SOME_OPTION_ID) { diff --git a/library/cpp/getopt/ut/posix_getopt_ut.cpp b/library/cpp/getopt/ut/posix_getopt_ut.cpp index b6d374bf28..7a9dbf6c5c 100644 --- a/library/cpp/getopt/ut/posix_getopt_ut.cpp +++ b/library/cpp/getopt/ut/posix_getopt_ut.cpp @@ -13,9 +13,9 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) { NLastGetopt::optreset = 1; UNIT_ASSERT_VALUES_EQUAL('b', NLastGetopt::getopt(argc, argv, "bf:")); UNIT_ASSERT_VALUES_EQUAL('f', NLastGetopt::getopt(argc, argv, "bf:")); - UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("1")); + UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("1")); UNIT_ASSERT_VALUES_EQUAL('f', NLastGetopt::getopt(argc, argv, "bf:")); - UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("2")); + UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("2")); UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt(argc, argv, "bf:")); UNIT_ASSERT_VALUES_EQUAL(5, NLastGetopt::optind); diff --git a/library/cpp/getopt/ut/ygetopt_ut.cpp b/library/cpp/getopt/ut/ygetopt_ut.cpp index a76f117216..29cfb0e8e3 100644 --- a/library/cpp/getopt/ut/ygetopt_ut.cpp +++ b/library/cpp/getopt/ut/ygetopt_ut.cpp @@ -29,8 +29,8 @@ void TGetOptTest::TestGetOpt() { "-q", nullptr}; - TString res; - const TString format = "qzp:f"; + TString res; + const TString format = "qzp:f"; TGetOpt opt(sizeof(argv) / sizeof(*argv) - 1, argv, format); for (TGetOpt::TIterator it = opt.Begin(); it != opt.End(); ++it) { diff --git a/library/cpp/grpc/server/grpc_server.h b/library/cpp/grpc/server/grpc_server.h index d6814a90a0..e78eefee5e 100644 --- a/library/cpp/grpc/server/grpc_server.h +++ b/library/cpp/grpc/server/grpc_server.h @@ -347,9 +347,9 @@ private: const TServerOptions Options_; std::unique_ptr<grpc::Server> Server_; std::vector<std::unique_ptr<grpc::ServerCompletionQueue>> CQS_; - TVector<IThreadRef> Ts; + TVector<IThreadRef> Ts; - TVector<IGRpcServicePtr> Services_; + TVector<IGRpcServicePtr> Services_; TGlobalLimiter Limiter_; }; diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.cpp b/library/cpp/histogram/adaptive/adaptive_histogram.cpp index cbfc494021..57dec4d608 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.cpp +++ b/library/cpp/histogram/adaptive/adaptive_histogram.cpp @@ -113,15 +113,15 @@ namespace NKiwiAggr { } } - void TAdaptiveHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { + void TAdaptiveHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { for (size_t i = 0; i < histogramsToMerge.size(); ++i) { Merge(histogramsToMerge[i], 1.0); } } - void TAdaptiveHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { - TVector<IHistogramPtr> histogramsToMergeRepacked(0); - TVector<TAdaptiveHistogram*> histograms(0); + void TAdaptiveHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { + TVector<IHistogramPtr> histogramsToMergeRepacked(0); + TVector<TAdaptiveHistogram*> histograms(0); for (size_t i = 0; i < histogramsToMerge.size(); ++i) { if (!histogramsToMerge[i] || histogramsToMerge[i]->Empty()) { continue; diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h index fa8f48433f..3bb921e780 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.h +++ b/library/cpp/histogram/adaptive/adaptive_histogram.h @@ -15,7 +15,7 @@ namespace NKiwiAggr { static const size_t DEFAULT_INTERVALS = 100; private: - using TPairSet = TSet<TWeightedValue>; + using TPairSet = TSet<TWeightedValue>; struct TFastBin { // these names are for compatibility with TWeightedValue @@ -47,7 +47,7 @@ namespace NKiwiAggr { TPairSet BinsByQuality; TQualityFunction CalcQuality; - TVector<TFastBin> PrecomputedBins; + TVector<TFastBin> PrecomputedBins; public: TAdaptiveHistogram(size_t intervals, ui64 id = 0, TQualityFunction qualityFunc = CalcWeightQuality); diff --git a/library/cpp/histogram/adaptive/auto_histogram.h b/library/cpp/histogram/adaptive/auto_histogram.h index 9fdf0b9abe..21efc5cd3a 100644 --- a/library/cpp/histogram/adaptive/auto_histogram.h +++ b/library/cpp/histogram/adaptive/auto_histogram.h @@ -58,11 +58,11 @@ namespace NKiwiAggr { HistogramImpl->Merge(histo, multiplier); } - virtual void Merge(const TVector<THistogram>& histogramsToMerge) { + virtual void Merge(const TVector<THistogram>& histogramsToMerge) { HistogramImpl->Merge(histogramsToMerge); } - virtual void Merge(TVector<IHistogramPtr> histogramsToMerge) { + virtual void Merge(TVector<IHistogramPtr> histogramsToMerge) { HistogramImpl->Merge(histogramsToMerge); } diff --git a/library/cpp/histogram/adaptive/block_histogram.cpp b/library/cpp/histogram/adaptive/block_histogram.cpp index 6586d13ff6..51e418405b 100644 --- a/library/cpp/histogram/adaptive/block_histogram.cpp +++ b/library/cpp/histogram/adaptive/block_histogram.cpp @@ -16,12 +16,12 @@ namespace { class TSmartHeap { private: - TVector<ui32> A; - TVector<ui32> Pos; - const TVector<double>& Weights; + TVector<ui32> A; + TVector<ui32> Pos; + const TVector<double>& Weights; public: - TSmartHeap(const TVector<double>& weights) + TSmartHeap(const TVector<double>& weights) : A(weights.size()) , Pos(weights.size()) , Weights(weights) @@ -182,7 +182,7 @@ namespace NKiwiAggr { } } - void TBlockHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { + void TBlockHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { for (size_t i = 0; i < histogramsToMerge.size(); ++i) { Merge(histogramsToMerge[i], 1.0); } @@ -190,7 +190,7 @@ namespace NKiwiAggr { void TBlockHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { Y_UNUSED(histogramsToMerge); - ythrow yexception() << "IHistogram::Merge(TVector<IHistogramPtr>) is not defined for TBlockHistogram"; + ythrow yexception() << "IHistogram::Merge(TVector<IHistogramPtr>) is not defined for TBlockHistogram"; } void TBlockHistogram::Multiply(double factor) { @@ -198,7 +198,7 @@ namespace NKiwiAggr { ythrow yexception() << "Not valid factor in IHistogram::Multiply(): " << factor; } Sum *= factor; - for (TVector<TWeightedValue>::iterator it = Bins.begin(); it != Bins.end(); ++it) { + for (TVector<TWeightedValue>::iterator it = Bins.begin(); it != Bins.end(); ++it) { it->second *= factor; } } @@ -255,7 +255,7 @@ namespace NKiwiAggr { SortAndShrink(Intervals, true); histo.SetMinValue(MinValue); histo.SetMaxValue(MaxValue); - for (TVector<TWeightedValue>::const_iterator it = Bins.begin(); it != Bins.end(); ++it) { + for (TVector<TWeightedValue>::const_iterator it = Bins.begin(); it != Bins.end(); ++it) { histo.AddFreq(it->second); histo.AddPosition(it->first); } @@ -311,7 +311,7 @@ namespace NKiwiAggr { void TBlockHistogram::SortBins() { Sort(Bins.begin() + PrevSize, Bins.end()); if (PrevSize != 0) { - TVector<TWeightedValue> temp(Bins.begin(), Bins.begin() + PrevSize); + TVector<TWeightedValue> temp(Bins.begin(), Bins.begin() + PrevSize); std::merge(temp.begin(), temp.end(), Bins.begin() + PrevSize, Bins.end(), Bins.begin()); } } @@ -367,7 +367,7 @@ namespace NKiwiAggr { bins[i].LinkAfter(&bins[i - 1]); } - TVector<double> pairWeights(n); + TVector<double> pairWeights(n); for (ui32 i = 0; i < n; ++i) { pairWeights[i] = CalcQuality(Bins[i], Bins[i + 1]).first; @@ -548,12 +548,12 @@ namespace NKiwiAggr { cumulatives.push_back(cumulative); } - TVector<TCumulatives::const_iterator> splits; + TVector<TCumulatives::const_iterator> splits; splits.reserve(intervals + 1); splits.push_back(cumulatives.begin()); splits.push_back(cumulatives.end() - 1); - TPriorityQueue<TSplitInfo> candidates; + TPriorityQueue<TSplitInfo> candidates; // explicitly add first split TSplitInfo newSplitInfo; diff --git a/library/cpp/histogram/adaptive/block_histogram.h b/library/cpp/histogram/adaptive/block_histogram.h index 266bb2f2b2..ba1d26f274 100644 --- a/library/cpp/histogram/adaptive/block_histogram.h +++ b/library/cpp/histogram/adaptive/block_histogram.h @@ -45,7 +45,7 @@ namespace NKiwiAggr { double MinValue; double MaxValue; - TVector<TWeightedValue> Bins; + TVector<TWeightedValue> Bins; public: TBlockHistogram(EHistogramType type, TQualityFunction calcQuality, @@ -60,7 +60,7 @@ namespace NKiwiAggr { virtual void Add(const THistoRec& histoRec); virtual void Merge(const THistogram& histo, double multiplier); - virtual void Merge(const TVector<THistogram>& histogramsToMerge); + virtual void Merge(const TVector<THistogram>& histogramsToMerge); virtual void Merge(TVector<IHistogramPtr> histogramsToMerge); // not implemented virtual void Multiply(double factor); @@ -123,7 +123,7 @@ namespace NKiwiAggr { private: using TCumulative = std::pair<double, double>; // cumulative sum of (weights, weighted centers) - using TCumulatives = TVector<TCumulative>; + using TCumulatives = TVector<TCumulative>; struct TSplitInfo { double profit; diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp index 558aba9e2d..903b076a30 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.cpp @@ -102,7 +102,7 @@ namespace NKiwiAggr { if (!IsInitialized) { if (!TrainingSet) { - TrainingSet.Reset(new TVector<TWeightedValue>(0)); + TrainingSet.Reset(new TVector<TWeightedValue>(0)); } TrainingSet->push_back(TWeightedValue(value, weight)); if (TrainingSet->size() >= TrainingSetSize) { @@ -128,17 +128,17 @@ namespace NKiwiAggr { ythrow yexception() << "Method is not implemented for TFixedBinHistogram"; } - void TFixedBinHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { - TVector<IHistogramPtr> parsedHistogramsToMerge; + void TFixedBinHistogram::Merge(const TVector<THistogram>& histogramsToMerge) { + TVector<IHistogramPtr> parsedHistogramsToMerge; for (size_t i = 0; i < histogramsToMerge.size(); ++i) { parsedHistogramsToMerge.push_back(IHistogramPtr(new TAutoHistogram(histogramsToMerge[i], Intervals, Id))); } Merge(parsedHistogramsToMerge); } - void TFixedBinHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { - TVector<IHistogramPtr> histogramsToMergeRepacked(0); - TVector<TFixedBinHistogram*> histograms(0); + void TFixedBinHistogram::Merge(TVector<IHistogramPtr> histogramsToMerge) { + TVector<IHistogramPtr> histogramsToMergeRepacked(0); + TVector<TFixedBinHistogram*> histograms(0); // put current histogram to the vector of histograms to merge and clear self if (!Empty()) { @@ -485,7 +485,7 @@ namespace NKiwiAggr { } SetFrame(MinElement(TrainingSet->begin(), TrainingSet->end(), CompareWeightedValue)->first, MaxElement(TrainingSet->begin(), TrainingSet->end(), CompareWeightedValue)->first, true); - for (TVector<TWeightedValue>::const_iterator it = TrainingSet->begin(); it != TrainingSet->end(); ++it) { + for (TVector<TWeightedValue>::const_iterator it = TrainingSet->begin(); it != TrainingSet->end(); ++it) { Freqs[CalcBin(it->first)] += it->second; } TrainingSet.Destroy(); diff --git a/library/cpp/histogram/adaptive/fixed_bin_histogram.h b/library/cpp/histogram/adaptive/fixed_bin_histogram.h index bd380bd94a..05ae0db428 100644 --- a/library/cpp/histogram/adaptive/fixed_bin_histogram.h +++ b/library/cpp/histogram/adaptive/fixed_bin_histogram.h @@ -26,8 +26,8 @@ namespace NKiwiAggr { double MaxValue; double Sum; - TVector<double> Freqs; - TVector<double> ReserveFreqs; + TVector<double> Freqs; + TVector<double> ReserveFreqs; double ReferencePoint; double BinRange; size_t Intervals; @@ -49,8 +49,8 @@ namespace NKiwiAggr { virtual void Add(const THistoRec& histoRec); virtual void Merge(const THistogram& histo, double multiplier); - virtual void Merge(const TVector<THistogram>& histogramsToMerge); - virtual void Merge(TVector<IHistogramPtr> histogramsToMerge); + virtual void Merge(const TVector<THistogram>& histogramsToMerge); + virtual void Merge(TVector<IHistogramPtr> histogramsToMerge); virtual void Multiply(double factor); diff --git a/library/cpp/histogram/adaptive/histogram.h b/library/cpp/histogram/adaptive/histogram.h index 360fd9a693..e6b11870e1 100644 --- a/library/cpp/histogram/adaptive/histogram.h +++ b/library/cpp/histogram/adaptive/histogram.h @@ -29,8 +29,8 @@ namespace NKiwiAggr { // Merge some other histos into current virtual void Merge(const THistogram& histo, double multiplier) = 0; - virtual void Merge(const TVector<THistogram>& histogramsToMerge) = 0; - virtual void Merge(TVector<IHistogramPtr> histogramsToMerge) = 0; + virtual void Merge(const TVector<THistogram>& histogramsToMerge) = 0; + virtual void Merge(TVector<IHistogramPtr> histogramsToMerge) = 0; // factor should be greater then zero virtual void Multiply(double factor) = 0; diff --git a/library/cpp/histogram/adaptive/multi_histogram.h b/library/cpp/histogram/adaptive/multi_histogram.h index 41caac5ba6..5a18999edc 100644 --- a/library/cpp/histogram/adaptive/multi_histogram.h +++ b/library/cpp/histogram/adaptive/multi_histogram.h @@ -15,7 +15,7 @@ namespace NKiwiAggr { private: static const size_t DEFAULT_INTERVALS = 100; - typedef THashMap<ui64, IHistogramPtr> THistogramsMap; + typedef THashMap<ui64, IHistogramPtr> THistogramsMap; THistogramsMap Histograms; size_t Intervals; @@ -62,8 +62,8 @@ namespace NKiwiAggr { } } - TVector<ui64> GetIds() const { - TVector<ui64> result(0); + TVector<ui64> GetIds() const { + TVector<ui64> result(0); for (THistogramsMap::const_iterator it = Histograms.begin(); it != Histograms.end(); ++it) { result.push_back(it->first); } diff --git a/library/cpp/html/escape/escape.h b/library/cpp/html/escape/escape.h index 1c45fc5193..6fc9fb4f1b 100644 --- a/library/cpp/html/escape/escape.h +++ b/library/cpp/html/escape/escape.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> namespace NHtml { TString EscapeAttributeValue(const TString& value); diff --git a/library/cpp/html/pcdata/pcdata.cpp b/library/cpp/html/pcdata/pcdata.cpp index 740c240fd2..70fe073bb9 100644 --- a/library/cpp/html/pcdata/pcdata.cpp +++ b/library/cpp/html/pcdata/pcdata.cpp @@ -1,10 +1,10 @@ #include "pcdata.h" -#include <util/string/strspn.h> - +#include <util/string/strspn.h> + static TCompactStrSpn sspn("\"<>&'"); -static void EncodeHtmlPcdataAppendInternal(const TStringBuf str, TString& strout, bool qAmp) { +static void EncodeHtmlPcdataAppendInternal(const TStringBuf str, TString& strout, bool qAmp) { const char* s = str.data(); const char* e = s + str.length(); @@ -49,18 +49,18 @@ static void EncodeHtmlPcdataAppendInternal(const TStringBuf str, TString& strout } } -void EncodeHtmlPcdataAppend(const TStringBuf str, TString& strout) { +void EncodeHtmlPcdataAppend(const TStringBuf str, TString& strout) { EncodeHtmlPcdataAppendInternal(str, strout, true); } -TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp) { - TString strout; +TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp) { + TString strout; EncodeHtmlPcdataAppendInternal(str, strout, qAmp); return strout; } -TString DecodeHtmlPcdata(const TString& sz) { - TString res; +TString DecodeHtmlPcdata(const TString& sz) { + TString res; const char* codes[] = {""", "<", ">", "'", "'", "&", "'", nullptr}; const char chars[] = {'\"', '<', '>', '\'', '\'', '&', '\''}; for (size_t i = 0; i < sz.length(); ++i) { diff --git a/library/cpp/html/pcdata/pcdata.h b/library/cpp/html/pcdata/pcdata.h index 7dd741f53d..c1de2d0a31 100644 --- a/library/cpp/html/pcdata/pcdata.h +++ b/library/cpp/html/pcdata/pcdata.h @@ -3,8 +3,8 @@ #include <util/generic/fwd.h> /// Converts a text into HTML-code. Special characters of HTML («<», «>», ...) replaced with entities. -TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp = true); -void EncodeHtmlPcdataAppend(const TStringBuf str, TString& strout); +TString EncodeHtmlPcdata(const TStringBuf str, bool qAmp = true); +void EncodeHtmlPcdataAppend(const TStringBuf str, TString& strout); /// Reverse of EncodeHtmlPcdata() -TString DecodeHtmlPcdata(const TString& sz); +TString DecodeHtmlPcdata(const TString& sz); diff --git a/library/cpp/html/pcdata/pcdata_ut.cpp b/library/cpp/html/pcdata/pcdata_ut.cpp index 5833f8bc59..6710d9dfce 100644 --- a/library/cpp/html/pcdata/pcdata_ut.cpp +++ b/library/cpp/html/pcdata/pcdata_ut.cpp @@ -6,18 +6,18 @@ Y_UNIT_TEST_SUITE(TPcdata) { Y_UNIT_TEST(TestStress) { { ui64 key = 0x000017C0B76C4E87ull; - TString res = EncodeHtmlPcdata(TStringBuf((const char*)&key, sizeof(key))); + TString res = EncodeHtmlPcdata(TStringBuf((const char*)&key, sizeof(key))); } for (size_t i = 0; i < 1000; ++i) { - const TString s = NUnitTest::RandomString(i, i); + const TString s = NUnitTest::RandomString(i, i); UNIT_ASSERT_VALUES_EQUAL(DecodeHtmlPcdata(EncodeHtmlPcdata(s)), s); } } Y_UNIT_TEST(Test1) { - const TString tests[] = { + const TString tests[] = { "qw&qw", "&<", ">&qw", @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TPcdata) { } Y_UNIT_TEST(TestEncodeHtmlPcdataAppend) { - TString s; + TString s; EncodeHtmlPcdataAppend("m&m", s); EncodeHtmlPcdataAppend("'s", s); UNIT_ASSERT_VALUES_EQUAL(EncodeHtmlPcdata("m&m's"), s); diff --git a/library/cpp/html/pcdata/ut/ya.make b/library/cpp/html/pcdata/ut/ya.make index bc947baa89..ad9f9abe47 100644 --- a/library/cpp/html/pcdata/ut/ya.make +++ b/library/cpp/html/pcdata/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/html/pcdata) - -OWNER(vladon) - -SRCS( - pcdata_ut.cpp -) - -END() + +OWNER(vladon) + +SRCS( + pcdata_ut.cpp +) + +END() diff --git a/library/cpp/html/pcdata/ya.make b/library/cpp/html/pcdata/ya.make index 637220e706..957fd964c2 100644 --- a/library/cpp/html/pcdata/ya.make +++ b/library/cpp/html/pcdata/ya.make @@ -1,10 +1,10 @@ -LIBRARY() - -OWNER(vladon) - -SRCS( - pcdata.cpp - pcdata.h -) - -END() +LIBRARY() + +OWNER(vladon) + +SRCS( + pcdata.cpp + pcdata.h +) + +END() diff --git a/library/cpp/http/fetch/exthttpcodes.cpp b/library/cpp/http/fetch/exthttpcodes.cpp index acc05650c8..9c9fbc86b9 100644 --- a/library/cpp/http/fetch/exthttpcodes.cpp +++ b/library/cpp/http/fetch/exthttpcodes.cpp @@ -172,7 +172,7 @@ static ui16* prepare_flags(http_flag* arg) { ui16* http2status = prepare_flags(HTTP_FLAG); -TStringBuf ExtHttpCodeStr(int code) noexcept { +TStringBuf ExtHttpCodeStr(int code) noexcept { if (code < HTTP_CODE_MAX) { return HttpCodeStr(code); } diff --git a/library/cpp/http/fetch/exthttpcodes.h b/library/cpp/http/fetch/exthttpcodes.h index 6b525052cd..e5f8c42295 100644 --- a/library/cpp/http/fetch/exthttpcodes.h +++ b/library/cpp/http/fetch/exthttpcodes.h @@ -138,4 +138,4 @@ static inline int Http2Status(int code) { return http2status[code & (EXT_HTTP_CODE_MAX - 1)]; } -TStringBuf ExtHttpCodeStr(int code) noexcept; +TStringBuf ExtHttpCodeStr(int code) noexcept; diff --git a/library/cpp/http/fetch/http_digest.cpp b/library/cpp/http/fetch/http_digest.cpp index 1eaa02b7f2..4955ada67c 100644 --- a/library/cpp/http/fetch/http_digest.cpp +++ b/library/cpp/http/fetch/http_digest.cpp @@ -196,7 +196,7 @@ bool httpDigestHandler::processHeader(const THttpAuthHeader* header, out << ", opaque=\"" << header->opaque << "\""; out << "\r\n"; - TString s_out = out.Str(); + TString s_out = out.Str(); HeaderInstruction_ = strdup(s_out.c_str()); return true; diff --git a/library/cpp/http/fetch/httpfsm.rl6 b/library/cpp/http/fetch/httpfsm.rl6 index eab0328b18..d0e8aab8fe 100644 --- a/library/cpp/http/fetch/httpfsm.rl6 +++ b/library/cpp/http/fetch/httpfsm.rl6 @@ -312,8 +312,8 @@ rel_canonical = "link"i def '<' url ">;"i lws "rel"i lws '=' lws "\"canonical\"" ################# hreflang ############### action set_hreflang { bool first = (hreflangpos == hd->hreflangs); - size_t len2 = (first ? 0 : 1) + langlen + 1 + buflen; - if (langlen && len2 < hreflangspace) { + size_t len2 = (first ? 0 : 1) + langlen + 1 + buflen; + if (langlen && len2 < hreflangspace) { if (!first) { *(hreflangpos++) = '\t'; } @@ -323,7 +323,7 @@ action set_hreflang { memcpy(hreflangpos, buf, buflen); hreflangpos += buflen; *(hreflangpos) = 0; - hreflangspace -= len2; + hreflangspace -= len2; } } diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index b018e80101..3545b25cb6 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -107,7 +107,7 @@ void THttpHeaderParserTestSuite::TestSplitRequestHeader() { for (size_t n1 = 0; n1 < rlen; n1++) { for (size_t n2 = n1; n2 < rlen; n2++) { - TString s1{request, 0, n1}; + TString s1{request, 0, n1}; TString s2{request, n1, n2 - n1}; TString s3{request, n2, rlen - n2}; UNIT_ASSERT_EQUAL(s1 + s2 + s3, request); @@ -144,7 +144,7 @@ void THttpHeaderParserTestSuite::TestTrailingData() { UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0); UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi"); - UNIT_ASSERT_EQUAL(TString(httpHeaderParser->lastchar + 1), "high.ru"); + UNIT_ASSERT_EQUAL(TString(httpHeaderParser->lastchar + 1), "high.ru"); UNIT_ASSERT_EQUAL(httpRequestHeader.http_minor, 1); UNIT_ASSERT_EQUAL(httpRequestHeader.transfer_chunked, -1); UNIT_ASSERT_EQUAL(httpRequestHeader.content_length, -1); @@ -495,20 +495,20 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { return parser; } - static THttpChunkParser parseByteByByte(const TStringBuf& blob, const TVector<int>& states) { + static THttpChunkParser parseByteByByte(const TStringBuf& blob, const TVector<int>& states) { UNIT_ASSERT(states.size() <= blob.size()); THttpChunkParser parser{initParser()}; for (size_t n = 0; n < states.size(); n++) { const TStringBuf d{blob, n, 1}; int code = parser.Execute(d.data(), d.size()); - Cout << TString(d).Quote() << " " << code << Endl; + Cout << TString(d).Quote() << " " << code << Endl; UNIT_ASSERT_EQUAL(code, states[n]); } return parser; } static THttpChunkParser parseBytesWithLastState(const TStringBuf& blob, const int last_state) { - TVector<int> states(blob.size() - 1, 1); + TVector<int> states(blob.size() - 1, 1); states.push_back(last_state); return parseByteByByte(blob, states); } @@ -517,7 +517,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { const TStringBuf blob{ "4\r\n" "____\r\n"}; - TVector<int> states{ + TVector<int> states{ -1, /* 1, -1, 1, -1, 1, -1, 1, -1 */}; // as soon as error happens parser state should be considered @@ -540,7 +540,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { const TStringBuf blob{ "\r\n" "-1"}; - TVector<int> states{ + TVector<int> states{ 1, 1, -1, /* 1 */}; @@ -570,7 +570,7 @@ Y_UNIT_TEST_SUITE(TestHttpChunkParser) { "4\r\n" "_" // first byte of the chunk }; - TVector<int> states{ + TVector<int> states{ 1, 1, 1, 1, 2, -1}; diff --git a/library/cpp/http/fetch/httpheader.h b/library/cpp/http/fetch/httpheader.h index b2810bbd41..071ce6fe8d 100644 --- a/library/cpp/http/fetch/httpheader.h +++ b/library/cpp/http/fetch/httpheader.h @@ -6,7 +6,7 @@ #include <util/system/defaults.h> #include <util/system/compat.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ylimits.h> #include <util/system/maxlen.h> @@ -217,8 +217,8 @@ public: /// It doesn't care about errors in request or headers, where /// request_uri equals to '*'. /// This returns copy of the string, which you have to delete. - TString GetUrl() { - TString url; + TString GetUrl() { + TString url; if (host[0] == 0 || !strcmp(host, "")) { url = request_uri; } else { diff --git a/library/cpp/http/fetch/httpload.cpp b/library/cpp/http/fetch/httpload.cpp index 82ea8900b5..e96ec13a80 100644 --- a/library/cpp/http/fetch/httpload.cpp +++ b/library/cpp/http/fetch/httpload.cpp @@ -336,7 +336,7 @@ bool httpLoadAgent::doStartRequest() { return false; } - TString urlBaseStr = URL_.PrintS(THttpURL::FlagNoFrag); + TString urlBaseStr = URL_.PrintS(THttpURL::FlagNoFrag); clearReader(); Reader_ = new httpAgentReader(*this, urlBaseStr.c_str(), diff --git a/library/cpp/http/fetch/httpparser_ut.cpp b/library/cpp/http/fetch/httpparser_ut.cpp index 3b3b938e7a..1ccc667bb4 100644 --- a/library/cpp/http/fetch/httpparser_ut.cpp +++ b/library/cpp/http/fetch/httpparser_ut.cpp @@ -48,7 +48,7 @@ namespace { Y_UNIT_TEST_SUITE(TestHttpParser) { Y_UNIT_TEST(TestTrivialRequest) { - const TString blob{ + const TString blob{ "GET /search?q=hi HTTP/1.1\r\n" "Host: www.google.ru:8080 \r\n" "\r\n"}; @@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { // XXX: `entity_size` is i32 and `content_length` is i64! Y_UNIT_TEST(TestTrivialResponse) { - const TString blob{ + const TString blob{ "HTTP/1.1 200 Ok\r\n" "Content-Length: 2\r\n" "\r\n" @@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { // XXX: `entity_size` is off by one in TE:chunked case. Y_UNIT_TEST(TestChunkedResponse) { - const TString blob{ + const TString blob{ "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" "\r\n" @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "\r\n")); } - static const TString PipelineClenBlob_{ + static const TString PipelineClenBlob_{ "HTTP/1.1 200 Ok\r\n" "Content-Length: 4\r\n" "\r\n" @@ -131,14 +131,14 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } Y_UNIT_TEST(TestPipelineClenByteByByte) { - const TString& blob = PipelineClenBlob_; + const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; parser.Init(&hdr); for (size_t i = 0; i < blob.size(); ++i) { const TStringBuf d{blob, i, 1}; parser.Parse((void*)d.data(), d.size()); - Cout << TString(d).Quote() << " -> " << parser.GetState() << Endl; + Cout << TString(d).Quote() << " -> " << parser.GetState() << Endl; } AssertPipelineClen(parser, hdr); UNIT_ASSERT_EQUAL(parser.Body(), "OK\r\n"); @@ -147,7 +147,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { // XXX: Content-Length is ignored, Body() looks unexpected! Y_UNIT_TEST(TestPipelineClenOneChunk) { - const TString& blob = PipelineClenBlob_; + const TString& blob = PipelineClenBlob_; THttpHeader hdr; TTestHttpParser parser; parser.Init(&hdr); @@ -167,7 +167,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { "ZZ\r\n")); } - static const TString PipelineChunkedBlob_{ + static const TString PipelineChunkedBlob_{ "HTTP/1.1 200 OK\r\n" "Transfer-Encoding: chunked\r\n" "\r\n" @@ -206,14 +206,14 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } Y_UNIT_TEST(TestPipelineChunkedByteByByte) { - const TString& blob = PipelineChunkedBlob_; + const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; parser.Init(&hdr); for (size_t i = 0; i < blob.size(); ++i) { const TStringBuf d{blob, i, 1}; parser.Parse((void*)d.data(), d.size()); - Cout << TString(d).Quote() << " -> " << parser.GetState() << Endl; + Cout << TString(d).Quote() << " -> " << parser.GetState() << Endl; if (blob.size() / 2 - 1 <= i) // last \n sets EOF UNIT_ASSERT_EQUAL(parser.GetState(), parser.hp_eof); } @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(TestHttpParser) { } Y_UNIT_TEST(TestPipelineChunkedOneChunk) { - const TString& blob = PipelineChunkedBlob_; + const TString& blob = PipelineChunkedBlob_; THttpHeader hdr; TTestHttpParser parser; parser.Init(&hdr); diff --git a/library/cpp/http/io/chunk.cpp b/library/cpp/http/io/chunk.cpp index 6975d9eac1..181a6cec11 100644 --- a/library/cpp/http/io/chunk.cpp +++ b/library/cpp/http/io/chunk.cpp @@ -6,14 +6,14 @@ #include <util/generic/utility.h> #include <util/generic/yexception.h> -static inline size_t ParseHex(const TString& s) { +static inline size_t ParseHex(const TString& s) { if (s.empty()) { ythrow yexception() << "can not parse chunk length(empty string)"; } size_t ret = 0; - for (TString::const_iterator c = s.begin(); c != s.end(); ++c) { + for (TString::const_iterator c = s.begin(); c != s.end(); ++c) { const char ch = *c; if (ch >= '0' && ch <= '9') { @@ -61,7 +61,7 @@ public: } } - inline ~TImpl() { + inline ~TImpl() { } inline size_t Read(void* buf, size_t len) { @@ -111,7 +111,7 @@ private: } inline bool ProceedToNextChunk() { - TString len(Slave_->ReadLine()); + TString len(Slave_->ReadLine()); if (len.empty()) { /* @@ -147,7 +147,7 @@ TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers { } -TChunkedInput::~TChunkedInput() { +TChunkedInput::~TChunkedInput() { } size_t TChunkedInput::DoRead(void* buf, size_t len) { @@ -167,7 +167,7 @@ public: { } - inline ~TImpl() { + inline ~TImpl() { } inline void Write(const void* buf, size_t len) { @@ -217,7 +217,7 @@ TChunkedOutput::TChunkedOutput(IOutputStream* slave) { } -TChunkedOutput::~TChunkedOutput() { +TChunkedOutput::~TChunkedOutput() { try { Finish(); } catch (...) { diff --git a/library/cpp/http/io/chunk.h b/library/cpp/http/io/chunk.h index 88d89fafda..d73cbf1523 100644 --- a/library/cpp/http/io/chunk.h +++ b/library/cpp/http/io/chunk.h @@ -16,7 +16,7 @@ public: /// Если передан указатель на trailers, то туда будут записаны HTTP trailer'ы (возможно пустые), /// которые идут после чанков. TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr); - ~TChunkedInput() override; + ~TChunkedInput() override; private: size_t DoRead(void* buf, size_t len) override; @@ -33,7 +33,7 @@ private: class TChunkedOutput: public IOutputStream { public: TChunkedOutput(IOutputStream* slave); - ~TChunkedOutput() override; + ~TChunkedOutput() override; private: void DoWrite(const void* buf, size_t len) override; diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp index da283f8568..2fb65a92f5 100644 --- a/library/cpp/http/io/chunk_ut.cpp +++ b/library/cpp/http/io/chunk_ut.cpp @@ -11,8 +11,8 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s"; - TString CombString(const TString& s, size_t chunkSize) { - TString result; + TString CombString(const TString& s, size_t chunkSize) { + TString result; for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize) result += s.substr(pos, chunkSize); return result; @@ -59,18 +59,18 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { Y_UNIT_TEST(TestChunkedIo) { TTempFile tmpFile(CDATA); - TString tmp; + TString tmp; { - TUnbufferedFileOutput fo(CDATA); + TUnbufferedFileOutput fo(CDATA); TChunkedOutput co(&fo); WriteTestData(&co, &tmp); } { - TUnbufferedFileInput fi(CDATA); + TUnbufferedFileInput fi(CDATA); TChunkedInput ci(&fi); - TString r; + TString r; ReadInSmallChunks(&ci, &r); @@ -78,9 +78,9 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { } { - TUnbufferedFileInput fi(CDATA); + TUnbufferedFileInput fi(CDATA); TChunkedInput ci(&fi); - TString r; + TString r; ReadCombed(&ci, &r, 11); @@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) { bool hasError = false; try { - TString badChunk = "10\r\nqwerty"; + TString badChunk = "10\r\nqwerty"; TMemoryInput mi(badChunk.data(), badChunk.size()); TChunkedInput ci(&mi); TransferData(&ci, &Cnull); diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 4ec27a29e8..3647828946 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -8,14 +8,14 @@ #include <util/string/cast.h> #include <util/string/strip.h> -static inline TStringBuf Trim(const char* b, const char* e) noexcept { +static inline TStringBuf Trim(const char* b, const char* e) noexcept { return StripString(TStringBuf(b, e)); } THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); - if (pos == TString::npos) { + if (pos == TString::npos) { ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; } @@ -43,8 +43,8 @@ void THttpInputHeader::OutTo(IOutputStream* stream) const { } THttpHeaders::THttpHeaders(IInputStream* stream) { - TString header; - TString line; + TString header; + TString line; bool rdOk = stream->ReadLine(header); while (rdOk && !header.empty()) { diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h index a71793d1c6..139aab2f81 100644 --- a/library/cpp/http/io/headers.h +++ b/library/cpp/http/io/headers.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/deque.h> #include <util/generic/vector.h> @@ -21,12 +21,12 @@ public: THttpInputHeader(TString name, TString value); /// Возвращает имя параметра. - inline const TString& Name() const noexcept { + inline const TString& Name() const noexcept { return Name_; } /// Возвращает значение параметра. - inline const TString& Value() const noexcept { + inline const TString& Value() const noexcept { return Value_; } @@ -34,13 +34,13 @@ public: void OutTo(IOutputStream* stream) const; /// Возвращает строку "имя параметра: значение". - inline TString ToString() const { + inline TString ToString() const { return Name_ + TStringBuf(": ") + Value_; } private: - TString Name_; - TString Value_; + TString Name_; + TString Value_; }; /// Контейнер для хранения HTTP-заголовков @@ -56,7 +56,7 @@ public: THttpHeaders(IInputStream* stream); /// Стандартный итератор. - inline TConstIterator Begin() const noexcept { + inline TConstIterator Begin() const noexcept { return Headers_.begin(); } inline TConstIterator begin() const noexcept { @@ -64,7 +64,7 @@ public: } /// Стандартный итератор. - inline TConstIterator End() const noexcept { + inline TConstIterator End() const noexcept { return Headers_.end(); } inline TConstIterator end() const noexcept { @@ -72,12 +72,12 @@ public: } /// Возвращает количество заголовков в контейнере. - inline size_t Count() const noexcept { + inline size_t Count() const noexcept { return Headers_.size(); } /// Проверяет, содержит ли контейнер хотя бы один заголовок. - inline bool Empty() const noexcept { + inline bool Empty() const noexcept { return Headers_.empty(); } @@ -114,7 +114,7 @@ public: void OutTo(IOutputStream* stream) const; /// Обменивает наборы заголовков двух контейнеров. - void Swap(THttpHeaders& headers) noexcept { + void Swap(THttpHeaders& headers) noexcept { Headers_.swap(headers.Headers_); } diff --git a/library/cpp/http/io/headers_ut.cpp b/library/cpp/http/io/headers_ut.cpp index 1d23ef8fdc..12c45b3b7f 100644 --- a/library/cpp/http/io/headers_ut.cpp +++ b/library/cpp/http/io/headers_ut.cpp @@ -1,5 +1,5 @@ #include <util/generic/set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <utility> @@ -21,7 +21,7 @@ namespace { public: void Add(TStringBuf name, TStringBuf value) { - Impl.emplace(TString(name), TString(value)); + Impl.emplace(TString(name), TString(value)); } bool operator==(const THeadersExistence& rhs) const { @@ -29,7 +29,7 @@ namespace { } private: - typedef TMultiSet<std::pair<TString, TString>> TImpl; + typedef TMultiSet<std::pair<TString, TString>> TImpl; TImpl Impl; }; } @@ -66,11 +66,11 @@ public: private: static void AddHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) { - headers.AddHeader(THttpInputHeader(TString(name), TString(value))); + headers.AddHeader(THttpInputHeader(TString(name), TString(value))); } static void AddHeaderImpl2Args(THttpHeaders& headers, TStringBuf name, TStringBuf value) { - headers.AddHeader(TString(name), TString(value)); + headers.AddHeader(TString(name), TString(value)); } static void AddOrReplaceHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) { @@ -154,7 +154,7 @@ void THttpHeadersTest::DoTestAddOrReplaceOperation(TAddHeaderFunction addHeader, void THttpHeadersTest::TestAddHeaderTemplateness() { THttpHeaders h1; h1.AddHeader("h1", "v1"); - h1.AddHeader("h2", TString("v2")); + h1.AddHeader("h2", TString("v2")); h1.AddHeader("h3", TStringBuf("v3")); h1.AddHeader("h4", TStringBuf("v4")); diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 6689be684f..25859087c3 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -17,7 +17,7 @@ #include <util/string/cast.h> #include <util/string/strip.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/utility.h> #include <util/generic/hash_set.h> #include <util/generic/yexception.h> @@ -131,7 +131,7 @@ namespace { } class THttpInput::TImpl { - typedef THashSet<TString> TAcceptCodings; + typedef THashSet<TString> TAcceptCodings; public: inline TImpl(IInputStream* slave) @@ -157,7 +157,7 @@ public: return s; } - inline ~TImpl() { + inline ~TImpl() { } inline size_t Read(void* buf, size_t len) { @@ -168,11 +168,11 @@ public: return Perform(len, [this](size_t toSkip) { return Input_->Skip(toSkip); }); } - inline const TString& FirstLine() const noexcept { + inline const TString& FirstLine() const noexcept { return FirstLine_; } - inline const THttpHeaders& Headers() const noexcept { + inline const THttpHeaders& Headers() const noexcept { return Headers_; } @@ -180,15 +180,15 @@ public: return Trailers_; } - inline bool IsKeepAlive() const noexcept { + inline bool IsKeepAlive() const noexcept { return KeepAlive_; } - inline bool AcceptEncoding(const TString& s) const { + inline bool AcceptEncoding(const TString& s) const { return Codings_.find(to_lower(s)) != Codings_.end(); } - inline bool GetContentLength(ui64& value) const noexcept { + inline bool GetContentLength(ui64& value) const noexcept { if (HasContentLength_) { value = ContentLength_; return true; @@ -196,7 +196,7 @@ public: return false; } - inline bool ContentEncoded() const noexcept { + inline bool ContentEncoded() const noexcept { return ContentEncoded_; } @@ -252,7 +252,7 @@ private: }; template <class Functor> - inline void ForEach(TString in, Functor& f) { + inline void ForEach(TString in, Functor& f) { in.to_lower(); const char* b = in.begin(); @@ -287,7 +287,7 @@ private: size_t pos = FirstLine_.rfind(' '); // In HTTP/1.1 Keep-Alive is turned on by default - if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) { + if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) { p.KeepAlive = true; //request } else if (strnicmp(FirstLine_.data(), "HTTP/1.1", 8) == 0) { p.KeepAlive = true; //reply @@ -375,7 +375,7 @@ private: */ IInputStream* Input_; - TString FirstLine_; + TString FirstLine_; THttpHeaders Headers_; TMaybe<THttpHeaders> Trailers_; bool KeepAlive_; @@ -396,7 +396,7 @@ THttpInput::THttpInput(IInputStream* slave) THttpInput::THttpInput(THttpInput&& httpInput) = default; -THttpInput::~THttpInput() { +THttpInput::~THttpInput() { } size_t THttpInput::DoRead(void* buf, size_t len) { @@ -407,7 +407,7 @@ size_t THttpInput::DoSkip(size_t len) { return Impl_->Skip(len); } -const THttpHeaders& THttpInput::Headers() const noexcept { +const THttpHeaders& THttpInput::Headers() const noexcept { return Impl_->Headers(); } @@ -415,15 +415,15 @@ const TMaybe<THttpHeaders>& THttpInput::Trailers() const noexcept { return Impl_->Trailers(); } -const TString& THttpInput::FirstLine() const noexcept { +const TString& THttpInput::FirstLine() const noexcept { return Impl_->FirstLine(); } -bool THttpInput::IsKeepAlive() const noexcept { +bool THttpInput::IsKeepAlive() const noexcept { return Impl_->IsKeepAlive(); } -bool THttpInput::AcceptEncoding(const TString& coding) const { +bool THttpInput::AcceptEncoding(const TString& coding) const { return Impl_->AcceptEncoding(coding); } @@ -440,11 +440,11 @@ TString THttpInput::BestCompressionScheme() const { return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs()); } -bool THttpInput::GetContentLength(ui64& value) const noexcept { +bool THttpInput::GetContentLength(ui64& value) const noexcept { return Impl_->GetContentLength(value); } -bool THttpInput::ContentEncoded() const noexcept { +bool THttpInput::ContentEncoded() const noexcept { return Impl_->ContentEncoded(); } @@ -459,17 +459,17 @@ bool THttpInput::HasExpect100Continue() const noexcept { class THttpOutput::TImpl { class TSizeCalculator: public IOutputStream { public: - inline TSizeCalculator() noexcept { + inline TSizeCalculator() noexcept { } - ~TSizeCalculator() override { + ~TSizeCalculator() override { } void DoWrite(const void* /*buf*/, size_t len) override { Length_ += len; } - inline size_t Length() const noexcept { + inline size_t Length() const noexcept { return Length_; } @@ -509,7 +509,7 @@ public: { } - inline ~TImpl() { + inline ~TImpl() { } inline void SendContinue() { @@ -579,7 +579,7 @@ public: Finished_ = true; } - inline const THttpHeaders& SentHeaders() const noexcept { + inline const THttpHeaders& SentHeaders() const noexcept { return Headers_; } @@ -599,11 +599,11 @@ public: CompressionHeaderEnabled_ = enable; } - inline bool IsCompressionEnabled() const noexcept { + inline bool IsCompressionEnabled() const noexcept { return !ComprSchemas_.empty(); } - inline bool IsKeepAliveEnabled() const noexcept { + inline bool IsKeepAliveEnabled() const noexcept { return KeepAliveEnabled_; } @@ -615,7 +615,7 @@ public: return CompressionHeaderEnabled_; } - inline bool CanBeKeepAlive() const noexcept { + inline bool CanBeKeepAlive() const noexcept { return SupportChunkedTransfer() && IsKeepAliveEnabled() && (Request_ ? Request_->IsKeepAlive() : true); } @@ -628,15 +628,15 @@ public: } private: - static inline bool IsResponse(const TString& s) noexcept { + static inline bool IsResponse(const TString& s) noexcept { return strnicmp(s.data(), "HTTP/", 5) == 0; } - static inline bool IsRequest(const TString& s) noexcept { + static inline bool IsRequest(const TString& s) noexcept { return !IsResponse(s); } - inline bool IsHttpRequest() const noexcept { + inline bool IsHttpRequest() const noexcept { return IsRequest(FirstLine_); } @@ -651,16 +651,16 @@ private: return false; } - inline bool IsHttpResponse() const noexcept { + inline bool IsHttpResponse() const noexcept { return IsResponse(FirstLine_); } - inline bool HasRequestBody() const noexcept { + inline bool HasRequestBody() const noexcept { return strnicmp(FirstLine_.data(), "POST", 4) == 0 || strnicmp(FirstLine_.data(), "PATCH", 5) == 0 || strnicmp(FirstLine_.data(), "PUT", 3) == 0; } - static inline size_t ParseHttpVersion(const TString& s) { + static inline size_t ParseHttpVersion(const TString& s) { if (s.empty()) { ythrow THttpParseException() << "malformed http stream"; } @@ -709,7 +709,7 @@ private: Version_ = parsed_version; } - inline void Process(const TString& s) { + inline void Process(const TString& s) { Y_ASSERT(State_ != HeadersSent); if (State_ == Begin) { @@ -760,7 +760,7 @@ private: } } - inline bool SupportChunkedTransfer() const noexcept { + inline bool SupportChunkedTransfer() const noexcept { return Version_ >= 1100; } @@ -791,8 +791,8 @@ private: } } - inline TString BuildAcceptEncoding() const { - TString ret; + inline TString BuildAcceptEncoding() const { + TString ret; for (const auto& coding : ComprSchemas_) { if (ret) { @@ -813,7 +813,7 @@ private: for (THttpHeaders::TConstIterator h = Headers_.Begin(); h != Headers_.End(); ++h) { const THttpInputHeader& header = *h; - const TString hl = to_lower(header.Name()); + const TString hl = to_lower(header.Name()); if (hl == TStringBuf("connection")) { keepAlive = to_lower(header.Value()) == TStringBuf("keep-alive"); @@ -850,7 +850,7 @@ private: Headers_.AddOrReplaceHeader(hdr); } - inline void RemoveHeader(const TString& hdr) { + inline void RemoveHeader(const TString& hdr) { Headers_.RemoveHeader(hdr); } @@ -859,8 +859,8 @@ private: TState State_; IOutputStream* Output_; TStreams<IOutputStream, 8> Streams_; - TString Line_; - TString FirstLine_; + TString Line_; + TString FirstLine_; THttpHeaders Headers_; THttpInput* Request_; size_t Version_; @@ -886,7 +886,7 @@ THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request) { } -THttpOutput::~THttpOutput() { +THttpOutput::~THttpOutput() { try { Finish(); } catch (...) { @@ -905,7 +905,7 @@ void THttpOutput::DoFinish() { Impl_->Finish(); } -const THttpHeaders& THttpOutput::SentHeaders() const noexcept { +const THttpHeaders& THttpOutput::SentHeaders() const noexcept { return Impl_->SentHeaders(); } @@ -934,7 +934,7 @@ void THttpOutput::EnableCompressionHeader(bool enable) { Impl_->EnableCompressionHeader(enable); } -bool THttpOutput::IsKeepAliveEnabled() const noexcept { +bool THttpOutput::IsKeepAliveEnabled() const noexcept { return Impl_->IsKeepAliveEnabled(); } @@ -942,7 +942,7 @@ bool THttpOutput::IsBodyEncodingEnabled() const noexcept { return Impl_->IsBodyEncodingEnabled(); } -bool THttpOutput::IsCompressionEnabled() const noexcept { +bool THttpOutput::IsCompressionEnabled() const noexcept { return Impl_->IsCompressionEnabled(); } @@ -950,7 +950,7 @@ bool THttpOutput::IsCompressionHeaderEnabled() const noexcept { return Impl_->IsCompressionHeaderEnabled(); } -bool THttpOutput::CanBeKeepAlive() const noexcept { +bool THttpOutput::CanBeKeepAlive() const noexcept { return Impl_->CanBeKeepAlive(); } diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h index 78ca4fc814..1ad69a0329 100644 --- a/library/cpp/http/io/stream.h +++ b/library/cpp/http/io/stream.h @@ -5,7 +5,7 @@ #include <util/stream/output.h> #include <util/generic/maybe.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/yexception.h> #include <util/generic/array_ref.h> @@ -26,13 +26,13 @@ class THttpInput: public IInputStream { public: THttpInput(IInputStream* slave); THttpInput(THttpInput&& httpInput); - ~THttpInput() override; + ~THttpInput() override; /* * parsed http headers */ /// Возвращает контейнер с заголовками ответа HTTP-сервера. - const THttpHeaders& Headers() const noexcept; + const THttpHeaders& Headers() const noexcept; /* * parsed http trailers @@ -49,7 +49,7 @@ public: /// Возвращает первую строку ответа HTTP-сервера. /// @details Первая строка HTTP-сервера - строка состояния, /// содержащая три поля: версию HTTP, код состояния и описание. - const TString& FirstLine() const noexcept; + const TString& FirstLine() const noexcept; /* * connection can be keep-alive @@ -57,29 +57,29 @@ public: /// Проверяет, не завершено ли соединение с сервером. /// @details Транзакция считается завершенной, если не передан заголовок /// "Connection: Keep Alive". - bool IsKeepAlive() const noexcept; + bool IsKeepAlive() const noexcept; /* * output data can be encoded */ /// Проверяет, поддерживается ли данный тип кодирования содержимого /// ответа HTTP-сервера. - bool AcceptEncoding(const TString& coding) const; + bool AcceptEncoding(const TString& coding) const; /// Пытается определить наилучший тип кодирования ответа HTTP-сервера. /// @details Если ответ сервера говорит о том, что поддерживаются /// любые типы кодирования, выбирается gzip. В противном случае /// из списка типов кодирования выбирается лучший из поддерживаемых сервером. - TString BestCompressionScheme() const; + TString BestCompressionScheme() const; TString BestCompressionScheme(TArrayRef<const TStringBuf> codings) const; /// Если заголовки содержат Content-Length, возвращает true и /// записывает значение из заголовка в value - bool GetContentLength(ui64& value) const noexcept; + bool GetContentLength(ui64& value) const noexcept; /// Признак запакованности данных, - если выставлен, то Content-Length, при наличии в заголовках, /// показывает объём запакованных данных, а из THttpInput мы будем вычитывать уже распакованные. - bool ContentEncoded() const noexcept; + bool ContentEncoded() const noexcept; /// Returns true if Content-Length or Transfer-Encoding header received bool HasContent() const noexcept; @@ -100,13 +100,13 @@ class THttpOutput: public IOutputStream { public: THttpOutput(IOutputStream* slave); THttpOutput(IOutputStream* slave, THttpInput* request); - ~THttpOutput() override; + ~THttpOutput() override; /* * sent http headers */ /// Возвращает контейнер с заголовками запроса к HTTP-серверу. - const THttpHeaders& SentHeaders() const noexcept; + const THttpHeaders& SentHeaders() const noexcept; /// Устанавливает режим, при котором сервер выдает ответ в упакованном виде. void EnableCompression(bool enable); @@ -125,10 +125,10 @@ public: void EnableCompressionHeader(bool enable); /// Проверяет, производится ли выдача ответов в упакованном виде. - bool IsCompressionEnabled() const noexcept; + bool IsCompressionEnabled() const noexcept; /// Проверяет, не завершается ли соединение с сервером после окончания транзакции. - bool IsKeepAliveEnabled() const noexcept; + bool IsKeepAliveEnabled() const noexcept; /// Проверяет, преобразуется ли тело HTTP-запроса/ответа в соответствии /// с заголовками Content-Encoding и Transfer-Encoding @@ -143,7 +143,7 @@ public: */ /// Проверяет, можно ли установить режим, при котором соединение с сервером /// не завершается после окончания транзакции. - bool CanBeKeepAlive() const noexcept; + bool CanBeKeepAlive() const noexcept; void SendContinue(); diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 1ea35df675..c67d6ce48c 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { }; public: - inline TTestHttpServer(const TString& res) + inline TTestHttpServer(const TString& res) : Res_(res) { } @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } private: - TString Res_; + TString Res_; size_t LastRequestSentSize_ = 0; }; @@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(TestHttpInput) { - TString res = "I'm a teapot"; + TString res = "I'm a teapot"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { output.EnableKeepAlive(true); output.EnableCompression(true); - TString r; + TString r; r += "GET / HTTP/1.1"; r += "\r\n"; r += "Host: yandex.lo"; @@ -180,56 +180,56 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { Y_UNIT_TEST(TestKeepAlive) { { - TString s = "GET / HTTP/1.0\r\n\r\n"; + TString s = "GET / HTTP/1.0\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(!in.IsKeepAlive()); } { - TString s = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"; + TString s = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(in.IsKeepAlive()); } { - TString s = "GET / HTTP/1.1\r\n\r\n"; + TString s = "GET / HTTP/1.1\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(in.IsKeepAlive()); } { - TString s = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"; + TString s = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(!in.IsKeepAlive()); } { - TString s = "HTTP/1.0 200 Ok\r\n\r\n"; + TString s = "HTTP/1.0 200 Ok\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(!in.IsKeepAlive()); } { - TString s = "HTTP/1.0 200 Ok\r\nConnection: keep-alive\r\n\r\n"; + TString s = "HTTP/1.0 200 Ok\r\nConnection: keep-alive\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(in.IsKeepAlive()); } { - TString s = "HTTP/1.1 200 Ok\r\n\r\n"; + TString s = "HTTP/1.1 200 Ok\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(in.IsKeepAlive()); } { - TString s = "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n"; + TString s = "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n"; TStringInput si(s); THttpInput in(&si); UNIT_ASSERT(!in.IsKeepAlive()); @@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(TestMinRequest) { - TString res = "qqqqqq"; + TString res = "qqqqqq"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(TestResponseWithBlanks) { - TString res = "qqqqqq\r\n\r\nsdasdsad\r\n"; + TString res = "qqqqqq\r\n\r\nsdasdsad\r\n"; TPortManager pm; const ui16 port = pm.GetPort(); @@ -282,13 +282,13 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { THttpInput input(&si); unsigned httpCode = ParseHttpRetCode(input.FirstLine()); UNIT_ASSERT_VALUES_EQUAL(httpCode, 200u); - TString reply = input.ReadAll(); + TString reply = input.ReadAll(); UNIT_ASSERT_VALUES_EQUAL(reply, res); server.Stop(); } Y_UNIT_TEST(TestOutputFlush) { - TString str; + TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); THttpOutput httpOut(&bufOut); @@ -308,8 +308,8 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(TestOutputPostFlush) { - TString str; - TString checkStr; + TString str; + TString checkStr; TStringOutput strOut(str); TStringOutput checkOut(checkStr); TBufferedOutput bufOut(&strOut, 8192); @@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } TString MakeHttpOutputBody(const char* body, bool encodingEnabled) { - TString str; + TString str; TStringOutput strOut(str); { TBufferedOutput bufOut(&strOut, 8192); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } const char* bodyDelimiter = "\r\n\r\n"; size_t bodyPos = str.find(bodyDelimiter); - UNIT_ASSERT(bodyPos != TString::npos); + UNIT_ASSERT(bodyPos != TString::npos); return str.substr(bodyPos + strlen(bodyDelimiter)); }; @@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(TestOutputFinish) { - TString str; + TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); THttpOutput httpOut(&bufOut); @@ -399,8 +399,8 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { const char* headerLine3 = "\tAccept-Language"; const char* headerLine4 = "Content-Length: 18"; - TString endLine("\r\n"); - TString r; + TString endLine("\r\n"); + TString r; r += headerLine0 + endLine; r += headerLine1 + endLine; r += headerLine2 + endLine; @@ -414,15 +414,15 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { 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)); + 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); - TString result; + TString result; TStringOutput out(result); THttpOutput httpOut(&out, &i); @@ -661,7 +661,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { out << "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n"; out << ""; out.Finish(); - TString result = outBuf.Str(); + TString result = outBuf.Str(); UNIT_ASSERT(!result.Contains(TStringBuf("0\r\n"))); } diff --git a/library/cpp/http/misc/httpcodes.cpp b/library/cpp/http/misc/httpcodes.cpp index ad8c80ac1e..40208b7d18 100644 --- a/library/cpp/http/misc/httpcodes.cpp +++ b/library/cpp/http/misc/httpcodes.cpp @@ -1,6 +1,6 @@ #include "httpcodes.h" -TStringBuf HttpCodeStrEx(int code) noexcept { +TStringBuf HttpCodeStrEx(int code) noexcept { switch (code) { case HTTP_CONTINUE: return TStringBuf("100 Continue"); diff --git a/library/cpp/http/misc/httpcodes.h b/library/cpp/http/misc/httpcodes.h index cbfbaa1188..e655dd5bd1 100644 --- a/library/cpp/http/misc/httpcodes.h +++ b/library/cpp/http/misc/httpcodes.h @@ -75,20 +75,20 @@ enum HttpCodes { HTTP_CODE_MAX }; -TStringBuf HttpCodeStrEx(int code) noexcept; +TStringBuf HttpCodeStrEx(int code) noexcept; -inline TStringBuf HttpCodeStr(int code) noexcept { +inline TStringBuf HttpCodeStr(int code) noexcept { return HttpCodeStrEx(code).Skip(4); } -inline bool IsHttpCode(int code) noexcept { +inline bool IsHttpCode(int code) noexcept { return HttpCodeStrEx(code).data() != HttpCodeStrEx(0).data(); } -inline bool IsUserError(int code) noexcept { +inline bool IsUserError(int code) noexcept { return code >= 400 && code < 500; } -inline bool IsServerError(int code) noexcept { +inline bool IsServerError(int code) noexcept { return code >= 500; } diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp index 4a3031bbf4..8fcfc002e6 100644 --- a/library/cpp/http/misc/httpdate.cpp +++ b/library/cpp/http/misc/httpdate.cpp @@ -76,8 +76,8 @@ char* format_http_date(time_t when, char* buf, size_t buflen) { return buf; } -TString FormatHttpDate(time_t when) { +TString FormatHttpDate(time_t when) { char str[64] = {0}; format_http_date(str, Y_ARRAY_SIZE(str), when); - return TString(str); + return TString(str); } diff --git a/library/cpp/http/misc/httpdate.h b/library/cpp/http/misc/httpdate.h index 04876f38fe..2d66154243 100644 --- a/library/cpp/http/misc/httpdate.h +++ b/library/cpp/http/misc/httpdate.h @@ -1,7 +1,7 @@ #pragma once #include <util/datetime/base.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <ctime> @@ -18,4 +18,4 @@ inline time_t parse_http_date(const TStringBuf& datestring) { int format_http_date(char buf[], size_t size, time_t when); char* format_http_date(time_t when, char* buf, size_t len); -TString FormatHttpDate(time_t when); +TString FormatHttpDate(time_t when); diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index f6951f68cd..27fa66f9c6 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -74,7 +74,7 @@ const char* TBaseServerRequestData::HeaderIn(TStringBuf key) const { return it->second.data(); } -TString TBaseServerRequestData::HeaderByIndex(size_t n) const noexcept { +TString TBaseServerRequestData::HeaderByIndex(size_t n) const noexcept { if (n >= HeadersCount()) { return nullptr; } @@ -179,7 +179,7 @@ bool TBaseServerRequestData::Parse(const char* origReq) { return true; } -void TBaseServerRequestData::AddHeader(const TString& name, const TString& value) { +void TBaseServerRequestData::AddHeader(const TString& name, const TString& value) { HeadersIn_[name] = value; if (stricmp(name.data(), "Host") == 0) { @@ -190,7 +190,7 @@ void TBaseServerRequestData::AddHeader(const TString& name, const TString& value } } -void TBaseServerRequestData::SetPath(const TString& path) { +void TBaseServerRequestData::SetPath(const TString& path) { PathStorage = TBuffer(path.data(), path.size() + 1); Path = PathStorage.Data(); } diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h index 16e59c4d78..74448db8d7 100644 --- a/library/cpp/http/misc/httpreqdata.h +++ b/library/cpp/http/misc/httpreqdata.h @@ -11,7 +11,7 @@ #include <util/network/socket.h> #include <util/generic/hash.h> #include <util/system/yassert.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/datetime/base.h> #include <util/generic/buffer.h> @@ -22,12 +22,12 @@ public: TBaseServerRequestData(SOCKET s = INVALID_SOCKET); TBaseServerRequestData(const char* qs, SOCKET s = INVALID_SOCKET); - void SetHost(const TString& host, ui16 port) { + void SetHost(const TString& host, ui16 port) { Host = host; Port = ToString(port); } - const TString& ServerName() const { + const TString& ServerName() const { return Host; } @@ -35,7 +35,7 @@ public: return NAddr::GetSockAddr(Socket); } - const TString& ServerPort() const { + const TString& ServerPort() const { return Port; } @@ -64,33 +64,33 @@ public: return HeadersIn_; } - inline size_t HeadersCount() const noexcept { + inline size_t HeadersCount() const noexcept { return HeadersIn_.size(); } - TString HeaderByIndex(size_t n) const noexcept; + TString HeaderByIndex(size_t n) const noexcept; const char* Environment(const char* key) const; void Clear(); - void SetSocket(SOCKET s) noexcept { + void SetSocket(SOCKET s) noexcept { Socket = s; } - ui64 RequestBeginTime() const noexcept { + ui64 RequestBeginTime() const noexcept { return BeginTime; } - void SetPath(const TString& path); + void SetPath(const TString& path); const char* GetCurPage() const; bool Parse(const char* req); - void AddHeader(const TString& name, const TString& value); + void AddHeader(const TString& name, const TString& value); private: TBuffer PathStorage; mutable char* Addr; - TString Host; - TString Port; + TString Host; + TString Port; char* Path; char* Search; size_t SearchLength; // length of Search @@ -99,7 +99,7 @@ private: mutable char AddrData[INET6_ADDRSTRLEN]; SOCKET Socket; ui64 BeginTime; - mutable TString CurPage; + mutable TString CurPage; TBuffer ParseBuf; TBuffer ModifiedQueryString; }; diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp index e332a24e91..3bc94a4d33 100644 --- a/library/cpp/http/misc/parsed_request.cpp +++ b/library/cpp/http/misc/parsed_request.cpp @@ -4,7 +4,7 @@ #include <util/generic/yexception.h> #include <util/string/cast.h> -static inline TStringBuf StripLeft(const TStringBuf& s) noexcept { +static inline TStringBuf StripLeft(const TStringBuf& s) noexcept { const char* b = s.begin(); const char* e = s.end(); diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index 38a76c4c30..4e285874ed 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -15,14 +15,14 @@ public: { } - inline ~TImpl() { + inline ~TImpl() { } - inline THttpInput* Input() noexcept { + inline THttpInput* Input() noexcept { return &HI_; } - inline THttpOutput* Output() noexcept { + inline THttpOutput* Output() noexcept { return &HO_; } @@ -53,14 +53,14 @@ THttpServerConn::THttpServerConn(const TSocket& s, size_t outputBufferSize) { } -THttpServerConn::~THttpServerConn() { +THttpServerConn::~THttpServerConn() { } -THttpInput* THttpServerConn::Input() noexcept { +THttpInput* THttpServerConn::Input() noexcept { return Impl_->Input(); } -THttpOutput* THttpServerConn::Output() noexcept { +THttpOutput* THttpServerConn::Output() noexcept { return Impl_->Output(); } diff --git a/library/cpp/http/server/conn.h b/library/cpp/http/server/conn.h index 3aa5329af4..44d6f8be28 100644 --- a/library/cpp/http/server/conn.h +++ b/library/cpp/http/server/conn.h @@ -10,22 +10,22 @@ class THttpServerConn { public: explicit THttpServerConn(const TSocket& s); THttpServerConn(const TSocket& s, size_t outputBufferSize); - ~THttpServerConn(); + ~THttpServerConn(); - THttpInput* Input() noexcept; - THttpOutput* Output() noexcept; + THttpInput* Input() noexcept; + THttpOutput* Output() noexcept; - inline const THttpInput* Input() const noexcept { + inline const THttpInput* Input() const noexcept { return const_cast<THttpServerConn*>(this)->Input(); } - inline const THttpOutput* Output() const noexcept { + inline const THttpOutput* Output() const noexcept { return const_cast<THttpServerConn*>(this)->Output(); } /// Проверяет, можно ли установить режим, при котором соединение с сервером /// не завершается после окончания транзакции. - inline bool CanBeKeepAlive() const noexcept { + inline bool CanBeKeepAlive() const noexcept { return Output()->CanBeKeepAlive(); } diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 128583bdd7..4a122d1a0a 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -31,7 +31,7 @@ using namespace NAddr; namespace { class IPollAble { public: - inline IPollAble() noexcept { + inline IPollAble() noexcept { } virtual ~IPollAble() { @@ -53,7 +53,7 @@ namespace { class TClientConnection: public IPollAble, public TIntrusiveListItem<TClientConnection> { public: TClientConnection(const TSocket& s, THttpServer::TImpl* serv, NAddr::IRemoteAddrRef listenerSockAddrRef); - ~TClientConnection() override; + ~TClientConnection() override; void OnPollEvent(TInstant now) override; @@ -81,10 +81,10 @@ public: { } - inline ~TConnections() { + inline ~TConnections() { } - inline void Add(TClientConnection* c) noexcept { + inline void Add(TClientConnection* c) noexcept { TGuard<TMutex> g(Mutex_); Conns_.PushBack(c); @@ -99,7 +99,7 @@ public: } } - inline void Clear() noexcept { + inline void Clear() noexcept { TGuard<TMutex> g(Mutex_); Conns_.Clear(); @@ -297,7 +297,7 @@ public: { } - ~TListenSocket() override { + ~TListenSocket() override { } void OnPollEvent(TInstant) override { @@ -310,7 +310,7 @@ public: Server_->AddRequestFromSocket(s, TInstant::Now(), SockAddrRef_); } - SOCKET GetSocket() const noexcept { + SOCKET GetSocket() const noexcept { return S_; } @@ -345,7 +345,7 @@ public: ListenerRunningOK = true; ListenStartEvent.Signal(); - TVector<void*> events; + TVector<void*> events; events.resize(1); TInstant now = TInstant::Now(); @@ -422,15 +422,15 @@ public: } } - inline const TOptions& Options() const noexcept { + inline const TOptions& Options() const noexcept { return Options_; } - inline void DecreaseConnections() noexcept { + inline void DecreaseConnections() noexcept { AtomicDecrement(ConnectionCount); } - inline void IncreaseConnections() noexcept { + inline void IncreaseConnections() noexcept { AtomicIncrement(ConnectionCount); } @@ -527,7 +527,7 @@ void THttpServer::RestartRequestThreads(ui32 n, ui32 queue) { Impl_->RestartRequestThreads(n, queue); } -const THttpServer::TOptions& THttpServer::Options() const noexcept { +const THttpServer::TOptions& THttpServer::Options() const noexcept { return Impl_->Options(); } @@ -566,7 +566,7 @@ TClientConnection::TClientConnection(const TSocket& s, THttpServer::TImpl* serv, HttpServ_->IncreaseConnections(); } -TClientConnection::~TClientConnection() { +TClientConnection::~TClientConnection() { HttpServ_->DecreaseConnections(); } @@ -730,7 +730,7 @@ void TClientRequest::ProcessFailRequest(int failstate) { "\r\n" "Service Unavailable\r\n"; - TString url; + TString url; if (!strnicmp(RequestString.data(), "GET ", 4)) { // Trying to extract url... @@ -764,11 +764,11 @@ void TClientRequest::ProcessFailRequest(int failstate) { Output().Flush(); } -THttpServer* TClientRequest::HttpServ() const noexcept { +THttpServer* TClientRequest::HttpServ() const noexcept { return Conn_->HttpServ_->Parent_; } -const TSocket& TClientRequest::Socket() const noexcept { +const TSocket& TClientRequest::Socket() const noexcept { return Conn_->Socket_; } diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index b292d38f27..e36a27ca25 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -23,7 +23,7 @@ public: public: struct TFailLogData { int failstate; - TString url; + TString url; }; virtual ~ICallBack() { @@ -80,7 +80,7 @@ public: int GetErrorCode(); const char* GetError(); void RestartRequestThreads(ui32 nTh, ui32 maxQS); - const TOptions& Options() const noexcept; + const TOptions& Options() const noexcept; i64 GetClientCount() const; class TImpl; @@ -109,16 +109,16 @@ public: TClientRequest(); ~TClientRequest() override; - inline THttpInput& Input() noexcept { + inline THttpInput& Input() noexcept { return *HttpConn_->Input(); } - inline THttpOutput& Output() noexcept { + inline THttpOutput& Output() noexcept { return *HttpConn_->Output(); } - THttpServer* HttpServ() const noexcept; - const TSocket& Socket() const noexcept; + THttpServer* HttpServ() const noexcept; + const TSocket& Socket() const noexcept; NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept; TInstant AcceptMoment() const noexcept; @@ -140,8 +140,8 @@ private: void Process(void* ThreadSpecificResource) override; public: - TVector<std::pair<TString, TString>> ParsedHeaders; - TString RequestString; + TVector<std::pair<TString, TString>> ParsedHeaders; + TString RequestString; private: THolder<TClientConnection> Conn_; diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index cc62bb988e..f72fde0cc2 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { }; public: - inline TEchoServer(const TString& res) + inline TEchoServer(const TString& res) : Res_(res) { } @@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } private: - TString Res_; + TString Res_; }; class TSleepingServer: public THttpServer::ICallBack { @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { THolder<TAtomicCounter> MaxConns; }; - static const TString CrLf = "\r\n"; + static const TString CrLf = "\r\n"; struct TTestRequest { TTestRequest(ui16 port, TString content = TString()) @@ -148,10 +148,10 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { void CheckContinue(TSocketInput& si) { if (Expect100Continue) { TStringStream ss; - TString firstLine; + TString firstLine; si.ReadLine(firstLine); for (;;) { - TString buf; + TString buf; si.ReadLine(buf); if (buf.size() == 0) { break; @@ -162,7 +162,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } } - TString Execute() { + TString Execute() { TSocket* s = nullptr; THolder<TSocket> singleReqSocket; if (KeepAliveConnection) { @@ -239,7 +239,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { s->Send(r.Data(), r.Size()); CheckContinue(si); Hdr = r.Str(); - TString tosend = compressedContent.Str(); + TString tosend = compressedContent.Str(); s->Send(tosend.data(), tosend.size()); } else { if (isPost) { @@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { return ss.Str(); } - TString GetDescription() const { + TString GetDescription() const { if (UseHttpOutput) { TStringStream ss; ss << (KeepAliveConnection ? "keep-alive " : "") << Type; @@ -279,13 +279,13 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { ui16 Port = 0; bool UseHttpOutput = true; - TString Type = "GET"; - TString ContentEncoding; - TString Content; + TString Type = "GET"; + TString ContentEncoding; + TString Content; bool KeepAliveConnection = false; THolder<TSocket> KeepAlivedSocket; bool EnableResponseEncoding = false; - TString Hdr; + TString Hdr; bool Expect100Continue = false; }; @@ -311,8 +311,8 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } }; - TString TestData(size_t size = 5 * 4096) { - TString res; + TString TestData(size_t size = 5 * 4096) { + TString res; for (size_t i = 0; i < size; ++i) { res += (char)i; @@ -321,7 +321,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } Y_UNIT_TEST(TestEchoServer) { - TString res = TestData(); + TString res = TestData(); TPortManager pm; const ui16 port = pm.GetPort(); const bool trueFalse[] = {true, false}; @@ -345,17 +345,17 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { for (bool enableResponseEncoding : trueFalse) { r.EnableResponseEncoding = enableResponseEncoding; - const TString reqTypes[] = {"GET", "POST"}; - for (const TString& reqType : reqTypes) { + const TString reqTypes[] = {"GET", "POST"}; + for (const TString& reqType : reqTypes) { r.Type = reqType; - const TString encoders[] = {"", "deflate"}; - for (const TString& encoder : encoders) { + const TString encoders[] = {"", "deflate"}; + for (const TString& encoder : encoders) { r.ContentEncoding = encoder; for (bool expect100Continue : trueFalse) { r.Expect100Continue = expect100Continue; - TString resp = r.Execute(); + TString resp = r.Execute(); UNIT_ASSERT_C(resp == res, "diff echo response for request:\n" + r.GetDescription()); } } @@ -377,7 +377,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { const ui16 port = pm.GetPort(); TEchoServer serverImpl(res); - TVector<THolder<THttpServer>> servers; + TVector<THolder<THttpServer>> servers; for (ui32 i = 0; i < 10; i++) { servers.push_back(MakeHolder<THttpServer>(&serverImpl, THttpServer::TOptions(port).EnableReusePort(true))); } @@ -427,7 +427,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { * Emulate request processing failures * Data should be large enough not to fit into socket buffer **/ - TString res = TestData(10 * 1024 * 1024); + TString res = TestData(10 * 1024 * 1024); TPortManager portManager; const ui16 port = portManager.GetPort(); TEchoServer serverImpl(res); @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { TTestRequest r(port); r.Content = res; r.Type = "POST"; - TString resp = r.Execute(); + TString resp = r.Execute(); if (i == 1) { UNIT_ASSERT(resp.Contains("Service Unavailable")); } else { diff --git a/library/cpp/http/server/options.cpp b/library/cpp/http/server/options.cpp index 05c954384a..e1f85d22c3 100644 --- a/library/cpp/http/server/options.cpp +++ b/library/cpp/http/server/options.cpp @@ -9,11 +9,11 @@ using TAddr = THttpServerOptions::TAddr; -static inline TString AddrToString(const TAddr& addr) { +static inline TString AddrToString(const TAddr& addr) { return addr.Addr + ":" + ToString(addr.Port); } -static inline TNetworkAddress ToNetworkAddr(const TString& address, ui16 port) { +static inline TNetworkAddress ToNetworkAddr(const TString& address, ui16 port) { if (address.empty() || address == TStringBuf("*")) { return TNetworkAddress(port); } @@ -22,14 +22,14 @@ static inline TNetworkAddress ToNetworkAddr(const TString& address, ui16 port) { } void THttpServerOptions::BindAddresses(TBindAddresses& ret) const { - THashSet<TString> check; + THashSet<TString> check; for (auto addr : BindSockaddr) { if (!addr.Port) { addr.Port = Port; } - const TString straddr = AddrToString(addr); + const TString straddr = AddrToString(addr); if (check.find(straddr) == check.end()) { check.insert(straddr); diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h index 38eda0e5e7..3354578db2 100644 --- a/library/cpp/http/server/options.h +++ b/library/cpp/http/server/options.h @@ -4,18 +4,18 @@ #include <util/network/init.h> #include <util/network/address.h> #include <util/generic/size_literals.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/datetime/base.h> class THttpServerOptions { public: - inline THttpServerOptions(ui16 port = 17000) noexcept + inline THttpServerOptions(ui16 port = 17000) noexcept : Port(port) { } - using TBindAddresses = TVector<TNetworkAddress>; + using TBindAddresses = TVector<TNetworkAddress>; void BindAddresses(TBindAddresses& ret) const; inline THttpServerOptions& AddBindAddress(const TString& address, ui16 port) { @@ -32,13 +32,13 @@ public: return AddBindAddress(address, 0); } - inline THttpServerOptions& EnableKeepAlive(bool enable) noexcept { + inline THttpServerOptions& EnableKeepAlive(bool enable) noexcept { KeepAliveEnabled = enable; return *this; } - inline THttpServerOptions& EnableCompression(bool enable) noexcept { + inline THttpServerOptions& EnableCompression(bool enable) noexcept { CompressionEnabled = enable; return *this; @@ -62,51 +62,51 @@ public: return *this; } - inline THttpServerOptions& SetThreads(ui32 threads) noexcept { + inline THttpServerOptions& SetThreads(ui32 threads) noexcept { nThreads = threads; return *this; } /// Default interface name to bind the server. Used when none of BindAddress are provided. - inline THttpServerOptions& SetHost(const TString& host) noexcept { + inline THttpServerOptions& SetHost(const TString& host) noexcept { Host = host; return *this; } /// Default port to bind the server. Used when none of BindAddress are provided. - inline THttpServerOptions& SetPort(ui16 port) noexcept { + inline THttpServerOptions& SetPort(ui16 port) noexcept { Port = port; return *this; } - inline THttpServerOptions& SetMaxConnections(ui32 mc = 0) noexcept { + inline THttpServerOptions& SetMaxConnections(ui32 mc = 0) noexcept { MaxConnections = mc; return *this; } - inline THttpServerOptions& SetMaxQueueSize(ui32 mqs = 0) noexcept { + inline THttpServerOptions& SetMaxQueueSize(ui32 mqs = 0) noexcept { MaxQueueSize = mqs; return *this; } - inline THttpServerOptions& SetClientTimeout(const TDuration& timeout) noexcept { + inline THttpServerOptions& SetClientTimeout(const TDuration& timeout) noexcept { ClientTimeout = timeout; return *this; } - inline THttpServerOptions& SetListenBacklog(int val) noexcept { + inline THttpServerOptions& SetListenBacklog(int val) noexcept { ListenBacklog = val; return *this; } - inline THttpServerOptions& SetOutputBufferSize(size_t val) noexcept { + inline THttpServerOptions& SetOutputBufferSize(size_t val) noexcept { OutputBufferSize = val; return *this; @@ -140,11 +140,11 @@ public: } struct TAddr { - TString Addr; + TString Addr; ui16 Port; }; - typedef TVector<TAddr> TAddrs; + typedef TVector<TAddr> TAddrs; bool KeepAliveEnabled = true; bool CompressionEnabled = false; diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp index 52d64c91ce..64ad7fceb3 100644 --- a/library/cpp/http/server/response.cpp +++ b/library/cpp/http/server/response.cpp @@ -18,7 +18,7 @@ THttpResponse& THttpResponse::SetContentType(const TStringBuf& contentType) { } void THttpResponse::OutTo(IOutputStream& os) const { - TVector<IOutputStream::TPart> parts; + TVector<IOutputStream::TPart> parts; const size_t FIRST_LINE_PARTS = 3; const size_t HEADERS_PARTS = Headers.Count() * 4; const size_t CONTENT_PARTS = 5; diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h index a75cb85605..a6a92c89d0 100644 --- a/library/cpp/http/server/response.h +++ b/library/cpp/http/server/response.h @@ -11,18 +11,18 @@ class IOutputStream; class THttpResponse { public: - THttpResponse() noexcept + THttpResponse() noexcept : Code(HTTP_OK) { } - explicit THttpResponse(HttpCodes code) noexcept + explicit THttpResponse(HttpCodes code) noexcept : Code(code) { } template <typename ValueType> - THttpResponse& AddHeader(const TString& name, const ValueType& value) { + THttpResponse& AddHeader(const TString& name, const ValueType& value) { return AddHeader(THttpInputHeader(name, ToString(value))); } @@ -45,7 +45,7 @@ public: * "Content-Length" header during output to IOutputStream. * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ - THttpResponse& SetContent(const TString& content) { + THttpResponse& SetContent(const TString& content) { Content = content; return *this; @@ -60,7 +60,7 @@ public: * "Content-Length" header during output to IOutputStream. * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) */ - THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) { + THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) { return SetContent(content).SetContentType(contentType); } @@ -78,5 +78,5 @@ public: private: HttpCodes Code; THttpHeaders Headers; - TString Content; + TString Content; }; diff --git a/library/cpp/int128/README.md b/library/cpp/int128/README.md index e1c4dcbb78..0fa0df29c6 100644 --- a/library/cpp/int128/README.md +++ b/library/cpp/int128/README.md @@ -1,6 +1,6 @@ -https://st.yandex-team.ru/IGNIETFERRO-697 - -(Объединение разрозненных по Аркадии библиотек для поддержки 128-битного целого) - -Идея классов ui128 / i128 в том, чтобы они работали так, как будто это компиляторные интовые типы. -Т.е. у этих классов не должно быть публичных функций типа ui128::GetHigh(), конструкторов из нескольких параметров и так далее. +https://st.yandex-team.ru/IGNIETFERRO-697 + +(Объединение разрозненных по Аркадии библиотек для поддержки 128-битного целого) + +Идея классов ui128 / i128 в том, чтобы они работали так, как будто это компиляторные интовые типы. +Т.е. у этих классов не должно быть публичных функций типа ui128::GetHigh(), конструкторов из нескольких параметров и так далее. diff --git a/library/cpp/int128/bench/main.cpp b/library/cpp/int128/bench/main.cpp index be4f8d1500..54d063cc40 100644 --- a/library/cpp/int128/bench/main.cpp +++ b/library/cpp/int128/bench/main.cpp @@ -1,45 +1,45 @@ #include <library/cpp/int128/int128.h> #include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/xrange.h> -#include <util/system/compiler.h> - -Y_CPU_BENCHMARK(LibraryDivisionUnsigned128, iface) { - ui128 b = {0, 10'000'000}; - for (const auto i : xrange(iface.Iterations())) { - ui128 a = i * 10'000'000; - ui128 c = a / b; - Y_FAKE_READ(c); - } -} - -#if defined(Y_HAVE_INT128) -Y_CPU_BENCHMARK(IntrinsicDivisionUnsigned128, iface) { - unsigned __int128 b = 10'000'000; - for (const auto i : xrange(iface.Iterations())) { - unsigned __int128 a = i * 10'000'000; - unsigned __int128 c = a / b; - Y_FAKE_READ(c); - } -} -#endif // Y_HAVE_INT128 - -Y_CPU_BENCHMARK(LibraryDivisionSigned128, iface) { - i128 b = {0, 10'000'000}; - for (const auto i : xrange(iface.Iterations())) { - i128 a = i * 10'000'000; - i128 c = a / b; - Y_FAKE_READ(c); - } -} - -#if defined(Y_HAVE_INT128) -Y_CPU_BENCHMARK(IntrinsicDivisionSigned128, iface) { - signed __int128 b = 10'000'000; - for (const auto i : xrange(iface.Iterations())) { - signed __int128 a = i * 10'000'000; - signed __int128 c = a / b; - Y_FAKE_READ(c); - } -} -#endif // Y_HAVE_INT128 + +#include <util/generic/xrange.h> +#include <util/system/compiler.h> + +Y_CPU_BENCHMARK(LibraryDivisionUnsigned128, iface) { + ui128 b = {0, 10'000'000}; + for (const auto i : xrange(iface.Iterations())) { + ui128 a = i * 10'000'000; + ui128 c = a / b; + Y_FAKE_READ(c); + } +} + +#if defined(Y_HAVE_INT128) +Y_CPU_BENCHMARK(IntrinsicDivisionUnsigned128, iface) { + unsigned __int128 b = 10'000'000; + for (const auto i : xrange(iface.Iterations())) { + unsigned __int128 a = i * 10'000'000; + unsigned __int128 c = a / b; + Y_FAKE_READ(c); + } +} +#endif // Y_HAVE_INT128 + +Y_CPU_BENCHMARK(LibraryDivisionSigned128, iface) { + i128 b = {0, 10'000'000}; + for (const auto i : xrange(iface.Iterations())) { + i128 a = i * 10'000'000; + i128 c = a / b; + Y_FAKE_READ(c); + } +} + +#if defined(Y_HAVE_INT128) +Y_CPU_BENCHMARK(IntrinsicDivisionSigned128, iface) { + signed __int128 b = 10'000'000; + for (const auto i : xrange(iface.Iterations())) { + signed __int128 a = i * 10'000'000; + signed __int128 c = a / b; + Y_FAKE_READ(c); + } +} +#endif // Y_HAVE_INT128 diff --git a/library/cpp/int128/bench/ya.make b/library/cpp/int128/bench/ya.make index 4800e7883d..bcd7c2a263 100644 --- a/library/cpp/int128/bench/ya.make +++ b/library/cpp/int128/bench/ya.make @@ -1,15 +1,15 @@ -OWNER( - vladon -) - +OWNER( + vladon +) + Y_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/int128 -) - -END() +) + +END() diff --git a/library/cpp/int128/int128.cpp b/library/cpp/int128/int128.cpp index a28a389fe8..dedcd28f91 100644 --- a/library/cpp/int128/int128.cpp +++ b/library/cpp/int128/int128.cpp @@ -1,55 +1,55 @@ -#include "int128.h" - -#include <tuple> - -IOutputStream& operator<<(IOutputStream& out, const ui128& other) { - // see http://stackoverflow.com/questions/4361441/c-print-a-biginteger-in-base-10 - // and http://stackoverflow.com/questions/8023414/how-to-convert-a-128-bit-integer-to-a-decimal-ascii-string-in-c - int d[39] = {0}; - int i; - int j; - for (i = 63; i > -1; i--) { - if ((other.High_ >> i) & 1) - ++d[0]; - for (j = 0; j < 39; j++) - d[j] *= 2; - for (j = 0; j < 38; j++) { - d[j + 1] += d[j] / 10; - d[j] %= 10; - } - } - for (i = 63; i > -1; i--) { - if ((other.Low_ >> i) & 1) - ++d[0]; - if (i > 0) - for (j = 0; j < 39; j++) - d[j] *= 2; - for (j = 0; j < 38; j++) { - d[j + 1] += d[j] / 10; - d[j] %= 10; - } - } - for (i = 38; i > 0; i--) - if (d[i] > 0) - break; - for (; i > -1; i--) - out << static_cast<char>('0' + d[i]); - - return out; -} - -void TSerializer<ui128>::Save(IOutputStream* out, const ui128& Number) { - ::Save(out, GetHigh(Number)); - ::Save(out, GetLow(Number)); -} - -void TSerializer<ui128>::Load(IInputStream* in, ui128& Number) { - ui64 High; - ui64 Low; - ::Load(in, High); - ::Load(in, Low); - Number = ui128(High, Low); -} +#include "int128.h" + +#include <tuple> + +IOutputStream& operator<<(IOutputStream& out, const ui128& other) { + // see http://stackoverflow.com/questions/4361441/c-print-a-biginteger-in-base-10 + // and http://stackoverflow.com/questions/8023414/how-to-convert-a-128-bit-integer-to-a-decimal-ascii-string-in-c + int d[39] = {0}; + int i; + int j; + for (i = 63; i > -1; i--) { + if ((other.High_ >> i) & 1) + ++d[0]; + for (j = 0; j < 39; j++) + d[j] *= 2; + for (j = 0; j < 38; j++) { + d[j + 1] += d[j] / 10; + d[j] %= 10; + } + } + for (i = 63; i > -1; i--) { + if ((other.Low_ >> i) & 1) + ++d[0]; + if (i > 0) + for (j = 0; j < 39; j++) + d[j] *= 2; + for (j = 0; j < 38; j++) { + d[j + 1] += d[j] / 10; + d[j] %= 10; + } + } + for (i = 38; i > 0; i--) + if (d[i] > 0) + break; + for (; i > -1; i--) + out << static_cast<char>('0' + d[i]); + + return out; +} + +void TSerializer<ui128>::Save(IOutputStream* out, const ui128& Number) { + ::Save(out, GetHigh(Number)); + ::Save(out, GetLow(Number)); +} + +void TSerializer<ui128>::Load(IInputStream* in, ui128& Number) { + ui64 High; + ui64 Low; + ::Load(in, High); + ::Load(in, Low); + Number = ui128(High, Low); +} IOutputStream& operator<<(IOutputStream& out, const i128& other) { diff --git a/library/cpp/int128/int128.h b/library/cpp/int128/int128.h index f1121fc0c6..e6345f4f12 100644 --- a/library/cpp/int128/int128.h +++ b/library/cpp/int128/int128.h @@ -1,1278 +1,1278 @@ -#pragma once - -#include "int128_util.h" - -#include <util/generic/bitops.h> -#include <util/system/compiler.h> -#include <util/system/defaults.h> -#include <util/stream/output.h> -#include <util/string/cast.h> -#include <util/string/builder.h> -#include <util/str_stl.h> -#include <util/ysaveload.h> - -#include <cfenv> -#include <climits> -#include <cmath> -#include <limits> -#include <type_traits> - -#if !defined(_little_endian_) && !defined(_big_endian_) - static_assert(false, "Platform endianness is not supported"); -#endif - -template <bool IsSigned> -class TInteger128 { -public: - TInteger128() noexcept = default; - -#if defined(_little_endian_) - constexpr TInteger128(const ui64 high, const ui64 low) noexcept - : Low_(low) - , High_(high) - { - } -#elif defined(_big_endian_) - constexpr TInteger128(const ui64 high, const ui64 low) noexcept - : High_(high) - , Low_(low) - { - } -#endif - - constexpr TInteger128(const TInteger128<!IsSigned> other) noexcept - : TInteger128{GetHigh(other), GetLow(other)} - { - } - -#if defined(_little_endian_) - constexpr TInteger128(const char other) noexcept - : Low_{static_cast<ui64>(other)} - , High_{0} - { - } - - constexpr TInteger128(const ui8 other) noexcept - : Low_{other} - , High_{0} - { - } - - constexpr TInteger128(const ui16 other) noexcept - : Low_{other} - , High_{0} - { - } - - constexpr TInteger128(const ui32 other) noexcept - : Low_{other} - , High_{0} - { - } - - constexpr TInteger128(const ui64 other) noexcept - : Low_{other} - , High_{0} - { - } - -#if defined(Y_HAVE_INT128) - constexpr TInteger128(const unsigned __int128 other) noexcept - : Low_{static_cast<ui64>(other & ~ui64{0})} - , High_{static_cast<ui64>(other >> 64)} - { - } -#endif - - constexpr TInteger128(const i8 other) noexcept - : Low_{static_cast<ui64>(other)} - , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} - { - } - - constexpr TInteger128(const i16 other) noexcept - : Low_{static_cast<ui64>(other)} - , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} - { - } - - constexpr TInteger128(const i32 other) noexcept - : Low_(static_cast<ui64>(other)) - , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} - { - } - - constexpr TInteger128(const i64 other) noexcept - : Low_(static_cast<ui64>(other)) - , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} - { - } - -#if defined(Y_HAVE_INT128) - template <bool IsSigned2 = IsSigned, std::enable_if_t<!IsSigned2, bool> = false> - constexpr TInteger128(const signed __int128 other) noexcept - : Low_{static_cast<ui64>(other & ~ui64{0})} - , High_{static_cast<ui64>(static_cast<unsigned __int128>(other) >> 64)} - { - } - - template <bool IsSigned2 = IsSigned, typename std::enable_if_t<IsSigned2, bool> = false> - constexpr TInteger128(const signed __int128 other) noexcept - : Low_{static_cast<ui64>(other & ~ui64(0))} - , High_{static_cast<ui64>(other >> 64)} - { - } -#endif - -#elif defined(_big_endian_) - static_assert(false, "Big-endian will be later"); -#endif // _little_endian_ or _big_endian_ - - constexpr TInteger128& operator=(const char other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const ui8 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const ui16 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const ui32 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const ui64 other) noexcept { - *this = TInteger128{other}; - return *this; - } - -#if defined(Y_HAVE_INT128) - constexpr TInteger128& operator=(const unsigned __int128 other) noexcept { - *this = TInteger128{other}; - return *this; - } -#endif - - constexpr TInteger128& operator=(const i8 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const i16 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const i32 other) noexcept { - *this = TInteger128{other}; - return *this; - } - - constexpr TInteger128& operator=(const i64 other) noexcept { - *this = TInteger128{other}; - return *this; - } - -#if defined(Y_HAVE_INT128) - constexpr TInteger128& operator=(const signed __int128 other) noexcept { - *this = TInteger128{other}; - return *this; - } -#endif // Y_HAVE_INT128 - - constexpr TInteger128& operator+=(const TInteger128 other) noexcept { - return *this = *this + other; - } - - constexpr TInteger128& operator-=(const TInteger128 other) noexcept { - return *this = *this - other; - } - - constexpr TInteger128& operator*=(const TInteger128 other) noexcept { - return *this = *this * other; - } - - constexpr TInteger128& operator&=(const TInteger128 other) noexcept { - return *this = *this & other; - } - - constexpr TInteger128& operator^=(const TInteger128 other) noexcept { +#pragma once + +#include "int128_util.h" + +#include <util/generic/bitops.h> +#include <util/system/compiler.h> +#include <util/system/defaults.h> +#include <util/stream/output.h> +#include <util/string/cast.h> +#include <util/string/builder.h> +#include <util/str_stl.h> +#include <util/ysaveload.h> + +#include <cfenv> +#include <climits> +#include <cmath> +#include <limits> +#include <type_traits> + +#if !defined(_little_endian_) && !defined(_big_endian_) + static_assert(false, "Platform endianness is not supported"); +#endif + +template <bool IsSigned> +class TInteger128 { +public: + TInteger128() noexcept = default; + +#if defined(_little_endian_) + constexpr TInteger128(const ui64 high, const ui64 low) noexcept + : Low_(low) + , High_(high) + { + } +#elif defined(_big_endian_) + constexpr TInteger128(const ui64 high, const ui64 low) noexcept + : High_(high) + , Low_(low) + { + } +#endif + + constexpr TInteger128(const TInteger128<!IsSigned> other) noexcept + : TInteger128{GetHigh(other), GetLow(other)} + { + } + +#if defined(_little_endian_) + constexpr TInteger128(const char other) noexcept + : Low_{static_cast<ui64>(other)} + , High_{0} + { + } + + constexpr TInteger128(const ui8 other) noexcept + : Low_{other} + , High_{0} + { + } + + constexpr TInteger128(const ui16 other) noexcept + : Low_{other} + , High_{0} + { + } + + constexpr TInteger128(const ui32 other) noexcept + : Low_{other} + , High_{0} + { + } + + constexpr TInteger128(const ui64 other) noexcept + : Low_{other} + , High_{0} + { + } + +#if defined(Y_HAVE_INT128) + constexpr TInteger128(const unsigned __int128 other) noexcept + : Low_{static_cast<ui64>(other & ~ui64{0})} + , High_{static_cast<ui64>(other >> 64)} + { + } +#endif + + constexpr TInteger128(const i8 other) noexcept + : Low_{static_cast<ui64>(other)} + , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} + { + } + + constexpr TInteger128(const i16 other) noexcept + : Low_{static_cast<ui64>(other)} + , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} + { + } + + constexpr TInteger128(const i32 other) noexcept + : Low_(static_cast<ui64>(other)) + , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} + { + } + + constexpr TInteger128(const i64 other) noexcept + : Low_(static_cast<ui64>(other)) + , High_{other < 0 ? std::numeric_limits<ui64>::max() : 0} + { + } + +#if defined(Y_HAVE_INT128) + template <bool IsSigned2 = IsSigned, std::enable_if_t<!IsSigned2, bool> = false> + constexpr TInteger128(const signed __int128 other) noexcept + : Low_{static_cast<ui64>(other & ~ui64{0})} + , High_{static_cast<ui64>(static_cast<unsigned __int128>(other) >> 64)} + { + } + + template <bool IsSigned2 = IsSigned, typename std::enable_if_t<IsSigned2, bool> = false> + constexpr TInteger128(const signed __int128 other) noexcept + : Low_{static_cast<ui64>(other & ~ui64(0))} + , High_{static_cast<ui64>(other >> 64)} + { + } +#endif + +#elif defined(_big_endian_) + static_assert(false, "Big-endian will be later"); +#endif // _little_endian_ or _big_endian_ + + constexpr TInteger128& operator=(const char other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const ui8 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const ui16 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const ui32 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const ui64 other) noexcept { + *this = TInteger128{other}; + return *this; + } + +#if defined(Y_HAVE_INT128) + constexpr TInteger128& operator=(const unsigned __int128 other) noexcept { + *this = TInteger128{other}; + return *this; + } +#endif + + constexpr TInteger128& operator=(const i8 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const i16 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const i32 other) noexcept { + *this = TInteger128{other}; + return *this; + } + + constexpr TInteger128& operator=(const i64 other) noexcept { + *this = TInteger128{other}; + return *this; + } + +#if defined(Y_HAVE_INT128) + constexpr TInteger128& operator=(const signed __int128 other) noexcept { + *this = TInteger128{other}; + return *this; + } +#endif // Y_HAVE_INT128 + + constexpr TInteger128& operator+=(const TInteger128 other) noexcept { + return *this = *this + other; + } + + constexpr TInteger128& operator-=(const TInteger128 other) noexcept { + return *this = *this - other; + } + + constexpr TInteger128& operator*=(const TInteger128 other) noexcept { + return *this = *this * other; + } + + constexpr TInteger128& operator&=(const TInteger128 other) noexcept { + return *this = *this & other; + } + + constexpr TInteger128& operator^=(const TInteger128 other) noexcept { return *this = *this ^ other; - } - - constexpr TInteger128& operator|=(const TInteger128 other) noexcept { - return *this = *this | other; - } - - constexpr TInteger128& operator<<=(int n) noexcept { - *this = *this << n; - return *this; - } - - constexpr TInteger128& operator>>=(int n) noexcept { - *this = *this >> n; - return *this; - } - - constexpr TInteger128& operator++() noexcept { - *this += 1; - return *this; - } - - constexpr TInteger128 operator++(int) noexcept { - const TInteger128 ret{*this}; - this->operator++(); - return ret; - } - - constexpr TInteger128& operator--() noexcept { - *this -= 1; - return *this; - } - - constexpr TInteger128 operator--(int) noexcept { - const TInteger128 ret{*this}; - this->operator--(); - return ret; - } - - explicit constexpr operator bool() const noexcept { - return Low_ || High_; - } - - explicit constexpr operator char() const noexcept { - return static_cast<char>(Low_); - } - - explicit constexpr operator ui8() const noexcept { - return static_cast<ui8>(Low_); - } - - explicit constexpr operator i8() const noexcept { - return static_cast<i8>(Low_); - } - - explicit constexpr operator ui16() const noexcept { - return static_cast<ui16>(Low_); - } - - explicit constexpr operator i16() const noexcept { - return static_cast<i16>(Low_); - } - - explicit constexpr operator ui32() const noexcept { - return static_cast<ui32>(Low_); - } - - explicit constexpr operator i32() const noexcept { - return static_cast<i32>(Low_); - } - - explicit constexpr operator ui64() const noexcept { - return static_cast<ui64>(Low_); - } - - explicit constexpr operator i64() const noexcept { - return static_cast<i64>(Low_); - } - -#if defined(Y_HAVE_INT128) - explicit constexpr operator unsigned __int128() const noexcept { - return (static_cast<unsigned __int128>(High_) << 64) + Low_; - } - - explicit constexpr operator signed __int128() const noexcept { - return (static_cast<__int128>(High_) << 64) + Low_; - } -#endif - -private: -#if defined(_little_endian_) - ui64 Low_; - ui64 High_; -#elif defined(_big_endian_) - ui64 High_; - ui64 Low_; -#endif - template <bool IsSigned2> - friend constexpr ui64 GetHigh(TInteger128<IsSigned2> value) noexcept; - - template <bool IsSigned2> - friend constexpr ui64 GetLow(TInteger128<IsSigned2> value) noexcept; - - friend IOutputStream& operator<<(IOutputStream& out, const TInteger128& other); -}; // class TInteger128 - -using ui128 = TInteger128<false>; -using i128 = TInteger128<true>; - -constexpr ui128 operator+(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator+( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator-(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator-( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator-(ui128 num) noexcept; -constexpr i128 operator-( i128 num) noexcept; -constexpr ui128 operator*(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator*( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator/(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator/( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator%(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator%( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator|(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator|( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator&(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator&( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator^(ui128 lhs, ui128 rhs) noexcept; -constexpr i128 operator^( i128 lhs, i128 rhs) noexcept; -constexpr ui128 operator<<(ui128 lhs, int n) noexcept; -constexpr i128 operator<<( i128 lhs, int n) noexcept; -constexpr ui128 operator>>(ui128 lhs, int n) noexcept; -constexpr i128 operator>>( i128 lhs, int n) noexcept; - -template <bool IsSigned> -size_t MostSignificantBit(const TInteger128<IsSigned> v); - -namespace std { - //// type traits - template <bool IsSigned> - struct is_integral<TInteger128<IsSigned>> : public std::true_type{}; - - template <bool IsSigned> - struct is_class<TInteger128<IsSigned>> : public std::false_type{}; - - template <> - struct is_signed<ui128> : public std::false_type{}; - - template <> - struct is_signed<i128> : public std::true_type{}; -} - -template <bool IsSigned> -constexpr ui64 GetHigh(const TInteger128<IsSigned> value) noexcept { - return value.High_; -} - -template <bool IsSigned> -constexpr ui64 GetLow(const TInteger128<IsSigned> value) noexcept { - return value.Low_; -} - -template <class T, std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, i128>>* = nullptr> -constexpr ui128 operator-(const ui128 lhs, const T rhs) noexcept { - return lhs - static_cast<ui128>(rhs); -} - -template <class T, std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, ui128>>* = nullptr> -constexpr ui128 operator-(const i128 lhs, const T rhs) noexcept { - return static_cast<ui128>(lhs) - rhs; -} - -// specialize std templates -namespace std { - // numeric limits - // see full list at https://en.cppreference.com/w/cpp/types/numeric_limits - template <bool IsSigned> - struct numeric_limits<TInteger128<IsSigned>> { - static constexpr bool is_specialized = true; - static constexpr bool is_signed = IsSigned; - static constexpr bool is_integer = true; - static constexpr bool is_exact = true; - static constexpr bool has_infinity = false; - static constexpr bool has_quiet_NAN = false; - static constexpr bool has_signaling_NAN = false; - static constexpr float_denorm_style has_denorm = std::denorm_absent; - static constexpr bool has_denorm_loss = false; - static constexpr float_round_style round_style = std::round_toward_zero; - static constexpr bool is_iec559 = false; - static constexpr bool is_bounded = true; - static constexpr bool is_modulo = true; - static constexpr int digits = CHAR_BIT * sizeof(ui128) - (IsSigned ? 1 : 0); - static constexpr int digits10 = 38; // std::numeric_limits<ui128>::digits * std::log10(2); - static constexpr int max_digits10 = 0; - static constexpr int radix = 2; - static constexpr int min_exponent = 0; - static constexpr int min_exponent10 = 0; - static constexpr int max_exponent = 0; - static constexpr int max_exponent10 = 0; - static constexpr bool traps = std::numeric_limits<ui64>::traps; // same as of any other ui* - static constexpr bool tinyness_before = false; - - static constexpr TInteger128<IsSigned> min() noexcept { - if constexpr (IsSigned) { - return TInteger128<IsSigned>{ - static_cast<ui64>(std::numeric_limits<i64>::min()), - 0 - }; - } - else { - return 0; - } - } - - static constexpr TInteger128<IsSigned> lowest() noexcept { - return min(); - } - - static constexpr TInteger128<IsSigned> max() noexcept { - if constexpr (IsSigned) { - return TInteger128<IsSigned>{ - static_cast<ui64>(std::numeric_limits<i64>::max()), - std::numeric_limits<ui64>::max() - }; - } - else { - return TInteger128<IsSigned>{ - std::numeric_limits<ui64>::max(), - std::numeric_limits<ui64>::max() - }; - } - } - - static constexpr TInteger128<IsSigned> epsilon() noexcept { - return 0; - } - - static constexpr TInteger128<IsSigned> round_error() noexcept { - return 0; - } - - static constexpr TInteger128<IsSigned> infinity() noexcept { - return 0; - } - - static constexpr TInteger128<IsSigned> quiet_NAN() noexcept { - return 0; - } - - static constexpr TInteger128<IsSigned> signaling_NAN() noexcept { - return 0; - } - - static constexpr TInteger128<IsSigned> denorm_min() noexcept { - return 0; - } - }; - - constexpr bool signbit(const ui128 arg) noexcept { - Y_UNUSED(arg); - return false; - } - - constexpr bool signbit(const i128 arg) noexcept { - return GetHigh(arg) & 0x8000000000000000; - } - - constexpr ui128 abs(const ui128 arg) noexcept { - return arg; - } - - constexpr i128 abs(const i128 arg) noexcept { - return signbit(arg) ? (-arg) : arg; - } -} - -constexpr bool operator==(const ui128 lhs, const ui128 rhs) noexcept { - return GetLow(lhs) == GetLow(rhs) && GetHigh(lhs) == GetHigh(rhs); -} - -constexpr bool operator==(const i128 lhs, const i128 rhs) noexcept { - return GetLow(lhs) == GetLow(rhs) && GetHigh(lhs) == GetHigh(rhs); -} - -constexpr bool operator!=(const ui128 lhs, const ui128 rhs) noexcept { - return !(lhs == rhs); -} - -constexpr bool operator!=(const i128 lhs, const i128 rhs) noexcept { - return !(lhs == rhs); -} - -constexpr bool operator<(const ui128 lhs, const ui128 rhs) noexcept { - if (GetHigh(lhs) != GetHigh(rhs)) { - return GetHigh(lhs) < GetHigh(rhs); - } - - return GetLow(lhs) < GetLow(rhs); -} - -constexpr bool operator<(const i128 lhs, const i128 rhs) noexcept { - if (lhs == 0 && rhs == 0) { - return false; - } - - const bool lhsIsNegative = std::signbit(lhs); - const bool rhsIsNegative = std::signbit(rhs); - - if (lhsIsNegative && !rhsIsNegative) { - return true; - } - - if (!lhsIsNegative && rhsIsNegative) { - return false; - } - - // both are negative or both are positive - if (GetHigh(lhs) != GetHigh(rhs)) { - return GetHigh(lhs) < GetHigh(rhs); - } - - return GetLow(lhs) < GetLow(rhs); -} - -constexpr bool operator>(const ui128 lhs, const ui128 rhs) noexcept { - return rhs < lhs; -} - -constexpr bool operator>(const i128 lhs, const i128 rhs) noexcept { - return rhs < lhs; -} - -constexpr bool operator<=(const ui128 lhs, const ui128 rhs) noexcept { - return !(rhs < lhs); -} - -constexpr bool operator<=(const i128 lhs, const i128 rhs) noexcept { - return !(rhs < lhs); -} - -constexpr bool operator>=(const ui128 lhs, const ui128 rhs) noexcept { - return !(lhs < rhs); -} - -constexpr bool operator>=(const i128 lhs, const i128 rhs) noexcept { - return !(lhs < rhs); -} - -constexpr ui128 operator+(const ui128 lhs, const ui128 rhs) noexcept { - const ui128 result{GetHigh(lhs) + GetHigh(rhs), GetLow(lhs) + GetLow(rhs)}; - if (GetLow(result) < GetLow(lhs)) { - return ui128{GetHigh(result) + 1, GetLow(result)}; - } - return result; -} - -constexpr i128 operator+(const i128 lhs, const i128 rhs) noexcept { - const i128 result{GetHigh(lhs) + GetHigh(rhs), GetLow(lhs) + GetLow(rhs)}; - if (GetLow(result) < GetLow(lhs)) { - return i128{GetHigh(result) + 1, GetLow(result)}; - } - return result; -} - -constexpr ui128 operator-(const ui128 lhs, const ui128 rhs) noexcept { - const ui128 result{GetHigh(lhs) - GetHigh(rhs), GetLow(lhs) - GetLow(rhs)}; - if (GetLow(result) > GetLow(lhs)) { // underflow - return ui128{GetHigh(result) - 1, GetLow(result)}; - } - return result; -} - -constexpr i128 operator-(const i128 lhs, const i128 rhs) noexcept { - const i128 result{GetHigh(lhs) - GetHigh(rhs), GetLow(lhs) - GetLow(rhs)}; - if (GetLow(result) > GetLow(lhs)) { // underflow - return i128{GetHigh(result) - 1, GetLow(result)}; - } - return result; -} - -constexpr ui128 operator-(const ui128 num) noexcept { - const ui128 result{~GetHigh(num), ~GetLow(num) + 1}; - if (GetLow(result) == 0) { - return ui128{GetHigh(result) + 1, GetLow(result)}; - } - return result; -} - -constexpr i128 operator-(const i128 num) noexcept { - const i128 result{~GetHigh(num), ~GetLow(num) + 1}; - if (GetLow(result) == 0) { - return i128{GetHigh(result) + 1, GetLow(result)}; - } - return result; -} - -constexpr ui128 operator*(const ui128 lhs, const ui128 rhs) noexcept { - if (rhs == 0) { - return 0; - } - if (rhs == 1) { - return lhs; - } - - ui128 result{}; - ui128 t = rhs; - - for (size_t i = 0; i < 128; ++i) { - if ((t & 1) != 0) { - result += (lhs << i); - } - - t = t >> 1; - } - - return result; -} - -constexpr i128 operator*(const i128 lhs, const i128 rhs) noexcept { - if (rhs == 0) { - return 0; - } - if (rhs == 1) { - return lhs; - } - - i128 result{}; - i128 t = rhs; - - for (size_t i = 0; i < 128; ++i) { - if ((t & 1) != 0) { - result += (lhs << i); - } - - t = t >> 1; - } - - return result; -} - -namespace NPrivateInt128 { - // NOTE: division by zero is UB and can be changed in future - constexpr void DivMod128(const ui128 lhs, const ui128 rhs, ui128* const quo, ui128* const rem) { - if (!quo && !rem) { - return; - } - - constexpr size_t n_udword_bits = sizeof(ui64) * CHAR_BIT; - constexpr size_t n_utword_bits = sizeof(ui128) * CHAR_BIT; - - ui128 q{}; - ui128 r{}; - - unsigned sr{}; - - /* special cases, X is unknown, K != 0 */ - if (GetHigh(lhs) == 0) - { - if (GetHigh(rhs) == 0) - { - /* 0 X - * --- - * 0 X - */ - if (rem) { - *rem = GetLow(lhs) % GetLow(rhs); - } - if (quo) { - *quo = GetLow(lhs) / GetLow(rhs); - } - return; - } - /* 0 X - * --- - * K X - */ - if (rem) { - *rem = GetLow(lhs); - } - if (quo) { - *quo = 0; - } - return; - } - /* n.s.high != 0 */ - if (GetLow(rhs) == 0) - { - if (GetHigh(rhs) == 0) - { - /* K X - * --- - * 0 0 - */ - if (rem) { - *rem = GetHigh(lhs) % GetLow(rhs); - } - if (quo) { - *quo = GetHigh(lhs) / GetLow(rhs); - } - return; - } - /* d.s.high != 0 */ - if (GetLow(lhs) == 0) - { - /* K 0 - * --- - * K 0 - */ - if (rem) { - *rem = ui128{GetHigh(lhs) % GetHigh(rhs), 0}; - } - if (quo) { - *quo = GetHigh(lhs) / GetHigh(rhs); - } - return; - } - /* K K - * --- - * K 0 - */ - if ((GetHigh(rhs) & (GetHigh(rhs) - 1)) == 0) /* if d is a power of 2 */ - { - if (rem) { - *rem = ui128{GetHigh(lhs) & (GetHigh(rhs) - 1), GetLow(lhs)}; - } - if (quo) { - *quo = GetHigh(lhs) >> CountLeadingZeroBits(GetHigh(rhs)); - } - return; - } - /* K K - * --- - * K 0 - */ - sr = CountLeadingZeroBits(GetHigh(rhs)) - CountLeadingZeroBits(GetHigh(lhs)); - /* 0 <= sr <= n_udword_bits - 2 or sr large */ - if (sr > n_udword_bits - 2) - { - if (rem) { - *rem = lhs; - } - if (quo) { - *quo = 0; - } - return; - } - ++sr; - /* 1 <= sr <= n_udword_bits - 1 */ - /* q.all = n.all << (n_utword_bits - sr); */ - q = ui128{ - GetLow(lhs) << (n_udword_bits - sr), - 0 - }; - r = ui128{ - GetHigh(lhs) >> sr, - (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) - }; - } - else /* d.s.low != 0 */ - { - if (GetHigh(rhs) == 0) - { - /* K X - * --- - * 0 K - */ - if ((GetLow(rhs) & (GetLow(rhs) - 1)) == 0) /* if d is a power of 2 */ - { - if (rem) { - *rem = ui128{0, GetLow(lhs) & (GetLow(rhs) - 1)}; - } - if (GetLow(rhs) == 1) { - if (quo) { - *quo = lhs; - } - return; - } - sr = CountTrailingZeroBits(GetLow(rhs)); - if (quo) { - *quo = ui128{ - GetHigh(lhs) >> sr, - (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) - }; - return; - } - } - /* K X - * --- - * 0 K - */ - sr = 1 + n_udword_bits + CountLeadingZeroBits(GetLow(rhs)) - - CountLeadingZeroBits(GetHigh(lhs)); - /* 2 <= sr <= n_utword_bits - 1 - * q.all = n.all << (n_utword_bits - sr); - * r.all = n.all >> sr; - */ - if (sr == n_udword_bits) - { - q = ui128{GetLow(lhs), 0}; - r = ui128{0, GetHigh(lhs)}; - } - else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 - { - q = ui128{ - GetLow(lhs) << (n_udword_bits - sr), - 0 - }; - r = ui128{ - GetHigh(lhs) >> sr, - (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) - }; - } - else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 - { - q = ui128{ - (GetHigh(lhs) << (n_utword_bits - sr)) | (GetLow(lhs) >> (sr - n_udword_bits)), - GetLow(lhs) << (n_utword_bits - sr) - }; - r = ui128{ - 0, - GetHigh(lhs) >> (sr - n_udword_bits) - }; - } - } - else - { - /* K X - * --- - * K K - */ - sr = CountLeadingZeroBits(GetHigh(rhs)) - CountLeadingZeroBits(GetHigh(lhs)); - /*0 <= sr <= n_udword_bits - 1 or sr large */ - if (sr > n_udword_bits - 1) - { - if (rem) { - *rem = lhs; - } - if (quo) { - *quo = 0; - } - return; - } - ++sr; - /* 1 <= sr <= n_udword_bits - * q.all = n.all << (n_utword_bits - sr); - * r.all = n.all >> sr; - */ - if (sr == n_udword_bits) - { - q = ui128{ - GetLow(lhs), - 0 - }; - r = ui128{ - 0, - GetHigh(lhs) - }; - } - else - { - r = ui128{ - GetHigh(lhs) >> sr, - (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) - }; - q = ui128{ - GetLow(lhs) << (n_udword_bits - sr), - 0 - }; - } - } - } - /* Not a special case - * q and r are initialized with: - * q = n << (128 - sr); - * r = n >> sr; - * 1 <= sr <= 128 - 1 - */ - ui32 carry = 0; - for (; sr > 0; --sr) - { - /* r:q = ((r:q) << 1) | carry */ - r = ui128{ - (GetHigh(r) << 1) | (GetLow(r) >> (n_udword_bits - 1)), - (GetLow(r) << 1) | (GetHigh(q) >> (n_udword_bits - 1)) - }; - q = ui128{ - (GetHigh(q) << 1) | (GetLow(q) >> (n_udword_bits - 1)), - (GetLow(q) << 1) | carry - }; - carry = 0; - if (r >= rhs) { - r -= rhs; - carry = 1; - } - } - q = (q << 1) | carry; - if (rem) { - *rem = r; - } - if (quo) { - *quo = q; - } - } - - struct TSignedDivisionResult { - i128 Quotient; - i128 Remainder; - }; - - constexpr TSignedDivisionResult Divide(i128 lhs, i128 rhs) noexcept; -} - -constexpr ui128 operator/(const ui128 lhs, const ui128 rhs) noexcept { - ui128 quotient{}; - NPrivateInt128::DivMod128(lhs, rhs, "ient, nullptr); - return quotient; -} - -constexpr i128 operator/(const i128 lhs, const i128 rhs) noexcept { - i128 a = std::abs(lhs); - i128 b = std::abs(rhs); - - ui128 quotient{}; - NPrivateInt128::DivMod128(a, b, "ient, nullptr); - if (std::signbit(lhs) ^ std::signbit(rhs)) { - quotient = -quotient; - } - return quotient; -} - -constexpr ui128 operator%(const ui128 lhs, const ui128 rhs) noexcept { - ui128 remainder{}; - NPrivateInt128::DivMod128(lhs, rhs, nullptr, &remainder); - return remainder; -} - -constexpr i128 operator%(const i128 lhs, const i128 rhs) noexcept { - i128 a = std::abs(lhs); - i128 b = std::abs(rhs); - ui128 remainder{}; - NPrivateInt128::DivMod128(a, b, nullptr, &remainder); - if (std::signbit(lhs)) { - remainder = -remainder; - } - return remainder; -} - -constexpr ui128 operator<<(const ui128 lhs, int n) noexcept { - if (n < 64) { - if (n != 0) { - return - ui128{ - (GetHigh(lhs) << n) | (GetLow(lhs) >> (64 - n)), - GetLow(lhs) << n - }; - } - return lhs; - } - return ui128{GetLow(lhs) << (n - 64), 0}; -} - -constexpr ui128 operator>>(const ui128 lhs, int n) noexcept { - if (n < 64) { - if (n != 0) { - return - ui128{ - GetHigh(lhs) >> n, - (GetLow(lhs) >> n) | (GetHigh(lhs) << (64 - n)) - }; - } - return lhs; - } - return ui128{0, GetHigh(lhs) >> (n - 64)}; -} - - -constexpr bool operator!(const ui128 num) noexcept { - return !GetHigh(num) && !GetLow(num); -} - -constexpr ui128 operator~(const ui128 num) noexcept { - return ui128{~GetHigh(num), ~GetLow(num)}; -} - -constexpr ui128 operator|(const ui128 lhs, const ui128 rhs) noexcept { - return ui128{GetHigh(lhs) | GetHigh(rhs), GetLow(lhs) | GetLow(rhs)}; -} - -constexpr ui128 operator&(const ui128 lhs, const ui128 rhs) noexcept { - return ui128{GetHigh(lhs) & GetHigh(rhs), GetLow(lhs) & GetLow(rhs)}; -} - -constexpr ui128 operator^(const ui128 lhs, const ui128 rhs) noexcept { - return ui128{GetHigh(lhs) ^ GetHigh(rhs), GetLow(lhs) ^ GetLow(rhs)}; -} - - -IOutputStream& operator<<(IOutputStream& out, const ui128& other); - -// For THashMap -template <> -struct THash<ui128> { - inline size_t operator()(const ui128& num) const { - return THash<ui64>()(GetHigh(num)) + THash<ui64>()(GetLow(num)); - } -}; - -template <> -class TSerializer<ui128> { -public: - static void Save(IOutputStream* out, const ui128& Number); - static void Load(IInputStream* in, ui128& Number); -}; - -template <> -inline TString ToString<ui128>(const ui128& number) { - return TStringBuilder{} << number; -} - -template <> -inline ui128 FromStringImpl<ui128>(const char* data, size_t length) { - if (length < 20) { - return ui128{ FromString<ui64>(data, length) }; - } else { - ui128 result = 0; - const TStringBuf string(data, length); - for (auto&& c : string) { - if (!std::isdigit(c)) { + } + + constexpr TInteger128& operator|=(const TInteger128 other) noexcept { + return *this = *this | other; + } + + constexpr TInteger128& operator<<=(int n) noexcept { + *this = *this << n; + return *this; + } + + constexpr TInteger128& operator>>=(int n) noexcept { + *this = *this >> n; + return *this; + } + + constexpr TInteger128& operator++() noexcept { + *this += 1; + return *this; + } + + constexpr TInteger128 operator++(int) noexcept { + const TInteger128 ret{*this}; + this->operator++(); + return ret; + } + + constexpr TInteger128& operator--() noexcept { + *this -= 1; + return *this; + } + + constexpr TInteger128 operator--(int) noexcept { + const TInteger128 ret{*this}; + this->operator--(); + return ret; + } + + explicit constexpr operator bool() const noexcept { + return Low_ || High_; + } + + explicit constexpr operator char() const noexcept { + return static_cast<char>(Low_); + } + + explicit constexpr operator ui8() const noexcept { + return static_cast<ui8>(Low_); + } + + explicit constexpr operator i8() const noexcept { + return static_cast<i8>(Low_); + } + + explicit constexpr operator ui16() const noexcept { + return static_cast<ui16>(Low_); + } + + explicit constexpr operator i16() const noexcept { + return static_cast<i16>(Low_); + } + + explicit constexpr operator ui32() const noexcept { + return static_cast<ui32>(Low_); + } + + explicit constexpr operator i32() const noexcept { + return static_cast<i32>(Low_); + } + + explicit constexpr operator ui64() const noexcept { + return static_cast<ui64>(Low_); + } + + explicit constexpr operator i64() const noexcept { + return static_cast<i64>(Low_); + } + +#if defined(Y_HAVE_INT128) + explicit constexpr operator unsigned __int128() const noexcept { + return (static_cast<unsigned __int128>(High_) << 64) + Low_; + } + + explicit constexpr operator signed __int128() const noexcept { + return (static_cast<__int128>(High_) << 64) + Low_; + } +#endif + +private: +#if defined(_little_endian_) + ui64 Low_; + ui64 High_; +#elif defined(_big_endian_) + ui64 High_; + ui64 Low_; +#endif + template <bool IsSigned2> + friend constexpr ui64 GetHigh(TInteger128<IsSigned2> value) noexcept; + + template <bool IsSigned2> + friend constexpr ui64 GetLow(TInteger128<IsSigned2> value) noexcept; + + friend IOutputStream& operator<<(IOutputStream& out, const TInteger128& other); +}; // class TInteger128 + +using ui128 = TInteger128<false>; +using i128 = TInteger128<true>; + +constexpr ui128 operator+(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator+( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator-(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator-( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator-(ui128 num) noexcept; +constexpr i128 operator-( i128 num) noexcept; +constexpr ui128 operator*(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator*( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator/(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator/( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator%(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator%( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator|(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator|( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator&(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator&( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator^(ui128 lhs, ui128 rhs) noexcept; +constexpr i128 operator^( i128 lhs, i128 rhs) noexcept; +constexpr ui128 operator<<(ui128 lhs, int n) noexcept; +constexpr i128 operator<<( i128 lhs, int n) noexcept; +constexpr ui128 operator>>(ui128 lhs, int n) noexcept; +constexpr i128 operator>>( i128 lhs, int n) noexcept; + +template <bool IsSigned> +size_t MostSignificantBit(const TInteger128<IsSigned> v); + +namespace std { + //// type traits + template <bool IsSigned> + struct is_integral<TInteger128<IsSigned>> : public std::true_type{}; + + template <bool IsSigned> + struct is_class<TInteger128<IsSigned>> : public std::false_type{}; + + template <> + struct is_signed<ui128> : public std::false_type{}; + + template <> + struct is_signed<i128> : public std::true_type{}; +} + +template <bool IsSigned> +constexpr ui64 GetHigh(const TInteger128<IsSigned> value) noexcept { + return value.High_; +} + +template <bool IsSigned> +constexpr ui64 GetLow(const TInteger128<IsSigned> value) noexcept { + return value.Low_; +} + +template <class T, std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, i128>>* = nullptr> +constexpr ui128 operator-(const ui128 lhs, const T rhs) noexcept { + return lhs - static_cast<ui128>(rhs); +} + +template <class T, std::enable_if_t<std::is_same_v<std::remove_cv_t<T>, ui128>>* = nullptr> +constexpr ui128 operator-(const i128 lhs, const T rhs) noexcept { + return static_cast<ui128>(lhs) - rhs; +} + +// specialize std templates +namespace std { + // numeric limits + // see full list at https://en.cppreference.com/w/cpp/types/numeric_limits + template <bool IsSigned> + struct numeric_limits<TInteger128<IsSigned>> { + static constexpr bool is_specialized = true; + static constexpr bool is_signed = IsSigned; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NAN = false; + static constexpr bool has_signaling_NAN = false; + static constexpr float_denorm_style has_denorm = std::denorm_absent; + static constexpr bool has_denorm_loss = false; + static constexpr float_round_style round_style = std::round_toward_zero; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr int digits = CHAR_BIT * sizeof(ui128) - (IsSigned ? 1 : 0); + static constexpr int digits10 = 38; // std::numeric_limits<ui128>::digits * std::log10(2); + static constexpr int max_digits10 = 0; + static constexpr int radix = 2; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + static constexpr bool traps = std::numeric_limits<ui64>::traps; // same as of any other ui* + static constexpr bool tinyness_before = false; + + static constexpr TInteger128<IsSigned> min() noexcept { + if constexpr (IsSigned) { + return TInteger128<IsSigned>{ + static_cast<ui64>(std::numeric_limits<i64>::min()), + 0 + }; + } + else { + return 0; + } + } + + static constexpr TInteger128<IsSigned> lowest() noexcept { + return min(); + } + + static constexpr TInteger128<IsSigned> max() noexcept { + if constexpr (IsSigned) { + return TInteger128<IsSigned>{ + static_cast<ui64>(std::numeric_limits<i64>::max()), + std::numeric_limits<ui64>::max() + }; + } + else { + return TInteger128<IsSigned>{ + std::numeric_limits<ui64>::max(), + std::numeric_limits<ui64>::max() + }; + } + } + + static constexpr TInteger128<IsSigned> epsilon() noexcept { + return 0; + } + + static constexpr TInteger128<IsSigned> round_error() noexcept { + return 0; + } + + static constexpr TInteger128<IsSigned> infinity() noexcept { + return 0; + } + + static constexpr TInteger128<IsSigned> quiet_NAN() noexcept { + return 0; + } + + static constexpr TInteger128<IsSigned> signaling_NAN() noexcept { + return 0; + } + + static constexpr TInteger128<IsSigned> denorm_min() noexcept { + return 0; + } + }; + + constexpr bool signbit(const ui128 arg) noexcept { + Y_UNUSED(arg); + return false; + } + + constexpr bool signbit(const i128 arg) noexcept { + return GetHigh(arg) & 0x8000000000000000; + } + + constexpr ui128 abs(const ui128 arg) noexcept { + return arg; + } + + constexpr i128 abs(const i128 arg) noexcept { + return signbit(arg) ? (-arg) : arg; + } +} + +constexpr bool operator==(const ui128 lhs, const ui128 rhs) noexcept { + return GetLow(lhs) == GetLow(rhs) && GetHigh(lhs) == GetHigh(rhs); +} + +constexpr bool operator==(const i128 lhs, const i128 rhs) noexcept { + return GetLow(lhs) == GetLow(rhs) && GetHigh(lhs) == GetHigh(rhs); +} + +constexpr bool operator!=(const ui128 lhs, const ui128 rhs) noexcept { + return !(lhs == rhs); +} + +constexpr bool operator!=(const i128 lhs, const i128 rhs) noexcept { + return !(lhs == rhs); +} + +constexpr bool operator<(const ui128 lhs, const ui128 rhs) noexcept { + if (GetHigh(lhs) != GetHigh(rhs)) { + return GetHigh(lhs) < GetHigh(rhs); + } + + return GetLow(lhs) < GetLow(rhs); +} + +constexpr bool operator<(const i128 lhs, const i128 rhs) noexcept { + if (lhs == 0 && rhs == 0) { + return false; + } + + const bool lhsIsNegative = std::signbit(lhs); + const bool rhsIsNegative = std::signbit(rhs); + + if (lhsIsNegative && !rhsIsNegative) { + return true; + } + + if (!lhsIsNegative && rhsIsNegative) { + return false; + } + + // both are negative or both are positive + if (GetHigh(lhs) != GetHigh(rhs)) { + return GetHigh(lhs) < GetHigh(rhs); + } + + return GetLow(lhs) < GetLow(rhs); +} + +constexpr bool operator>(const ui128 lhs, const ui128 rhs) noexcept { + return rhs < lhs; +} + +constexpr bool operator>(const i128 lhs, const i128 rhs) noexcept { + return rhs < lhs; +} + +constexpr bool operator<=(const ui128 lhs, const ui128 rhs) noexcept { + return !(rhs < lhs); +} + +constexpr bool operator<=(const i128 lhs, const i128 rhs) noexcept { + return !(rhs < lhs); +} + +constexpr bool operator>=(const ui128 lhs, const ui128 rhs) noexcept { + return !(lhs < rhs); +} + +constexpr bool operator>=(const i128 lhs, const i128 rhs) noexcept { + return !(lhs < rhs); +} + +constexpr ui128 operator+(const ui128 lhs, const ui128 rhs) noexcept { + const ui128 result{GetHigh(lhs) + GetHigh(rhs), GetLow(lhs) + GetLow(rhs)}; + if (GetLow(result) < GetLow(lhs)) { + return ui128{GetHigh(result) + 1, GetLow(result)}; + } + return result; +} + +constexpr i128 operator+(const i128 lhs, const i128 rhs) noexcept { + const i128 result{GetHigh(lhs) + GetHigh(rhs), GetLow(lhs) + GetLow(rhs)}; + if (GetLow(result) < GetLow(lhs)) { + return i128{GetHigh(result) + 1, GetLow(result)}; + } + return result; +} + +constexpr ui128 operator-(const ui128 lhs, const ui128 rhs) noexcept { + const ui128 result{GetHigh(lhs) - GetHigh(rhs), GetLow(lhs) - GetLow(rhs)}; + if (GetLow(result) > GetLow(lhs)) { // underflow + return ui128{GetHigh(result) - 1, GetLow(result)}; + } + return result; +} + +constexpr i128 operator-(const i128 lhs, const i128 rhs) noexcept { + const i128 result{GetHigh(lhs) - GetHigh(rhs), GetLow(lhs) - GetLow(rhs)}; + if (GetLow(result) > GetLow(lhs)) { // underflow + return i128{GetHigh(result) - 1, GetLow(result)}; + } + return result; +} + +constexpr ui128 operator-(const ui128 num) noexcept { + const ui128 result{~GetHigh(num), ~GetLow(num) + 1}; + if (GetLow(result) == 0) { + return ui128{GetHigh(result) + 1, GetLow(result)}; + } + return result; +} + +constexpr i128 operator-(const i128 num) noexcept { + const i128 result{~GetHigh(num), ~GetLow(num) + 1}; + if (GetLow(result) == 0) { + return i128{GetHigh(result) + 1, GetLow(result)}; + } + return result; +} + +constexpr ui128 operator*(const ui128 lhs, const ui128 rhs) noexcept { + if (rhs == 0) { + return 0; + } + if (rhs == 1) { + return lhs; + } + + ui128 result{}; + ui128 t = rhs; + + for (size_t i = 0; i < 128; ++i) { + if ((t & 1) != 0) { + result += (lhs << i); + } + + t = t >> 1; + } + + return result; +} + +constexpr i128 operator*(const i128 lhs, const i128 rhs) noexcept { + if (rhs == 0) { + return 0; + } + if (rhs == 1) { + return lhs; + } + + i128 result{}; + i128 t = rhs; + + for (size_t i = 0; i < 128; ++i) { + if ((t & 1) != 0) { + result += (lhs << i); + } + + t = t >> 1; + } + + return result; +} + +namespace NPrivateInt128 { + // NOTE: division by zero is UB and can be changed in future + constexpr void DivMod128(const ui128 lhs, const ui128 rhs, ui128* const quo, ui128* const rem) { + if (!quo && !rem) { + return; + } + + constexpr size_t n_udword_bits = sizeof(ui64) * CHAR_BIT; + constexpr size_t n_utword_bits = sizeof(ui128) * CHAR_BIT; + + ui128 q{}; + ui128 r{}; + + unsigned sr{}; + + /* special cases, X is unknown, K != 0 */ + if (GetHigh(lhs) == 0) + { + if (GetHigh(rhs) == 0) + { + /* 0 X + * --- + * 0 X + */ + if (rem) { + *rem = GetLow(lhs) % GetLow(rhs); + } + if (quo) { + *quo = GetLow(lhs) / GetLow(rhs); + } + return; + } + /* 0 X + * --- + * K X + */ + if (rem) { + *rem = GetLow(lhs); + } + if (quo) { + *quo = 0; + } + return; + } + /* n.s.high != 0 */ + if (GetLow(rhs) == 0) + { + if (GetHigh(rhs) == 0) + { + /* K X + * --- + * 0 0 + */ + if (rem) { + *rem = GetHigh(lhs) % GetLow(rhs); + } + if (quo) { + *quo = GetHigh(lhs) / GetLow(rhs); + } + return; + } + /* d.s.high != 0 */ + if (GetLow(lhs) == 0) + { + /* K 0 + * --- + * K 0 + */ + if (rem) { + *rem = ui128{GetHigh(lhs) % GetHigh(rhs), 0}; + } + if (quo) { + *quo = GetHigh(lhs) / GetHigh(rhs); + } + return; + } + /* K K + * --- + * K 0 + */ + if ((GetHigh(rhs) & (GetHigh(rhs) - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) { + *rem = ui128{GetHigh(lhs) & (GetHigh(rhs) - 1), GetLow(lhs)}; + } + if (quo) { + *quo = GetHigh(lhs) >> CountLeadingZeroBits(GetHigh(rhs)); + } + return; + } + /* K K + * --- + * K 0 + */ + sr = CountLeadingZeroBits(GetHigh(rhs)) - CountLeadingZeroBits(GetHigh(lhs)); + /* 0 <= sr <= n_udword_bits - 2 or sr large */ + if (sr > n_udword_bits - 2) + { + if (rem) { + *rem = lhs; + } + if (quo) { + *quo = 0; + } + return; + } + ++sr; + /* 1 <= sr <= n_udword_bits - 1 */ + /* q.all = n.all << (n_utword_bits - sr); */ + q = ui128{ + GetLow(lhs) << (n_udword_bits - sr), + 0 + }; + r = ui128{ + GetHigh(lhs) >> sr, + (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) + }; + } + else /* d.s.low != 0 */ + { + if (GetHigh(rhs) == 0) + { + /* K X + * --- + * 0 K + */ + if ((GetLow(rhs) & (GetLow(rhs) - 1)) == 0) /* if d is a power of 2 */ + { + if (rem) { + *rem = ui128{0, GetLow(lhs) & (GetLow(rhs) - 1)}; + } + if (GetLow(rhs) == 1) { + if (quo) { + *quo = lhs; + } + return; + } + sr = CountTrailingZeroBits(GetLow(rhs)); + if (quo) { + *quo = ui128{ + GetHigh(lhs) >> sr, + (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) + }; + return; + } + } + /* K X + * --- + * 0 K + */ + sr = 1 + n_udword_bits + CountLeadingZeroBits(GetLow(rhs)) + - CountLeadingZeroBits(GetHigh(lhs)); + /* 2 <= sr <= n_utword_bits - 1 + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + */ + if (sr == n_udword_bits) + { + q = ui128{GetLow(lhs), 0}; + r = ui128{0, GetHigh(lhs)}; + } + else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 + { + q = ui128{ + GetLow(lhs) << (n_udword_bits - sr), + 0 + }; + r = ui128{ + GetHigh(lhs) >> sr, + (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) + }; + } + else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 + { + q = ui128{ + (GetHigh(lhs) << (n_utword_bits - sr)) | (GetLow(lhs) >> (sr - n_udword_bits)), + GetLow(lhs) << (n_utword_bits - sr) + }; + r = ui128{ + 0, + GetHigh(lhs) >> (sr - n_udword_bits) + }; + } + } + else + { + /* K X + * --- + * K K + */ + sr = CountLeadingZeroBits(GetHigh(rhs)) - CountLeadingZeroBits(GetHigh(lhs)); + /*0 <= sr <= n_udword_bits - 1 or sr large */ + if (sr > n_udword_bits - 1) + { + if (rem) { + *rem = lhs; + } + if (quo) { + *quo = 0; + } + return; + } + ++sr; + /* 1 <= sr <= n_udword_bits + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + */ + if (sr == n_udword_bits) + { + q = ui128{ + GetLow(lhs), + 0 + }; + r = ui128{ + 0, + GetHigh(lhs) + }; + } + else + { + r = ui128{ + GetHigh(lhs) >> sr, + (GetHigh(lhs) << (n_udword_bits - sr)) | (GetLow(lhs) >> sr) + }; + q = ui128{ + GetLow(lhs) << (n_udword_bits - sr), + 0 + }; + } + } + } + /* Not a special case + * q and r are initialized with: + * q = n << (128 - sr); + * r = n >> sr; + * 1 <= sr <= 128 - 1 + */ + ui32 carry = 0; + for (; sr > 0; --sr) + { + /* r:q = ((r:q) << 1) | carry */ + r = ui128{ + (GetHigh(r) << 1) | (GetLow(r) >> (n_udword_bits - 1)), + (GetLow(r) << 1) | (GetHigh(q) >> (n_udword_bits - 1)) + }; + q = ui128{ + (GetHigh(q) << 1) | (GetLow(q) >> (n_udword_bits - 1)), + (GetLow(q) << 1) | carry + }; + carry = 0; + if (r >= rhs) { + r -= rhs; + carry = 1; + } + } + q = (q << 1) | carry; + if (rem) { + *rem = r; + } + if (quo) { + *quo = q; + } + } + + struct TSignedDivisionResult { + i128 Quotient; + i128 Remainder; + }; + + constexpr TSignedDivisionResult Divide(i128 lhs, i128 rhs) noexcept; +} + +constexpr ui128 operator/(const ui128 lhs, const ui128 rhs) noexcept { + ui128 quotient{}; + NPrivateInt128::DivMod128(lhs, rhs, "ient, nullptr); + return quotient; +} + +constexpr i128 operator/(const i128 lhs, const i128 rhs) noexcept { + i128 a = std::abs(lhs); + i128 b = std::abs(rhs); + + ui128 quotient{}; + NPrivateInt128::DivMod128(a, b, "ient, nullptr); + if (std::signbit(lhs) ^ std::signbit(rhs)) { + quotient = -quotient; + } + return quotient; +} + +constexpr ui128 operator%(const ui128 lhs, const ui128 rhs) noexcept { + ui128 remainder{}; + NPrivateInt128::DivMod128(lhs, rhs, nullptr, &remainder); + return remainder; +} + +constexpr i128 operator%(const i128 lhs, const i128 rhs) noexcept { + i128 a = std::abs(lhs); + i128 b = std::abs(rhs); + ui128 remainder{}; + NPrivateInt128::DivMod128(a, b, nullptr, &remainder); + if (std::signbit(lhs)) { + remainder = -remainder; + } + return remainder; +} + +constexpr ui128 operator<<(const ui128 lhs, int n) noexcept { + if (n < 64) { + if (n != 0) { + return + ui128{ + (GetHigh(lhs) << n) | (GetLow(lhs) >> (64 - n)), + GetLow(lhs) << n + }; + } + return lhs; + } + return ui128{GetLow(lhs) << (n - 64), 0}; +} + +constexpr ui128 operator>>(const ui128 lhs, int n) noexcept { + if (n < 64) { + if (n != 0) { + return + ui128{ + GetHigh(lhs) >> n, + (GetLow(lhs) >> n) | (GetHigh(lhs) << (64 - n)) + }; + } + return lhs; + } + return ui128{0, GetHigh(lhs) >> (n - 64)}; +} + + +constexpr bool operator!(const ui128 num) noexcept { + return !GetHigh(num) && !GetLow(num); +} + +constexpr ui128 operator~(const ui128 num) noexcept { + return ui128{~GetHigh(num), ~GetLow(num)}; +} + +constexpr ui128 operator|(const ui128 lhs, const ui128 rhs) noexcept { + return ui128{GetHigh(lhs) | GetHigh(rhs), GetLow(lhs) | GetLow(rhs)}; +} + +constexpr ui128 operator&(const ui128 lhs, const ui128 rhs) noexcept { + return ui128{GetHigh(lhs) & GetHigh(rhs), GetLow(lhs) & GetLow(rhs)}; +} + +constexpr ui128 operator^(const ui128 lhs, const ui128 rhs) noexcept { + return ui128{GetHigh(lhs) ^ GetHigh(rhs), GetLow(lhs) ^ GetLow(rhs)}; +} + + +IOutputStream& operator<<(IOutputStream& out, const ui128& other); + +// For THashMap +template <> +struct THash<ui128> { + inline size_t operator()(const ui128& num) const { + return THash<ui64>()(GetHigh(num)) + THash<ui64>()(GetLow(num)); + } +}; + +template <> +class TSerializer<ui128> { +public: + static void Save(IOutputStream* out, const ui128& Number); + static void Load(IInputStream* in, ui128& Number); +}; + +template <> +inline TString ToString<ui128>(const ui128& number) { + return TStringBuilder{} << number; +} + +template <> +inline ui128 FromStringImpl<ui128>(const char* data, size_t length) { + if (length < 20) { + return ui128{ FromString<ui64>(data, length) }; + } else { + ui128 result = 0; + const TStringBuf string(data, length); + for (auto&& c : string) { + if (!std::isdigit(c)) { ythrow TFromStringException() << "Unexpected symbol \""sv << c << "\""sv; - } - - ui128 x1 = result; - ui128 x2 = x1 + x1; - ui128 x4 = x2 + x2; - ui128 x8 = x4 + x4; - ui128 x10 = x8 + x2; - ui128 s = c - '0'; - result = x10 + s; - - if (GetHigh(result) < GetHigh(x1)) { + } + + ui128 x1 = result; + ui128 x2 = x1 + x1; + ui128 x4 = x2 + x2; + ui128 x8 = x4 + x4; + ui128 x10 = x8 + x2; + ui128 s = c - '0'; + result = x10 + s; + + if (GetHigh(result) < GetHigh(x1)) { ythrow TFromStringException() << TStringBuf("Integer overflow"); - } - } - - return result; - } -} - -#if defined(Y_HAVE_INT128) -template <> -inline TString ToString<unsigned __int128>(const unsigned __int128& number) { - return ToString(ui128{number}); -} - -template <> -inline unsigned __int128 FromStringImpl<unsigned __int128>(const char* data, size_t length) { - return static_cast<unsigned __int128>(FromString<ui128>(data, length)); -} -#endif - -// operators - - -namespace NPrivateInt128 { - // very naive algorithm of division - // no contract for divide by zero (i.e. it is UB) (may be changed in future) - constexpr TSignedDivisionResult Divide(i128 lhs, i128 rhs) noexcept { - TSignedDivisionResult result {}; - - // check trivial cases - // X/0 = +/- inf, X%0 = X - if (rhs == 0) { - // UB, let's return: `X / 0 = +inf`, and `X % 0 = X` - result.Quotient = std::signbit(lhs) ? std::numeric_limits<i128>::min() : std::numeric_limits<i128>::max(); - result.Remainder = lhs; - } - - // 0/Y = 0, 0%Y = 0 - else if (lhs == 0) { - result.Quotient = 0; - result.Remainder = 0; - } - - // X/1 = X, X%1 = 0 - else if (rhs == 1) { - result.Quotient = lhs; - result.Remainder = 0; - } - - // X/-1 = -X, X%(-1) = 0 - else if (rhs == -1) { - result.Quotient = -lhs; - result.Remainder = 0; - } - - // abs(X)<abs(Y), X/Y = 0, X%Y = X - else if (std::abs(lhs) < std::abs(rhs)) { - result.Quotient = 0; - result.Remainder = lhs; - } - - else if (lhs == rhs) { - result.Quotient = 1; - result.Remainder = 0; - } - - else if (lhs == -rhs) { - result.Quotient = -1; - result.Remainder = 0; - } - - else if (std::abs(lhs) > std::abs(rhs)) { - const bool quotientMustBeNegative = std::signbit(lhs) ^ std::signbit(rhs); - const bool remainderMustBeNegative = std::signbit(lhs); - - lhs = std::abs(lhs); - rhs = std::abs(rhs); - - // result is division of two ui64 - if (GetHigh(lhs) == 0 && GetHigh(rhs) == 0) { - result.Quotient = GetLow(lhs) / GetLow(rhs); - result.Remainder = GetLow(lhs) % GetLow(rhs); - } - - // naive shift-and-subtract - // https://stackoverflow.com/questions/5386377/division-without-using - i128 denominator = rhs; - result.Quotient = 0; - result.Remainder = lhs; - - const size_t shift = MostSignificantBit(lhs) - MostSignificantBit(denominator); - denominator <<= shift; - - for (size_t i = 0; i <= shift; ++i) { - result.Quotient <<= 1; - if (result.Remainder >= denominator) { - result.Remainder -= denominator; - result.Quotient |= 1; - } - denominator >>= 1; - } - - if (quotientMustBeNegative) { - result.Quotient = -result.Quotient; - } - - if (remainderMustBeNegative) { - result.Remainder = -result.Remainder; - } - } - - return result; - } -} // namespace NPrivateInt128 - -constexpr i128 operator<<(const i128 lhs, int n) noexcept { - if (n < 64) { - if (n != 0) { - return - i128{ - (GetHigh(lhs) << n) | (GetLow(lhs) >> (64 - n)), - GetLow(lhs) << n - }; - } - return lhs; - } - return i128{GetLow(lhs) << (n - 64), 0}; -} - -constexpr i128 operator>>(const i128 lhs, int n) noexcept { - if (n < 64) { - if (n != 0) { - return - i128{ - GetHigh(lhs) >> n, - (GetLow(lhs) >> n) | (GetHigh(lhs) << (64 - n)) - }; - } - return lhs; - } - return i128{0, GetHigh(lhs) >> (n - 64)}; -} - -constexpr bool operator!(const i128 num) noexcept { - return !GetHigh(num) && !GetLow(num); -} - -constexpr i128 operator~(const i128 num) noexcept { - return i128{~GetHigh(num), ~GetLow(num)}; -} - -constexpr i128 operator|(const i128 lhs, const i128 rhs) noexcept { - return i128{GetHigh(lhs) | GetHigh(rhs), GetLow(lhs) | GetLow(rhs)}; -} - -constexpr i128 operator&(const i128 lhs, const i128 rhs) noexcept { - return i128{GetHigh(lhs) & GetHigh(rhs), GetLow(lhs) & GetLow(rhs)}; -} - -constexpr i128 operator^(const i128 lhs, const i128 rhs) noexcept { - return i128{GetHigh(lhs) ^ GetHigh(rhs), GetLow(lhs) ^ GetLow(rhs)}; -} - - -IOutputStream& operator<<(IOutputStream& out, const i128& other); - -// For THashMap -template <> -struct THash<i128> { - inline size_t operator()(const i128& num) const { - return THash<ui64>()(GetHigh(num)) + THash<ui64>()(GetLow(num)); - } -}; - -template <> -class TSerializer<i128> { -public: - static void Save(IOutputStream* out, const i128& Number); - static void Load(IInputStream* in, i128& Number); -}; - -template <> -inline TString ToString<i128>(const i128& number) { - return TStringBuilder{} << number; -} - -template <> -inline i128 FromStringImpl<i128>(const char* data, size_t length) { - if (length < 20) { - return i128{ FromString<ui64>(data, length) }; - } else { - i128 result = 0; - const TStringBuf string(data, length); - for (auto&& c : string) { - if (!std::isdigit(c)) { + } + } + + return result; + } +} + +#if defined(Y_HAVE_INT128) +template <> +inline TString ToString<unsigned __int128>(const unsigned __int128& number) { + return ToString(ui128{number}); +} + +template <> +inline unsigned __int128 FromStringImpl<unsigned __int128>(const char* data, size_t length) { + return static_cast<unsigned __int128>(FromString<ui128>(data, length)); +} +#endif + +// operators + + +namespace NPrivateInt128 { + // very naive algorithm of division + // no contract for divide by zero (i.e. it is UB) (may be changed in future) + constexpr TSignedDivisionResult Divide(i128 lhs, i128 rhs) noexcept { + TSignedDivisionResult result {}; + + // check trivial cases + // X/0 = +/- inf, X%0 = X + if (rhs == 0) { + // UB, let's return: `X / 0 = +inf`, and `X % 0 = X` + result.Quotient = std::signbit(lhs) ? std::numeric_limits<i128>::min() : std::numeric_limits<i128>::max(); + result.Remainder = lhs; + } + + // 0/Y = 0, 0%Y = 0 + else if (lhs == 0) { + result.Quotient = 0; + result.Remainder = 0; + } + + // X/1 = X, X%1 = 0 + else if (rhs == 1) { + result.Quotient = lhs; + result.Remainder = 0; + } + + // X/-1 = -X, X%(-1) = 0 + else if (rhs == -1) { + result.Quotient = -lhs; + result.Remainder = 0; + } + + // abs(X)<abs(Y), X/Y = 0, X%Y = X + else if (std::abs(lhs) < std::abs(rhs)) { + result.Quotient = 0; + result.Remainder = lhs; + } + + else if (lhs == rhs) { + result.Quotient = 1; + result.Remainder = 0; + } + + else if (lhs == -rhs) { + result.Quotient = -1; + result.Remainder = 0; + } + + else if (std::abs(lhs) > std::abs(rhs)) { + const bool quotientMustBeNegative = std::signbit(lhs) ^ std::signbit(rhs); + const bool remainderMustBeNegative = std::signbit(lhs); + + lhs = std::abs(lhs); + rhs = std::abs(rhs); + + // result is division of two ui64 + if (GetHigh(lhs) == 0 && GetHigh(rhs) == 0) { + result.Quotient = GetLow(lhs) / GetLow(rhs); + result.Remainder = GetLow(lhs) % GetLow(rhs); + } + + // naive shift-and-subtract + // https://stackoverflow.com/questions/5386377/division-without-using + i128 denominator = rhs; + result.Quotient = 0; + result.Remainder = lhs; + + const size_t shift = MostSignificantBit(lhs) - MostSignificantBit(denominator); + denominator <<= shift; + + for (size_t i = 0; i <= shift; ++i) { + result.Quotient <<= 1; + if (result.Remainder >= denominator) { + result.Remainder -= denominator; + result.Quotient |= 1; + } + denominator >>= 1; + } + + if (quotientMustBeNegative) { + result.Quotient = -result.Quotient; + } + + if (remainderMustBeNegative) { + result.Remainder = -result.Remainder; + } + } + + return result; + } +} // namespace NPrivateInt128 + +constexpr i128 operator<<(const i128 lhs, int n) noexcept { + if (n < 64) { + if (n != 0) { + return + i128{ + (GetHigh(lhs) << n) | (GetLow(lhs) >> (64 - n)), + GetLow(lhs) << n + }; + } + return lhs; + } + return i128{GetLow(lhs) << (n - 64), 0}; +} + +constexpr i128 operator>>(const i128 lhs, int n) noexcept { + if (n < 64) { + if (n != 0) { + return + i128{ + GetHigh(lhs) >> n, + (GetLow(lhs) >> n) | (GetHigh(lhs) << (64 - n)) + }; + } + return lhs; + } + return i128{0, GetHigh(lhs) >> (n - 64)}; +} + +constexpr bool operator!(const i128 num) noexcept { + return !GetHigh(num) && !GetLow(num); +} + +constexpr i128 operator~(const i128 num) noexcept { + return i128{~GetHigh(num), ~GetLow(num)}; +} + +constexpr i128 operator|(const i128 lhs, const i128 rhs) noexcept { + return i128{GetHigh(lhs) | GetHigh(rhs), GetLow(lhs) | GetLow(rhs)}; +} + +constexpr i128 operator&(const i128 lhs, const i128 rhs) noexcept { + return i128{GetHigh(lhs) & GetHigh(rhs), GetLow(lhs) & GetLow(rhs)}; +} + +constexpr i128 operator^(const i128 lhs, const i128 rhs) noexcept { + return i128{GetHigh(lhs) ^ GetHigh(rhs), GetLow(lhs) ^ GetLow(rhs)}; +} + + +IOutputStream& operator<<(IOutputStream& out, const i128& other); + +// For THashMap +template <> +struct THash<i128> { + inline size_t operator()(const i128& num) const { + return THash<ui64>()(GetHigh(num)) + THash<ui64>()(GetLow(num)); + } +}; + +template <> +class TSerializer<i128> { +public: + static void Save(IOutputStream* out, const i128& Number); + static void Load(IInputStream* in, i128& Number); +}; + +template <> +inline TString ToString<i128>(const i128& number) { + return TStringBuilder{} << number; +} + +template <> +inline i128 FromStringImpl<i128>(const char* data, size_t length) { + if (length < 20) { + return i128{ FromString<ui64>(data, length) }; + } else { + i128 result = 0; + const TStringBuf string(data, length); + for (auto&& c : string) { + if (!std::isdigit(c)) { ythrow TFromStringException() << "Unexpected symbol \""sv << c << "\""sv; - } - - i128 x1 = result; - i128 x2 = x1 + x1; - i128 x4 = x2 + x2; - i128 x8 = x4 + x4; - i128 x10 = x8 + x2; - i128 s = c - '0'; - result = x10 + s; - - if (GetHigh(result) < GetHigh(x1)) { + } + + i128 x1 = result; + i128 x2 = x1 + x1; + i128 x4 = x2 + x2; + i128 x8 = x4 + x4; + i128 x10 = x8 + x2; + i128 s = c - '0'; + result = x10 + s; + + if (GetHigh(result) < GetHigh(x1)) { ythrow TFromStringException() << TStringBuf("Integer overflow"); - } - } - - return result; - } -} - -#if defined(Y_HAVE_INT128) -template <> -inline TString ToString<signed __int128>(const signed __int128& number) { - return ToString(i128{number}); -} - -template <> -inline signed __int128 FromStringImpl<signed __int128>(const char* data, size_t length) { - return static_cast<signed __int128>(FromString<i128>(data, length)); -} -#endif - -template <bool IsSigned> -Y_FORCE_INLINE size_t MostSignificantBit(const TInteger128<IsSigned> v) { - if (ui64 hi = GetHigh(v)) { - return MostSignificantBit(hi) + 64; - } - return MostSignificantBit(GetLow(v)); -} + } + } + + return result; + } +} + +#if defined(Y_HAVE_INT128) +template <> +inline TString ToString<signed __int128>(const signed __int128& number) { + return ToString(i128{number}); +} + +template <> +inline signed __int128 FromStringImpl<signed __int128>(const char* data, size_t length) { + return static_cast<signed __int128>(FromString<i128>(data, length)); +} +#endif + +template <bool IsSigned> +Y_FORCE_INLINE size_t MostSignificantBit(const TInteger128<IsSigned> v) { + if (ui64 hi = GetHigh(v)) { + return MostSignificantBit(hi) + 64; + } + return MostSignificantBit(GetLow(v)); +} diff --git a/library/cpp/int128/int128_common.h b/library/cpp/int128/int128_common.h index 6f70f09bee..7ad6485b33 100644 --- a/library/cpp/int128/int128_common.h +++ b/library/cpp/int128/int128_common.h @@ -1 +1 @@ -#pragma once +#pragma once diff --git a/library/cpp/int128/int128_util.h b/library/cpp/int128/int128_util.h index 7a5ca2c250..b3208eaed3 100644 --- a/library/cpp/int128/int128_util.h +++ b/library/cpp/int128/int128_util.h @@ -1,15 +1,15 @@ -#pragma once - -#include <util/generic/bitops.h> -#include <limits> - -namespace NPrivateInt128 { - // will be moved to util/ later - template <typename T> - constexpr unsigned CountLeadingZeroBits(const T value) { - if (value == 0) { - return std::numeric_limits<std::make_unsigned_t<T>>::digits; - } - return std::numeric_limits<std::make_unsigned_t<T>>::digits - GetValueBitCount(value); - } -} +#pragma once + +#include <util/generic/bitops.h> +#include <limits> + +namespace NPrivateInt128 { + // will be moved to util/ later + template <typename T> + constexpr unsigned CountLeadingZeroBits(const T value) { + if (value == 0) { + return std::numeric_limits<std::make_unsigned_t<T>>::digits; + } + return std::numeric_limits<std::make_unsigned_t<T>>::digits - GetValueBitCount(value); + } +} diff --git a/library/cpp/int128/ut/.gitignore b/library/cpp/int128/ut/.gitignore index 36abcb2a2c..46c7056544 100644 --- a/library/cpp/int128/ut/.gitignore +++ b/library/cpp/int128/ut/.gitignore @@ -1,2 +1,2 @@ -library-int128-ut - +library-int128-ut + diff --git a/library/cpp/int128/ut/i128_and_intrinsic_identity_ut.cpp b/library/cpp/int128/ut/i128_and_intrinsic_identity_ut.cpp index dbb7507a73..c7de9b36c7 100644 --- a/library/cpp/int128/ut/i128_and_intrinsic_identity_ut.cpp +++ b/library/cpp/int128/ut/i128_and_intrinsic_identity_ut.cpp @@ -1,598 +1,598 @@ -#include "int128_ut_helpers.h" - +#include "int128_ut_helpers.h" + #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -#include <array> -#include <type_traits> - -#if defined(Y_HAVE_INT128) -bool IsIdentical(const i128 a, const signed __int128 b) { - const std::array<ui8, 16> arrayA = NInt128Private::GetAsArray(a); - const std::array<ui8, 16> arrayB = NInt128Private::GetAsArray(b); - return arrayA == arrayB; -} - -Y_UNIT_TEST_SUITE(i128_And_i8_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_i8_Zero) { - i8 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Minus1) { - i8 n = -1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Plus1) { - i8 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Minus42) { - i8 n = -42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Plus42) { - i8 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Min) { - i8 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_Max) { - i8 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_MinPlus1) { - i8 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i8_MaxMinus1) { - i8 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_i16_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_i16_Zero) { - i16 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Minus1) { - i16 n = -1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Plus1) { - i16 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Minus42) { - i16 n = -42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Plus42) { - i16 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Min) { - i16 n = std::numeric_limits<i16>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_Max) { - i16 n = std::numeric_limits<i16>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_MinPlus1) { - i16 n = std::numeric_limits<i16>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i16_MaxMinus1) { - i16 n = std::numeric_limits<i16>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_i32_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_i32_Zero) { - i32 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Minus1) { - i32 n = -1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Plus1) { - i32 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Minus42) { - i32 n = -42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Plus42) { - i32 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Min) { - i32 n = std::numeric_limits<i32>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_Max) { - i32 n = std::numeric_limits<i32>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_MinPlus1) { - i32 n = std::numeric_limits<i32>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i32_MaxMinus1) { - i32 n = std::numeric_limits<i32>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_i64_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_i64_Zero) { - i64 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Minus1) { - i64 n = -1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Plus1) { - i64 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Minus42) { - i64 n = -42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Plus42) { - i64 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Min) { - i64 n = std::numeric_limits<i64>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_Max) { - i64 n = std::numeric_limits<i64>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_MinPlus1) { - i64 n = std::numeric_limits<i64>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_i64_MaxMinus1) { - i64 n = std::numeric_limits<i64>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_signed_int128_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_signed_int128_Zero) { - signed __int128 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Minus1) { - signed __int128 n = -1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Plus1) { - signed __int128 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Minus42) { - signed __int128 n = -42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Plus42) { - signed __int128 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Min) { - signed __int128 n = std::numeric_limits<signed __int128>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_Max) { - signed __int128 n = std::numeric_limits<signed __int128>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_MinPlus1) { - signed __int128 n = std::numeric_limits<signed __int128>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_signed_int128_MaxMinus1) { - signed __int128 n = std::numeric_limits<signed __int128>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_ui8_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_ui8_Zero) { - ui8 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_Plus1) { - ui8 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_Plus42) { - ui8 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_Min) { - ui8 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_Max) { - ui8 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_MinPlus1) { - ui8 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui8_MaxMinus1) { - ui8 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_ui16_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_ui16_Zero) { - ui16 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_Plus1) { - ui16 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_Plus42) { - ui16 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_Min) { - ui16 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_Max) { - ui16 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_MinPlus1) { - ui16 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui16_MaxMinus1) { - ui16 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_ui32_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_ui32_Zero) { - ui32 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_Plus1) { - ui32 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_Plus42) { - ui32 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_Min) { - ui32 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_Max) { - ui32 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_MinPlus1) { - ui32 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui32_MaxMinus1) { - ui32 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_ui64_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_ui64_Zero) { - ui64 n = 0; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_Plus1) { - ui64 n = 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_Plus42) { - ui64 n = 42; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_Min) { - ui64 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_Max) { - ui64 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_MinPlus1) { - ui64 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_ui64_MaxMinus1) { - ui64 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2{n}; - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} - -Y_UNIT_TEST_SUITE(i128_And_unsigned_int128_BitwiseIdentity) { - Y_UNIT_TEST(i128_from_unsigned_int128_Zero) { - unsigned __int128 n = 0; - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_Plus1) { - unsigned __int128 n = 1; - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_Plus42) { - unsigned __int128 n = 42; - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_Min) { - unsigned __int128 n = std::numeric_limits<i8>::min(); - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_Max) { - unsigned __int128 n = std::numeric_limits<i8>::max(); - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_MinPlus1) { - unsigned __int128 n = std::numeric_limits<i8>::min() + 1; - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } - - Y_UNIT_TEST(i128_from_unsigned_int128_MaxMinus1) { - unsigned __int128 n = std::numeric_limits<i8>::max() - 1; - i128 t1{n}; - signed __int128 t2 = static_cast<signed __int128>(n); - UNIT_ASSERT(IsIdentical(t1, t2)); - } -} -#endif + +#include <util/generic/cast.h> + +#include <array> +#include <type_traits> + +#if defined(Y_HAVE_INT128) +bool IsIdentical(const i128 a, const signed __int128 b) { + const std::array<ui8, 16> arrayA = NInt128Private::GetAsArray(a); + const std::array<ui8, 16> arrayB = NInt128Private::GetAsArray(b); + return arrayA == arrayB; +} + +Y_UNIT_TEST_SUITE(i128_And_i8_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_i8_Zero) { + i8 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Minus1) { + i8 n = -1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Plus1) { + i8 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Minus42) { + i8 n = -42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Plus42) { + i8 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Min) { + i8 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_Max) { + i8 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_MinPlus1) { + i8 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i8_MaxMinus1) { + i8 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_i16_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_i16_Zero) { + i16 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Minus1) { + i16 n = -1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Plus1) { + i16 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Minus42) { + i16 n = -42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Plus42) { + i16 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Min) { + i16 n = std::numeric_limits<i16>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_Max) { + i16 n = std::numeric_limits<i16>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_MinPlus1) { + i16 n = std::numeric_limits<i16>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i16_MaxMinus1) { + i16 n = std::numeric_limits<i16>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_i32_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_i32_Zero) { + i32 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Minus1) { + i32 n = -1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Plus1) { + i32 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Minus42) { + i32 n = -42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Plus42) { + i32 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Min) { + i32 n = std::numeric_limits<i32>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_Max) { + i32 n = std::numeric_limits<i32>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_MinPlus1) { + i32 n = std::numeric_limits<i32>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i32_MaxMinus1) { + i32 n = std::numeric_limits<i32>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_i64_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_i64_Zero) { + i64 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Minus1) { + i64 n = -1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Plus1) { + i64 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Minus42) { + i64 n = -42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Plus42) { + i64 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Min) { + i64 n = std::numeric_limits<i64>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_Max) { + i64 n = std::numeric_limits<i64>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_MinPlus1) { + i64 n = std::numeric_limits<i64>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_i64_MaxMinus1) { + i64 n = std::numeric_limits<i64>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_signed_int128_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_signed_int128_Zero) { + signed __int128 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Minus1) { + signed __int128 n = -1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Plus1) { + signed __int128 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Minus42) { + signed __int128 n = -42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Plus42) { + signed __int128 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Min) { + signed __int128 n = std::numeric_limits<signed __int128>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_Max) { + signed __int128 n = std::numeric_limits<signed __int128>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_MinPlus1) { + signed __int128 n = std::numeric_limits<signed __int128>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_signed_int128_MaxMinus1) { + signed __int128 n = std::numeric_limits<signed __int128>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_ui8_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_ui8_Zero) { + ui8 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_Plus1) { + ui8 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_Plus42) { + ui8 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_Min) { + ui8 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_Max) { + ui8 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_MinPlus1) { + ui8 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui8_MaxMinus1) { + ui8 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_ui16_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_ui16_Zero) { + ui16 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_Plus1) { + ui16 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_Plus42) { + ui16 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_Min) { + ui16 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_Max) { + ui16 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_MinPlus1) { + ui16 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui16_MaxMinus1) { + ui16 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_ui32_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_ui32_Zero) { + ui32 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_Plus1) { + ui32 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_Plus42) { + ui32 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_Min) { + ui32 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_Max) { + ui32 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_MinPlus1) { + ui32 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui32_MaxMinus1) { + ui32 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_ui64_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_ui64_Zero) { + ui64 n = 0; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_Plus1) { + ui64 n = 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_Plus42) { + ui64 n = 42; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_Min) { + ui64 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_Max) { + ui64 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_MinPlus1) { + ui64 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_ui64_MaxMinus1) { + ui64 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2{n}; + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} + +Y_UNIT_TEST_SUITE(i128_And_unsigned_int128_BitwiseIdentity) { + Y_UNIT_TEST(i128_from_unsigned_int128_Zero) { + unsigned __int128 n = 0; + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_Plus1) { + unsigned __int128 n = 1; + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_Plus42) { + unsigned __int128 n = 42; + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_Min) { + unsigned __int128 n = std::numeric_limits<i8>::min(); + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_Max) { + unsigned __int128 n = std::numeric_limits<i8>::max(); + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_MinPlus1) { + unsigned __int128 n = std::numeric_limits<i8>::min() + 1; + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } + + Y_UNIT_TEST(i128_from_unsigned_int128_MaxMinus1) { + unsigned __int128 n = std::numeric_limits<i8>::max() - 1; + i128 t1{n}; + signed __int128 t2 = static_cast<signed __int128>(n); + UNIT_ASSERT(IsIdentical(t1, t2)); + } +} +#endif diff --git a/library/cpp/int128/ut/i128_comparison_ut.cpp b/library/cpp/int128/ut/i128_comparison_ut.cpp index 7b8d508815..8e38ac17e2 100644 --- a/library/cpp/int128/ut/i128_comparison_ut.cpp +++ b/library/cpp/int128/ut/i128_comparison_ut.cpp @@ -1,145 +1,145 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithPositiveSuite) { - Y_UNIT_TEST(PositivePositiveGreater) { - UNIT_ASSERT(i128{1} > i128{0}); - UNIT_ASSERT(i128{2} > i128{1}); - UNIT_ASSERT(i128{42} > i128{0}); - UNIT_ASSERT(i128{42} > i128{1}); - i128 big = i128{1, 0}; - UNIT_ASSERT(big > i128{1}); - UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{0}); - } - - Y_UNIT_TEST(PositivePositiveGreaterOrEqual) { - UNIT_ASSERT(i128{1} >= i128{0}); - UNIT_ASSERT(i128{2} >= i128{1}); - UNIT_ASSERT(i128{42} >= i128{0}); - UNIT_ASSERT(i128{42} >= i128{1}); - i128 big = i128{1, 0}; - UNIT_ASSERT(big >= i128{1}); - UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{0}); - - UNIT_ASSERT(i128{0} >= i128{0}); - UNIT_ASSERT(i128{1} >= i128{1}); - UNIT_ASSERT(i128{2} >= i128{2}); - UNIT_ASSERT(i128{42} >= i128{42}); - UNIT_ASSERT(big >= big); - UNIT_ASSERT(std::numeric_limits<i128>::max() >= std::numeric_limits<i128>::max()); - } - - Y_UNIT_TEST(PositivePositiveLess) { - UNIT_ASSERT(i128{0} < i128{1}); - UNIT_ASSERT(i128{1} < i128{2}); - UNIT_ASSERT(i128{0} < i128{42}); - UNIT_ASSERT(i128{1} < i128{42}); - i128 big = i128{1, 0}; - UNIT_ASSERT(i128{1} < big); - UNIT_ASSERT(i128{0} < std::numeric_limits<i128>::max()); - } - - Y_UNIT_TEST(PositivePositiveLessOrEqual) { - UNIT_ASSERT(i128{0} <= i128{1}); - UNIT_ASSERT(i128{1} <= i128{2}); - UNIT_ASSERT(i128{0} <= i128{42}); - UNIT_ASSERT(i128{1} <= i128{42}); - i128 big = i128{1, 0}; - UNIT_ASSERT(i128{1} <= big); - UNIT_ASSERT(i128{0} <= std::numeric_limits<i128>::max()); - - UNIT_ASSERT(i128{0} <= i128{0}); - UNIT_ASSERT(i128{1} <= i128{1}); - UNIT_ASSERT(i128{2} <= i128{2}); - UNIT_ASSERT(i128{42} <= i128{42}); - UNIT_ASSERT(big <= big); - UNIT_ASSERT(std::numeric_limits<i128>::max() <= std::numeric_limits<i128>::max()); - } -} - -Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithNegativeSuite) { - Y_UNIT_TEST(PositiveNegativeGreater) { - UNIT_ASSERT(i128{0} > i128{-1}); - UNIT_ASSERT(i128{2} > i128{-1}); - UNIT_ASSERT(i128{0} > i128{-42}); - UNIT_ASSERT(i128{42} > i128{-1}); - i128 big = i128{1, 0}; - UNIT_ASSERT(big > i128{-1}); - UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{-1}); - } - - Y_UNIT_TEST(PositiveNegativeGreaterOrEqual) { - UNIT_ASSERT(i128{0} >= i128{-1}); - UNIT_ASSERT(i128{2} >= i128{-1}); - UNIT_ASSERT(i128{0} >= i128{-42}); - UNIT_ASSERT(i128{42} >= i128{-1}); - i128 big = i128{1, 0}; - UNIT_ASSERT(big >= i128{-1}); - UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{-1}); - } - - Y_UNIT_TEST(NegativePositiveLess) { - UNIT_ASSERT(i128{-1} < i128{0}); - UNIT_ASSERT(i128{-1} < i128{2}); - UNIT_ASSERT(i128{-42} < i128{0}); - UNIT_ASSERT(i128{-1} < i128{42}); - i128 big = i128{1, 0}; - UNIT_ASSERT(i128{-1} < big); - UNIT_ASSERT(i128{-1} < std::numeric_limits<i128>::max()); - } - - Y_UNIT_TEST(NegativePositiveLessOrEqual) { - UNIT_ASSERT(i128{-1} <= i128{0}); - UNIT_ASSERT(i128{-1} <= i128{2}); - UNIT_ASSERT(i128{-42} <= i128{0}); - UNIT_ASSERT(i128{-1} <= i128{42}); - i128 big = i128{1, 0}; - UNIT_ASSERT(i128{-1} <= big); - UNIT_ASSERT(i128{-1} <= std::numeric_limits<i128>::max()); - } -} - -Y_UNIT_TEST_SUITE(I128ComparisonNegativeWithNegativeSuite) { - Y_UNIT_TEST(NegativeNegativeGreater) { - UNIT_ASSERT(i128{-1} > i128{-2}); - UNIT_ASSERT(i128{-2} > i128{-3}); - UNIT_ASSERT(i128{-1} > i128{-42}); - UNIT_ASSERT(i128{-42} > i128{-142}); - i128 big = -i128{1, 0}; - UNIT_ASSERT(i128{-1} > big); - UNIT_ASSERT(i128{-1} > std::numeric_limits<i128>::min()); - } - - Y_UNIT_TEST(NegativeNegativeGreaterOrEqual) { - UNIT_ASSERT(i128{-1} >= i128{-2}); - UNIT_ASSERT(i128{-2} >= i128{-3}); - UNIT_ASSERT(i128{-1} >= i128{-42}); - UNIT_ASSERT(i128{-42} >= i128{-142}); - i128 big = -i128{1, 0}; - UNIT_ASSERT(i128{-1} >= big); - UNIT_ASSERT(i128{-1} >= std::numeric_limits<i128>::min()); - } - - Y_UNIT_TEST(NegativeNegativeLess) { - UNIT_ASSERT(i128{-2} < i128{-1}); - UNIT_ASSERT(i128{-3} < i128{-2}); - UNIT_ASSERT(i128{-42} < i128{-1}); - UNIT_ASSERT(i128{-142} < i128{42}); - i128 big = -i128{1, 0}; - UNIT_ASSERT(big < i128{-1}); - UNIT_ASSERT(std::numeric_limits<i128>::min() < i128{-1}); - } - - Y_UNIT_TEST(NegativeNegativeLessOrEqual) { - UNIT_ASSERT(i128{-2} <= i128{-1}); - UNIT_ASSERT(i128{-3} <= i128{-2}); - UNIT_ASSERT(i128{-42} <= i128{-1}); - UNIT_ASSERT(i128{-142} <= i128{42}); - i128 big = -i128{1, 0}; - UNIT_ASSERT(big <= i128{-1}); - UNIT_ASSERT(std::numeric_limits<i128>::min() <= i128{-1}); - } -} + +#include <util/generic/cast.h> + +Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithPositiveSuite) { + Y_UNIT_TEST(PositivePositiveGreater) { + UNIT_ASSERT(i128{1} > i128{0}); + UNIT_ASSERT(i128{2} > i128{1}); + UNIT_ASSERT(i128{42} > i128{0}); + UNIT_ASSERT(i128{42} > i128{1}); + i128 big = i128{1, 0}; + UNIT_ASSERT(big > i128{1}); + UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{0}); + } + + Y_UNIT_TEST(PositivePositiveGreaterOrEqual) { + UNIT_ASSERT(i128{1} >= i128{0}); + UNIT_ASSERT(i128{2} >= i128{1}); + UNIT_ASSERT(i128{42} >= i128{0}); + UNIT_ASSERT(i128{42} >= i128{1}); + i128 big = i128{1, 0}; + UNIT_ASSERT(big >= i128{1}); + UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{0}); + + UNIT_ASSERT(i128{0} >= i128{0}); + UNIT_ASSERT(i128{1} >= i128{1}); + UNIT_ASSERT(i128{2} >= i128{2}); + UNIT_ASSERT(i128{42} >= i128{42}); + UNIT_ASSERT(big >= big); + UNIT_ASSERT(std::numeric_limits<i128>::max() >= std::numeric_limits<i128>::max()); + } + + Y_UNIT_TEST(PositivePositiveLess) { + UNIT_ASSERT(i128{0} < i128{1}); + UNIT_ASSERT(i128{1} < i128{2}); + UNIT_ASSERT(i128{0} < i128{42}); + UNIT_ASSERT(i128{1} < i128{42}); + i128 big = i128{1, 0}; + UNIT_ASSERT(i128{1} < big); + UNIT_ASSERT(i128{0} < std::numeric_limits<i128>::max()); + } + + Y_UNIT_TEST(PositivePositiveLessOrEqual) { + UNIT_ASSERT(i128{0} <= i128{1}); + UNIT_ASSERT(i128{1} <= i128{2}); + UNIT_ASSERT(i128{0} <= i128{42}); + UNIT_ASSERT(i128{1} <= i128{42}); + i128 big = i128{1, 0}; + UNIT_ASSERT(i128{1} <= big); + UNIT_ASSERT(i128{0} <= std::numeric_limits<i128>::max()); + + UNIT_ASSERT(i128{0} <= i128{0}); + UNIT_ASSERT(i128{1} <= i128{1}); + UNIT_ASSERT(i128{2} <= i128{2}); + UNIT_ASSERT(i128{42} <= i128{42}); + UNIT_ASSERT(big <= big); + UNIT_ASSERT(std::numeric_limits<i128>::max() <= std::numeric_limits<i128>::max()); + } +} + +Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithNegativeSuite) { + Y_UNIT_TEST(PositiveNegativeGreater) { + UNIT_ASSERT(i128{0} > i128{-1}); + UNIT_ASSERT(i128{2} > i128{-1}); + UNIT_ASSERT(i128{0} > i128{-42}); + UNIT_ASSERT(i128{42} > i128{-1}); + i128 big = i128{1, 0}; + UNIT_ASSERT(big > i128{-1}); + UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{-1}); + } + + Y_UNIT_TEST(PositiveNegativeGreaterOrEqual) { + UNIT_ASSERT(i128{0} >= i128{-1}); + UNIT_ASSERT(i128{2} >= i128{-1}); + UNIT_ASSERT(i128{0} >= i128{-42}); + UNIT_ASSERT(i128{42} >= i128{-1}); + i128 big = i128{1, 0}; + UNIT_ASSERT(big >= i128{-1}); + UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{-1}); + } + + Y_UNIT_TEST(NegativePositiveLess) { + UNIT_ASSERT(i128{-1} < i128{0}); + UNIT_ASSERT(i128{-1} < i128{2}); + UNIT_ASSERT(i128{-42} < i128{0}); + UNIT_ASSERT(i128{-1} < i128{42}); + i128 big = i128{1, 0}; + UNIT_ASSERT(i128{-1} < big); + UNIT_ASSERT(i128{-1} < std::numeric_limits<i128>::max()); + } + + Y_UNIT_TEST(NegativePositiveLessOrEqual) { + UNIT_ASSERT(i128{-1} <= i128{0}); + UNIT_ASSERT(i128{-1} <= i128{2}); + UNIT_ASSERT(i128{-42} <= i128{0}); + UNIT_ASSERT(i128{-1} <= i128{42}); + i128 big = i128{1, 0}; + UNIT_ASSERT(i128{-1} <= big); + UNIT_ASSERT(i128{-1} <= std::numeric_limits<i128>::max()); + } +} + +Y_UNIT_TEST_SUITE(I128ComparisonNegativeWithNegativeSuite) { + Y_UNIT_TEST(NegativeNegativeGreater) { + UNIT_ASSERT(i128{-1} > i128{-2}); + UNIT_ASSERT(i128{-2} > i128{-3}); + UNIT_ASSERT(i128{-1} > i128{-42}); + UNIT_ASSERT(i128{-42} > i128{-142}); + i128 big = -i128{1, 0}; + UNIT_ASSERT(i128{-1} > big); + UNIT_ASSERT(i128{-1} > std::numeric_limits<i128>::min()); + } + + Y_UNIT_TEST(NegativeNegativeGreaterOrEqual) { + UNIT_ASSERT(i128{-1} >= i128{-2}); + UNIT_ASSERT(i128{-2} >= i128{-3}); + UNIT_ASSERT(i128{-1} >= i128{-42}); + UNIT_ASSERT(i128{-42} >= i128{-142}); + i128 big = -i128{1, 0}; + UNIT_ASSERT(i128{-1} >= big); + UNIT_ASSERT(i128{-1} >= std::numeric_limits<i128>::min()); + } + + Y_UNIT_TEST(NegativeNegativeLess) { + UNIT_ASSERT(i128{-2} < i128{-1}); + UNIT_ASSERT(i128{-3} < i128{-2}); + UNIT_ASSERT(i128{-42} < i128{-1}); + UNIT_ASSERT(i128{-142} < i128{42}); + i128 big = -i128{1, 0}; + UNIT_ASSERT(big < i128{-1}); + UNIT_ASSERT(std::numeric_limits<i128>::min() < i128{-1}); + } + + Y_UNIT_TEST(NegativeNegativeLessOrEqual) { + UNIT_ASSERT(i128{-2} <= i128{-1}); + UNIT_ASSERT(i128{-3} <= i128{-2}); + UNIT_ASSERT(i128{-42} <= i128{-1}); + UNIT_ASSERT(i128{-142} <= i128{42}); + i128 big = -i128{1, 0}; + UNIT_ASSERT(big <= i128{-1}); + UNIT_ASSERT(std::numeric_limits<i128>::min() <= i128{-1}); + } +} diff --git a/library/cpp/int128/ut/i128_division_ut.cpp b/library/cpp/int128/ut/i128_division_ut.cpp index 46b0ca27f5..b58731dd7e 100644 --- a/library/cpp/int128/ut/i128_division_ut.cpp +++ b/library/cpp/int128/ut/i128_division_ut.cpp @@ -1,413 +1,413 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -Y_UNIT_TEST_SUITE(I128DivisionBy1Suite) { - Y_UNIT_TEST(I128Divide0By1) { - i128 dividend = 0; - i128 divider = 1; - i128 expectedQuotient = 0; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide1By1) { - i128 dividend = 1; - i128 divider = 1; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide2By1) { - i128 dividend = 2; - i128 divider = 1; - i128 expectedQuotient = 2; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide42By1) { - i128 dividend = 42; - i128 divider = 1; - i128 expectedQuotient = 42; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64By1) { - i128 dividend = std::numeric_limits<ui64>::max(); - i128 divider = 1; - i128 expectedQuotient = std::numeric_limits<ui64>::max(); - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64Plus1By1) { - i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{1}; - i128 divider = 1; - i128 expectedQuotient = i128{std::numeric_limits<ui64>::max()} + i128{1}; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64Plus42By1) { - i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{42}; - i128 divider = 1; - i128 expectedQuotient = i128{std::numeric_limits<ui64>::max()} + i128{42}; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxI128By1) { - i128 dividend = std::numeric_limits<i128>::max(); - i128 divider = 1; - i128 expectedQuotient = std::numeric_limits<i128>::max(); - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxI128Minus1By1) { - i128 dividend = std::numeric_limits<i128>::max() - 1; - i128 divider = 1; - i128 expectedQuotient = std::numeric_limits<i128>::max() - 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(I128DivisionByEqualSuite) { - Y_UNIT_TEST(I128Divide1ByEqual) { - i128 dividend = 1; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide2ByEqual) { - i128 dividend = 2; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide42ByEqual) { - i128 dividend = 42; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64ByEqual) { - i128 dividend = std::numeric_limits<ui64>::max(); - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64Plus1ByEqual) { - i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{1}; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64Plus42ByEqual) { - i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{42}; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxI128ByEqual) { - i128 dividend = std::numeric_limits<i128>::max(); - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxI128Minus1ByEqual) { - i128 dividend = std::numeric_limits<i128>::max() - 1; - i128 divider = dividend; - i128 expectedQuotient = 1; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(I128DivisionLessByHigherSuite) { - Y_UNIT_TEST(I128Divide42By84) { - i128 dividend = 42; - i128 divider = 84; - i128 expectedQuotient = 0; - i128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide42ByMaxUi64) { - i128 dividend = 42; - i128 divider = std::numeric_limits<ui64>::max(); - i128 expectedQuotient = 0; - i128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128Divide42ByMaxUi64Plus1) { - i128 dividend = 42; - i128 divider = i128{std::numeric_limits<ui64>::max()} + i128{1}; - i128 expectedQuotient = 0; - i128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(I128DivideMaxUi64ByMaxUi64Plus1) { - i128 dividend = i128{std::numeric_limits<ui64>::max()}; - i128 divider = i128{std::numeric_limits<ui64>::max()} + i128{1}; - i128 expectedQuotient = 0; - i128 expectedRemainder = i128{std::numeric_limits<ui64>::max()}; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(I128DivisionWithDifferentSigns) { - Y_UNIT_TEST(DivisionPositiveByNegative) { - i128 dividend = i128{100}; - i128 divider = i128{-33}; - i128 expectedQuotient = -3; - i128 expectedRemainder = 1; - i128 quotient = dividend / divider; - i128 remainder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(remainder, expectedRemainder); - } - - Y_UNIT_TEST(DivisionNegativeByPositive) { - i128 dividend = i128{-100}; - i128 divider = i128{33}; - i128 expectedQuotient = -3; - i128 expectedRemainder = -1; - i128 quotient = dividend / divider; - i128 remainder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(remainder, expectedRemainder); - } - - Y_UNIT_TEST(DivisionNegativeByNegative) { - i128 dividend = i128{-100}; - i128 divider = i128{-33}; - i128 expectedQuotient = 3; - i128 expectedRemainder = -1; - i128 quotient = dividend / divider; - i128 remainder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(remainder, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(i128DivisionBigByBigSuite) { - Y_UNIT_TEST(i128DivideBigByBig1) { - i128 dividend = {64, 0}; - i128 divider = {1, 0}; - i128 expectedQuotient = 64; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig1_PosByNeg) { - i128 dividend = i128{64, 0}; - i128 divider = -i128{1, 0}; - i128 expectedQuotient = -i128{64}; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig1_NegByPos) { - i128 dividend = -i128{64, 0}; - i128 divider = i128{1, 0}; - i128 expectedQuotient = -i128{64}; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig1_NegByNeg) { - i128 dividend = -i128{64, 0}; - i128 divider = -i128{1, 0}; - i128 expectedQuotient = i128{64}; - i128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig2) { - i128 dividend = {64, 0}; - i128 divider = {12, 5}; - i128 expectedQuotient = 5; - i128 expectedRemainder = i128{3, 18446744073709551591ull}; // plz don't ask - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig2_PosByNeg) { - i128 dividend = i128{64, 0}; - i128 divider = -i128{12, 5}; - i128 expectedQuotient = -5; - i128 expectedRemainder = i128{3, 18446744073709551591ull}; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig2_NegByPos) { - i128 dividend = -i128{64, 0}; - i128 divider = i128{12, 5}; - i128 expectedQuotient = -5; - i128 expectedRemainder = -i128{3, 18446744073709551591ull}; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(i128DivideBigByBig2_NegByNeg) { - i128 dividend = -i128{64, 0}; - i128 divider = -i128{12, 5}; - i128 expectedQuotient = 5; - i128 expectedRemainder = -i128{3, 18446744073709551591ull}; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - -} - -Y_UNIT_TEST_SUITE(i128DivisionAlgo) { - Y_UNIT_TEST(ii128DivideAlgoCheck_PosByPos) { - /* - 49672666804009505000000 / 10000000 == 4967266680400950 - 49672666804009505000000 % 10000000 == 5000000 - */ - i128 dividend = {2692ull, 14031757583392049728ull}; - i64 divider = 10000000; - i128 expectedQuotient = {0, 4967266680400950ull}; - i128 expectedRemainder = {0, 5000000ull}; - - i128 quotient = dividend / divider; - i128 reminder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(reminder, expectedRemainder); - } - - Y_UNIT_TEST(ii128DivideAlgoCheck_PosByNeg) { - /* - 49672666804009505000000 / -10000000 == -4967266680400950 - 49672666804009505000000 % -10000000 == 5000000 - */ - i128 dividend = {2692ull, 14031757583392049728ull}; - i64 divider = -10000000; - i128 expectedQuotient = -i128{0, 4967266680400950ull}; - i128 expectedRemainder = {0, 5000000ull}; - - i128 quotient = dividend / divider; - i128 reminder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(reminder, expectedRemainder); - } - - Y_UNIT_TEST(ii128DivideAlgoCheck_NegByPos) { - /* - -49672666804009505000000 / 10000000 == -4967266680400950 - -49672666804009505000000 % 10000000 == -5000000 - */ - i128 dividend = -i128{2692ull, 14031757583392049728ull}; - i64 divider = 10000000; - i128 expectedQuotient = -i128{0, 4967266680400950ull}; - i128 expectedRemainder = -i128{0, 5000000ull}; - - i128 quotient = dividend / divider; - i128 reminder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(reminder, expectedRemainder); - } - - Y_UNIT_TEST(ii128DivideAlgoCheck_NegByNeg) { - /* - -49672666804009505000000 / -10000000 == 4967266680400950 - -49672666804009505000000 % -10000000 == -5000000 - */ - i128 dividend = -i128{2692ull, 14031757583392049728ull}; - i64 divider = -10000000; - i128 expectedQuotient = {0, 4967266680400950ull}; - i128 expectedRemainder = -i128{0, 5000000ull}; - - i128 quotient = dividend / divider; - i128 reminder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(reminder, expectedRemainder); - } - -} + +#include <util/generic/cast.h> + +Y_UNIT_TEST_SUITE(I128DivisionBy1Suite) { + Y_UNIT_TEST(I128Divide0By1) { + i128 dividend = 0; + i128 divider = 1; + i128 expectedQuotient = 0; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide1By1) { + i128 dividend = 1; + i128 divider = 1; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide2By1) { + i128 dividend = 2; + i128 divider = 1; + i128 expectedQuotient = 2; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide42By1) { + i128 dividend = 42; + i128 divider = 1; + i128 expectedQuotient = 42; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64By1) { + i128 dividend = std::numeric_limits<ui64>::max(); + i128 divider = 1; + i128 expectedQuotient = std::numeric_limits<ui64>::max(); + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64Plus1By1) { + i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{1}; + i128 divider = 1; + i128 expectedQuotient = i128{std::numeric_limits<ui64>::max()} + i128{1}; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64Plus42By1) { + i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{42}; + i128 divider = 1; + i128 expectedQuotient = i128{std::numeric_limits<ui64>::max()} + i128{42}; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxI128By1) { + i128 dividend = std::numeric_limits<i128>::max(); + i128 divider = 1; + i128 expectedQuotient = std::numeric_limits<i128>::max(); + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxI128Minus1By1) { + i128 dividend = std::numeric_limits<i128>::max() - 1; + i128 divider = 1; + i128 expectedQuotient = std::numeric_limits<i128>::max() - 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(I128DivisionByEqualSuite) { + Y_UNIT_TEST(I128Divide1ByEqual) { + i128 dividend = 1; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide2ByEqual) { + i128 dividend = 2; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide42ByEqual) { + i128 dividend = 42; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64ByEqual) { + i128 dividend = std::numeric_limits<ui64>::max(); + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64Plus1ByEqual) { + i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{1}; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64Plus42ByEqual) { + i128 dividend = i128{std::numeric_limits<ui64>::max()} + i128{42}; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxI128ByEqual) { + i128 dividend = std::numeric_limits<i128>::max(); + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxI128Minus1ByEqual) { + i128 dividend = std::numeric_limits<i128>::max() - 1; + i128 divider = dividend; + i128 expectedQuotient = 1; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(I128DivisionLessByHigherSuite) { + Y_UNIT_TEST(I128Divide42By84) { + i128 dividend = 42; + i128 divider = 84; + i128 expectedQuotient = 0; + i128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide42ByMaxUi64) { + i128 dividend = 42; + i128 divider = std::numeric_limits<ui64>::max(); + i128 expectedQuotient = 0; + i128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128Divide42ByMaxUi64Plus1) { + i128 dividend = 42; + i128 divider = i128{std::numeric_limits<ui64>::max()} + i128{1}; + i128 expectedQuotient = 0; + i128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(I128DivideMaxUi64ByMaxUi64Plus1) { + i128 dividend = i128{std::numeric_limits<ui64>::max()}; + i128 divider = i128{std::numeric_limits<ui64>::max()} + i128{1}; + i128 expectedQuotient = 0; + i128 expectedRemainder = i128{std::numeric_limits<ui64>::max()}; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(I128DivisionWithDifferentSigns) { + Y_UNIT_TEST(DivisionPositiveByNegative) { + i128 dividend = i128{100}; + i128 divider = i128{-33}; + i128 expectedQuotient = -3; + i128 expectedRemainder = 1; + i128 quotient = dividend / divider; + i128 remainder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(remainder, expectedRemainder); + } + + Y_UNIT_TEST(DivisionNegativeByPositive) { + i128 dividend = i128{-100}; + i128 divider = i128{33}; + i128 expectedQuotient = -3; + i128 expectedRemainder = -1; + i128 quotient = dividend / divider; + i128 remainder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(remainder, expectedRemainder); + } + + Y_UNIT_TEST(DivisionNegativeByNegative) { + i128 dividend = i128{-100}; + i128 divider = i128{-33}; + i128 expectedQuotient = 3; + i128 expectedRemainder = -1; + i128 quotient = dividend / divider; + i128 remainder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(remainder, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(i128DivisionBigByBigSuite) { + Y_UNIT_TEST(i128DivideBigByBig1) { + i128 dividend = {64, 0}; + i128 divider = {1, 0}; + i128 expectedQuotient = 64; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig1_PosByNeg) { + i128 dividend = i128{64, 0}; + i128 divider = -i128{1, 0}; + i128 expectedQuotient = -i128{64}; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig1_NegByPos) { + i128 dividend = -i128{64, 0}; + i128 divider = i128{1, 0}; + i128 expectedQuotient = -i128{64}; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig1_NegByNeg) { + i128 dividend = -i128{64, 0}; + i128 divider = -i128{1, 0}; + i128 expectedQuotient = i128{64}; + i128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig2) { + i128 dividend = {64, 0}; + i128 divider = {12, 5}; + i128 expectedQuotient = 5; + i128 expectedRemainder = i128{3, 18446744073709551591ull}; // plz don't ask + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig2_PosByNeg) { + i128 dividend = i128{64, 0}; + i128 divider = -i128{12, 5}; + i128 expectedQuotient = -5; + i128 expectedRemainder = i128{3, 18446744073709551591ull}; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig2_NegByPos) { + i128 dividend = -i128{64, 0}; + i128 divider = i128{12, 5}; + i128 expectedQuotient = -5; + i128 expectedRemainder = -i128{3, 18446744073709551591ull}; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(i128DivideBigByBig2_NegByNeg) { + i128 dividend = -i128{64, 0}; + i128 divider = -i128{12, 5}; + i128 expectedQuotient = 5; + i128 expectedRemainder = -i128{3, 18446744073709551591ull}; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + +} + +Y_UNIT_TEST_SUITE(i128DivisionAlgo) { + Y_UNIT_TEST(ii128DivideAlgoCheck_PosByPos) { + /* + 49672666804009505000000 / 10000000 == 4967266680400950 + 49672666804009505000000 % 10000000 == 5000000 + */ + i128 dividend = {2692ull, 14031757583392049728ull}; + i64 divider = 10000000; + i128 expectedQuotient = {0, 4967266680400950ull}; + i128 expectedRemainder = {0, 5000000ull}; + + i128 quotient = dividend / divider; + i128 reminder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(reminder, expectedRemainder); + } + + Y_UNIT_TEST(ii128DivideAlgoCheck_PosByNeg) { + /* + 49672666804009505000000 / -10000000 == -4967266680400950 + 49672666804009505000000 % -10000000 == 5000000 + */ + i128 dividend = {2692ull, 14031757583392049728ull}; + i64 divider = -10000000; + i128 expectedQuotient = -i128{0, 4967266680400950ull}; + i128 expectedRemainder = {0, 5000000ull}; + + i128 quotient = dividend / divider; + i128 reminder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(reminder, expectedRemainder); + } + + Y_UNIT_TEST(ii128DivideAlgoCheck_NegByPos) { + /* + -49672666804009505000000 / 10000000 == -4967266680400950 + -49672666804009505000000 % 10000000 == -5000000 + */ + i128 dividend = -i128{2692ull, 14031757583392049728ull}; + i64 divider = 10000000; + i128 expectedQuotient = -i128{0, 4967266680400950ull}; + i128 expectedRemainder = -i128{0, 5000000ull}; + + i128 quotient = dividend / divider; + i128 reminder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(reminder, expectedRemainder); + } + + Y_UNIT_TEST(ii128DivideAlgoCheck_NegByNeg) { + /* + -49672666804009505000000 / -10000000 == 4967266680400950 + -49672666804009505000000 % -10000000 == -5000000 + */ + i128 dividend = -i128{2692ull, 14031757583392049728ull}; + i64 divider = -10000000; + i128 expectedQuotient = {0, 4967266680400950ull}; + i128 expectedRemainder = -i128{0, 5000000ull}; + + i128 quotient = dividend / divider; + i128 reminder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(reminder, expectedRemainder); + } + +} diff --git a/library/cpp/int128/ut/i128_type_traits_ut.cpp b/library/cpp/int128/ut/i128_type_traits_ut.cpp index 4ed87bf229..87a49ad985 100644 --- a/library/cpp/int128/ut/i128_type_traits_ut.cpp +++ b/library/cpp/int128/ut/i128_type_traits_ut.cpp @@ -1,68 +1,68 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -Y_UNIT_TEST_SUITE(I128TypeTraitsSuite) { - Y_UNIT_TEST(OperatorNegate0) { - const i128 n = 0; - const i128 m = -n; - UNIT_ASSERT(n == m); - } - - Y_UNIT_TEST(OperatorNegate1) { - const i128 n = 1; - const i128 m = -n; - const i128 expected = -1; - UNIT_ASSERT(m == expected); - } - - Y_UNIT_TEST(OperatorNegate2Pow64) { - const i128 n = i128{1, 0}; - const i128 m = -n; - const i128 expected = {static_cast<ui64>(-1), 0}; - UNIT_ASSERT(m == expected); - } - - Y_UNIT_TEST(OperatorNegateNegate) { - const i128 x = 1; - const i128 y = -x; - const i128 z = -y; - UNIT_ASSERT(z == x); - } - - Y_UNIT_TEST(AbsFromPositive) { - const i128 n = 1; - const i128 m = std::abs(n); - UNIT_ASSERT(m == n); - } - - Y_UNIT_TEST(AbsFromNegative) { - const i128 n = -1; - const i128 m = std::abs(n); - const i128 expected = 1; - UNIT_ASSERT(m == expected); - } - - Y_UNIT_TEST(AbsFromZero) { - const i128 n = 0; - const i128 m = std::abs(n); - UNIT_ASSERT(m == n); - } - - Y_UNIT_TEST(SignbitOfPositive) { - const i128 n = 1; - UNIT_ASSERT(!std::signbit(n)); - } - - Y_UNIT_TEST(SignbitOfNegative) { - const i128 n = -1; - UNIT_ASSERT(std::signbit(n)); - } - - Y_UNIT_TEST(SignbitOfZero) { - const i128 n = 0; - UNIT_ASSERT(!std::signbit(n)); - } -} + +#include <util/generic/cast.h> + +Y_UNIT_TEST_SUITE(I128TypeTraitsSuite) { + Y_UNIT_TEST(OperatorNegate0) { + const i128 n = 0; + const i128 m = -n; + UNIT_ASSERT(n == m); + } + + Y_UNIT_TEST(OperatorNegate1) { + const i128 n = 1; + const i128 m = -n; + const i128 expected = -1; + UNIT_ASSERT(m == expected); + } + + Y_UNIT_TEST(OperatorNegate2Pow64) { + const i128 n = i128{1, 0}; + const i128 m = -n; + const i128 expected = {static_cast<ui64>(-1), 0}; + UNIT_ASSERT(m == expected); + } + + Y_UNIT_TEST(OperatorNegateNegate) { + const i128 x = 1; + const i128 y = -x; + const i128 z = -y; + UNIT_ASSERT(z == x); + } + + Y_UNIT_TEST(AbsFromPositive) { + const i128 n = 1; + const i128 m = std::abs(n); + UNIT_ASSERT(m == n); + } + + Y_UNIT_TEST(AbsFromNegative) { + const i128 n = -1; + const i128 m = std::abs(n); + const i128 expected = 1; + UNIT_ASSERT(m == expected); + } + + Y_UNIT_TEST(AbsFromZero) { + const i128 n = 0; + const i128 m = std::abs(n); + UNIT_ASSERT(m == n); + } + + Y_UNIT_TEST(SignbitOfPositive) { + const i128 n = 1; + UNIT_ASSERT(!std::signbit(n)); + } + + Y_UNIT_TEST(SignbitOfNegative) { + const i128 n = -1; + UNIT_ASSERT(std::signbit(n)); + } + + Y_UNIT_TEST(SignbitOfZero) { + const i128 n = 0; + UNIT_ASSERT(!std::signbit(n)); + } +} diff --git a/library/cpp/int128/ut/i128_ut.cpp b/library/cpp/int128/ut/i128_ut.cpp index c196d132a2..39408d4d37 100644 --- a/library/cpp/int128/ut/i128_ut.cpp +++ b/library/cpp/int128/ut/i128_ut.cpp @@ -1,12 +1,12 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -Y_UNIT_TEST_SUITE(I128Suite) { - Y_UNIT_TEST(CreateI128FromUnsigned) { - i128 v{ui64(1)}; - Y_UNUSED(v); - } -} + +#include <util/generic/cast.h> + +Y_UNIT_TEST_SUITE(I128Suite) { + Y_UNIT_TEST(CreateI128FromUnsigned) { + i128 v{ui64(1)}; + Y_UNUSED(v); + } +} diff --git a/library/cpp/int128/ut/int128_old_ut.cpp b/library/cpp/int128/ut/int128_old_ut.cpp index 2c5b9e9610..e8dfbff5c2 100644 --- a/library/cpp/int128/ut/int128_old_ut.cpp +++ b/library/cpp/int128/ut/int128_old_ut.cpp @@ -1,8 +1,8 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/int128/int128.h> -#include "int128_ut_helpers.h" - +#include "int128_ut_helpers.h" + class TUInt128Test: public TTestBase { UNIT_TEST_SUITE(TUInt128Test); UNIT_TEST(Create); @@ -13,9 +13,9 @@ class TUInt128Test: public TTestBase { UNIT_TEST(Underflow); UNIT_TEST(ToStringTest); UNIT_TEST(FromStringTest); -#if defined(Y_HAVE_INT128) +#if defined(Y_HAVE_INT128) UNIT_TEST(FromSystemUint128); -#endif +#endif UNIT_TEST_SUITE_END(); private: @@ -25,30 +25,30 @@ private: void Shift(); void Overflow(); void Underflow(); - void ToStringTest(); - void FromStringTest(); -#if defined(Y_HAVE_INT128) - void FromSystemUint128(); -#endif + void ToStringTest(); + void FromStringTest(); +#if defined(Y_HAVE_INT128) + void FromSystemUint128(); +#endif }; UNIT_TEST_SUITE_REGISTRATION(TUInt128Test); void TUInt128Test::Create() { - const ui128 n1 = 10; + const ui128 n1 = 10; UNIT_ASSERT_EQUAL(n1, 10); - const ui128 n2 = n1; + const ui128 n2 = n1; UNIT_ASSERT_EQUAL(n2, 10); - const ui128 n3(10); + const ui128 n3(10); UNIT_ASSERT_EQUAL(n3, 10); } void TUInt128Test::Minus() { - const ui128 n2 = 20; - const ui128 n3 = 30; + const ui128 n2 = 20; + const ui128 n3 = 30; - ui128 n4 = n3 - n2; + ui128 n4 = n3 - n2; UNIT_ASSERT_EQUAL(n4, 10); n4 = n4 - 2; @@ -61,10 +61,10 @@ void TUInt128Test::Minus() { UNIT_ASSERT_EQUAL(n4, 4); } void TUInt128Test::Plus() { - const ui128 n2 = 20; - const ui128 n3 = 30; + const ui128 n2 = 20; + const ui128 n3 = 30; - ui128 n4 = n3 + n2; + ui128 n4 = n3 + n2; UNIT_ASSERT_EQUAL(n4, 50); n4 = n4 + 2; @@ -77,103 +77,103 @@ void TUInt128Test::Plus() { UNIT_ASSERT_EQUAL(n4, 64); } void TUInt128Test::Shift() { - ui128 n = 1; + ui128 n = 1; - const ui128 n4 = n << 4; - UNIT_ASSERT_EQUAL(n4, ui128(0x0, 0x0000000000000010)); + const ui128 n4 = n << 4; + UNIT_ASSERT_EQUAL(n4, ui128(0x0, 0x0000000000000010)); UNIT_ASSERT_EQUAL(n4 >> 4, 1); - const ui128 n8 = n << 8; - UNIT_ASSERT_EQUAL(n8, ui128(0x0, 0x0000000000000100)); + const ui128 n8 = n << 8; + UNIT_ASSERT_EQUAL(n8, ui128(0x0, 0x0000000000000100)); UNIT_ASSERT_EQUAL(n8 >> 8, 1); - const ui128 n60 = n << 60; - UNIT_ASSERT_EQUAL(n60, ui128(0x0, 0x1000000000000000)); + const ui128 n60 = n << 60; + UNIT_ASSERT_EQUAL(n60, ui128(0x0, 0x1000000000000000)); UNIT_ASSERT_EQUAL(n60 >> 60, 1); - const ui128 n64 = n << 64; - UNIT_ASSERT_EQUAL(n64, ui128(0x1, 0x0000000000000000)); + const ui128 n64 = n << 64; + UNIT_ASSERT_EQUAL(n64, ui128(0x1, 0x0000000000000000)); UNIT_ASSERT_EQUAL(n64 >> 64, 1); - const ui128 n124 = n << 124; - UNIT_ASSERT_EQUAL(n124, ui128(0x1000000000000000, 0x0000000000000000)); + const ui128 n124 = n << 124; + UNIT_ASSERT_EQUAL(n124, ui128(0x1000000000000000, 0x0000000000000000)); UNIT_ASSERT_EQUAL(n124 >> 124, 1); } void TUInt128Test::Overflow() { - ui128 n = ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF); - const ui128 n2 = n + 2; + ui128 n = ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF); + const ui128 n2 = n + 2; UNIT_ASSERT_EQUAL(n2, 1); } void TUInt128Test::Underflow() { - ui128 n = 1; - const ui128 n128 = n - 2; - UNIT_ASSERT_EQUAL(n128, ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF)); -} - -void TUInt128Test::ToStringTest() { - ui128 n(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF); - TString correct = "340282366920938463463374607431768211455"; - UNIT_ASSERT_EQUAL(correct, ::ToString(n)); -} - -void TUInt128Test::FromStringTest() { - { - const TString originalString = "37778931862957161709568"; - const ui128 number = FromString<ui128>(originalString); - UNIT_ASSERT_EQUAL(ToString(number), originalString); - } - - { - const TString originalString = "1024"; - const ui128 number = FromString<ui128>(originalString); - UNIT_ASSERT_EQUAL(ToString(number), originalString); - UNIT_ASSERT_EQUAL(GetHigh(number), 0); - UNIT_ASSERT_EQUAL(GetLow(number), 1024); - } - - { - const TString originalString = "18446744073709551616"; // 2^64, i.e. UINT64_MAX + 1 - const ui128 number = FromString<ui128>(originalString); - UNIT_ASSERT_EQUAL(ToString(number), originalString); - UNIT_ASSERT_EQUAL(GetHigh(number), 1); - UNIT_ASSERT_EQUAL(GetLow(number), 0); - } - - { - const TString originalString = "340282366920938463463374607431768211455"; // 2^128-1, i.e. UINT128_MAX - const ui128 number = FromString<ui128>(originalString); - UNIT_ASSERT_EQUAL(ToString(number), originalString); - UNIT_ASSERT_EQUAL(GetHigh(number), 0xFFFFFFFFFFFFFFFF); - UNIT_ASSERT_EQUAL(GetLow(number), 0xFFFFFFFFFFFFFFFF); - } -} - -#if defined(Y_HAVE_INT128) -void TUInt128Test::FromSystemUint128() { - unsigned __int128 n = 1; - ui128 number{n}; - - UNIT_ASSERT_EQUAL(GetLow(number), 1); - UNIT_ASSERT_EQUAL(GetHigh(number), 0); - - auto byteArray = NInt128Private::GetAsArray(number); -#ifdef _little_endian_ - UNIT_ASSERT_EQUAL(byteArray[0], 1); - for (size_t i = 1; i < 16; i++) { - UNIT_ASSERT_EQUAL(byteArray[i], 0); - } -#elif defined(_big_endian_) - UNIT_ASSERT_EQUAL(byteArray[15], 1); - for (size_t i = 0; i < 15; i++) { - UNIT_ASSERT_EQUAL(byteArray[i], 0); - } -#endif - - UNIT_ASSERT_EQUAL(std::memcmp((void*)&n, (void*)&number, 16), 0); - - UNIT_ASSERT_EQUAL(ToString(n), "1"); - - UNIT_ASSERT_EQUAL(FromString<unsigned __int128>(ToString(n)), n); + ui128 n = 1; + const ui128 n128 = n - 2; + UNIT_ASSERT_EQUAL(n128, ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF)); } -#endif + +void TUInt128Test::ToStringTest() { + ui128 n(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF); + TString correct = "340282366920938463463374607431768211455"; + UNIT_ASSERT_EQUAL(correct, ::ToString(n)); +} + +void TUInt128Test::FromStringTest() { + { + const TString originalString = "37778931862957161709568"; + const ui128 number = FromString<ui128>(originalString); + UNIT_ASSERT_EQUAL(ToString(number), originalString); + } + + { + const TString originalString = "1024"; + const ui128 number = FromString<ui128>(originalString); + UNIT_ASSERT_EQUAL(ToString(number), originalString); + UNIT_ASSERT_EQUAL(GetHigh(number), 0); + UNIT_ASSERT_EQUAL(GetLow(number), 1024); + } + + { + const TString originalString = "18446744073709551616"; // 2^64, i.e. UINT64_MAX + 1 + const ui128 number = FromString<ui128>(originalString); + UNIT_ASSERT_EQUAL(ToString(number), originalString); + UNIT_ASSERT_EQUAL(GetHigh(number), 1); + UNIT_ASSERT_EQUAL(GetLow(number), 0); + } + + { + const TString originalString = "340282366920938463463374607431768211455"; // 2^128-1, i.e. UINT128_MAX + const ui128 number = FromString<ui128>(originalString); + UNIT_ASSERT_EQUAL(ToString(number), originalString); + UNIT_ASSERT_EQUAL(GetHigh(number), 0xFFFFFFFFFFFFFFFF); + UNIT_ASSERT_EQUAL(GetLow(number), 0xFFFFFFFFFFFFFFFF); + } +} + +#if defined(Y_HAVE_INT128) +void TUInt128Test::FromSystemUint128() { + unsigned __int128 n = 1; + ui128 number{n}; + + UNIT_ASSERT_EQUAL(GetLow(number), 1); + UNIT_ASSERT_EQUAL(GetHigh(number), 0); + + auto byteArray = NInt128Private::GetAsArray(number); +#ifdef _little_endian_ + UNIT_ASSERT_EQUAL(byteArray[0], 1); + for (size_t i = 1; i < 16; i++) { + UNIT_ASSERT_EQUAL(byteArray[i], 0); + } +#elif defined(_big_endian_) + UNIT_ASSERT_EQUAL(byteArray[15], 1); + for (size_t i = 0; i < 15; i++) { + UNIT_ASSERT_EQUAL(byteArray[i], 0); + } +#endif + + UNIT_ASSERT_EQUAL(std::memcmp((void*)&n, (void*)&number, 16), 0); + + UNIT_ASSERT_EQUAL(ToString(n), "1"); + + UNIT_ASSERT_EQUAL(FromString<unsigned __int128>(ToString(n)), n); +} +#endif diff --git a/library/cpp/int128/ut/int128_typetraits_ut.cpp b/library/cpp/int128/ut/int128_typetraits_ut.cpp index fd5f19d7b8..32be581dd0 100644 --- a/library/cpp/int128/ut/int128_typetraits_ut.cpp +++ b/library/cpp/int128/ut/int128_typetraits_ut.cpp @@ -1,306 +1,306 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <type_traits> - -Y_UNIT_TEST_SUITE(TypeTraitsSuite) { - Y_UNIT_TEST(Uint128TypeTraits) { - // checks that all type traits of ui128 are the same as of ui64 - // https://en.cppreference.com/w/cpp/header/type_traits - UNIT_ASSERT_EQUAL( - std::is_void<ui128>::value, - std::is_void<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_null_pointer<ui128>::value, - std::is_null_pointer<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_integral<ui128>::value, - std::is_integral<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_floating_point<ui128>::value, - std::is_floating_point<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_array<ui128>::value, - std::is_array<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_enum<ui128>::value, - std::is_enum<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_union<ui128>::value, - std::is_union<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_class<ui128>::value, - std::is_class<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_function<ui128>::value, - std::is_function<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_pointer<ui128>::value, - std::is_pointer<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_lvalue_reference<ui128>::value, - std::is_lvalue_reference<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_rvalue_reference<ui128>::value, - std::is_rvalue_reference<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_object_pointer<ui128>::value, - std::is_member_object_pointer<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_function_pointer<ui128>::value, - std::is_member_function_pointer<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_fundamental<ui128>::value, - std::is_fundamental<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_arithmetic<ui128>::value, - std::is_arithmetic<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_scalar<ui128>::value, - std::is_scalar<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_object<ui128>::value, - std::is_object<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_compound<ui128>::value, - std::is_compound<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_reference<ui128>::value, - std::is_reference<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_pointer<ui128>::value, - std::is_member_pointer<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_const<ui128>::value, - std::is_const<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_volatile<ui128>::value, - std::is_volatile<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_trivial<ui128>::value, - std::is_trivial<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_standard_layout<ui128>::value, - std::is_standard_layout<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_pod<ui128>::value, - std::is_pod<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_literal_type<ui128>::value, - std::is_literal_type<ui64>::value - ); -#ifndef _MSC_VER - UNIT_ASSERT_EQUAL( - std::has_unique_object_representations<ui128>::value, - std::has_unique_object_representations<ui64>::value - ); -#endif - UNIT_ASSERT_EQUAL( - std::is_empty<ui128>::value, - std::is_empty<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_polymorphic<ui128>::value, - std::is_polymorphic<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_abstract<ui128>::value, - std::is_abstract<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_final<ui128>::value, - std::is_final<ui64>::value - ); -#ifndef _MSC_VER - UNIT_ASSERT_EQUAL( - std::is_aggregate<ui128>::value, - std::is_aggregate<ui64>::value - ); -#endif - UNIT_ASSERT_EQUAL( - std::is_signed<ui128>::value, - std::is_signed<ui64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_unsigned<ui128>::value, - std::is_unsigned<ui64>::value - ); - } - - Y_UNIT_TEST(Int128TypeTraits) { - // checks that all type traits of i128 are the same as of i64 - // https://en.cppreference.com/w/cpp/header/type_traits - UNIT_ASSERT_EQUAL( - std::is_void<i128>::value, - std::is_void<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_null_pointer<i128>::value, - std::is_null_pointer<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_integral<i128>::value, - std::is_integral<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_floating_point<i128>::value, - std::is_floating_point<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_array<i128>::value, - std::is_array<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_enum<i128>::value, - std::is_enum<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_union<i128>::value, - std::is_union<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_class<i128>::value, - std::is_class<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_function<i128>::value, - std::is_function<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_pointer<i128>::value, - std::is_pointer<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_lvalue_reference<i128>::value, - std::is_lvalue_reference<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_rvalue_reference<i128>::value, - std::is_rvalue_reference<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_object_pointer<i128>::value, - std::is_member_object_pointer<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_function_pointer<i128>::value, - std::is_member_function_pointer<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_fundamental<i128>::value, - std::is_fundamental<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_arithmetic<i128>::value, - std::is_arithmetic<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_scalar<i128>::value, - std::is_scalar<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_object<i128>::value, - std::is_object<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_compound<i128>::value, - std::is_compound<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_reference<i128>::value, - std::is_reference<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_member_pointer<i128>::value, - std::is_member_pointer<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_const<i128>::value, - std::is_const<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_volatile<i128>::value, - std::is_volatile<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_trivial<i128>::value, - std::is_trivial<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_standard_layout<i128>::value, - std::is_standard_layout<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_pod<i128>::value, - std::is_pod<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_literal_type<i128>::value, - std::is_literal_type<i64>::value - ); -#ifndef _MSC_VER - UNIT_ASSERT_EQUAL( - std::has_unique_object_representations<i128>::value, - std::has_unique_object_representations<i64>::value - ); -#endif - UNIT_ASSERT_EQUAL( - std::is_empty<i128>::value, - std::is_empty<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_polymorphic<i128>::value, - std::is_polymorphic<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_abstract<i128>::value, - std::is_abstract<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_final<i128>::value, - std::is_final<i64>::value - ); -#ifndef _MSC_VER - UNIT_ASSERT_EQUAL( - std::is_aggregate<i128>::value, - std::is_aggregate<i64>::value - ); -#endif - UNIT_ASSERT_EQUAL( - std::is_signed<i128>::value, - std::is_signed<i64>::value - ); - UNIT_ASSERT_EQUAL( - std::is_unsigned<i128>::value, - std::is_unsigned<i64>::value - ); - } -} - + +#include <type_traits> + +Y_UNIT_TEST_SUITE(TypeTraitsSuite) { + Y_UNIT_TEST(Uint128TypeTraits) { + // checks that all type traits of ui128 are the same as of ui64 + // https://en.cppreference.com/w/cpp/header/type_traits + UNIT_ASSERT_EQUAL( + std::is_void<ui128>::value, + std::is_void<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_null_pointer<ui128>::value, + std::is_null_pointer<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_integral<ui128>::value, + std::is_integral<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_floating_point<ui128>::value, + std::is_floating_point<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_array<ui128>::value, + std::is_array<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_enum<ui128>::value, + std::is_enum<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_union<ui128>::value, + std::is_union<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_class<ui128>::value, + std::is_class<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_function<ui128>::value, + std::is_function<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_pointer<ui128>::value, + std::is_pointer<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_lvalue_reference<ui128>::value, + std::is_lvalue_reference<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_rvalue_reference<ui128>::value, + std::is_rvalue_reference<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_object_pointer<ui128>::value, + std::is_member_object_pointer<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_function_pointer<ui128>::value, + std::is_member_function_pointer<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_fundamental<ui128>::value, + std::is_fundamental<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_arithmetic<ui128>::value, + std::is_arithmetic<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_scalar<ui128>::value, + std::is_scalar<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_object<ui128>::value, + std::is_object<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_compound<ui128>::value, + std::is_compound<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_reference<ui128>::value, + std::is_reference<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_pointer<ui128>::value, + std::is_member_pointer<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_const<ui128>::value, + std::is_const<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_volatile<ui128>::value, + std::is_volatile<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_trivial<ui128>::value, + std::is_trivial<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_standard_layout<ui128>::value, + std::is_standard_layout<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_pod<ui128>::value, + std::is_pod<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_literal_type<ui128>::value, + std::is_literal_type<ui64>::value + ); +#ifndef _MSC_VER + UNIT_ASSERT_EQUAL( + std::has_unique_object_representations<ui128>::value, + std::has_unique_object_representations<ui64>::value + ); +#endif + UNIT_ASSERT_EQUAL( + std::is_empty<ui128>::value, + std::is_empty<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_polymorphic<ui128>::value, + std::is_polymorphic<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_abstract<ui128>::value, + std::is_abstract<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_final<ui128>::value, + std::is_final<ui64>::value + ); +#ifndef _MSC_VER + UNIT_ASSERT_EQUAL( + std::is_aggregate<ui128>::value, + std::is_aggregate<ui64>::value + ); +#endif + UNIT_ASSERT_EQUAL( + std::is_signed<ui128>::value, + std::is_signed<ui64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_unsigned<ui128>::value, + std::is_unsigned<ui64>::value + ); + } + + Y_UNIT_TEST(Int128TypeTraits) { + // checks that all type traits of i128 are the same as of i64 + // https://en.cppreference.com/w/cpp/header/type_traits + UNIT_ASSERT_EQUAL( + std::is_void<i128>::value, + std::is_void<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_null_pointer<i128>::value, + std::is_null_pointer<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_integral<i128>::value, + std::is_integral<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_floating_point<i128>::value, + std::is_floating_point<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_array<i128>::value, + std::is_array<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_enum<i128>::value, + std::is_enum<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_union<i128>::value, + std::is_union<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_class<i128>::value, + std::is_class<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_function<i128>::value, + std::is_function<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_pointer<i128>::value, + std::is_pointer<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_lvalue_reference<i128>::value, + std::is_lvalue_reference<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_rvalue_reference<i128>::value, + std::is_rvalue_reference<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_object_pointer<i128>::value, + std::is_member_object_pointer<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_function_pointer<i128>::value, + std::is_member_function_pointer<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_fundamental<i128>::value, + std::is_fundamental<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_arithmetic<i128>::value, + std::is_arithmetic<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_scalar<i128>::value, + std::is_scalar<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_object<i128>::value, + std::is_object<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_compound<i128>::value, + std::is_compound<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_reference<i128>::value, + std::is_reference<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_member_pointer<i128>::value, + std::is_member_pointer<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_const<i128>::value, + std::is_const<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_volatile<i128>::value, + std::is_volatile<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_trivial<i128>::value, + std::is_trivial<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_standard_layout<i128>::value, + std::is_standard_layout<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_pod<i128>::value, + std::is_pod<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_literal_type<i128>::value, + std::is_literal_type<i64>::value + ); +#ifndef _MSC_VER + UNIT_ASSERT_EQUAL( + std::has_unique_object_representations<i128>::value, + std::has_unique_object_representations<i64>::value + ); +#endif + UNIT_ASSERT_EQUAL( + std::is_empty<i128>::value, + std::is_empty<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_polymorphic<i128>::value, + std::is_polymorphic<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_abstract<i128>::value, + std::is_abstract<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_final<i128>::value, + std::is_final<i64>::value + ); +#ifndef _MSC_VER + UNIT_ASSERT_EQUAL( + std::is_aggregate<i128>::value, + std::is_aggregate<i64>::value + ); +#endif + UNIT_ASSERT_EQUAL( + std::is_signed<i128>::value, + std::is_signed<i64>::value + ); + UNIT_ASSERT_EQUAL( + std::is_unsigned<i128>::value, + std::is_unsigned<i64>::value + ); + } +} + diff --git a/library/cpp/int128/ut/int128_ut.cpp b/library/cpp/int128/ut/int128_ut.cpp index 7339264017..0d68e42100 100644 --- a/library/cpp/int128/ut/int128_ut.cpp +++ b/library/cpp/int128/ut/int128_ut.cpp @@ -1,56 +1,56 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -#include <type_traits> - -Y_UNIT_TEST_SUITE(Uint128Suite) { - Y_UNIT_TEST(Uint128DefaultCtor) { - const ui128 value{}; - UNIT_ASSERT_EQUAL(GetLow(value), 0); - UNIT_ASSERT_EQUAL(GetHigh(value), 0); - } - - Y_UNIT_TEST(Uint128NumericLimits) { - UNIT_ASSERT_EQUAL(std::numeric_limits<ui128>::digits, 128); - UNIT_ASSERT_EQUAL(std::numeric_limits<ui128>::max() + 1, ui128{0}); - } - - Y_UNIT_TEST(Uint128Sizeof) { - UNIT_ASSERT_EQUAL(sizeof(ui128), sizeof(ui64) * 2); - } - - Y_UNIT_TEST(Uint128Cast) { - // see util/generic/cast.h - const auto underlyingTypeIsSelf = std::is_same<::NPrivate::TUnderlyingTypeOrSelf<ui128>, ui128>::value; - UNIT_ASSERT_EQUAL(underlyingTypeIsSelf, true); - - const auto convertibleUi128Ui128 = ::NPrivate::TSafelyConvertible<ui128, ui128>::Result; - const auto convertibleUi64Ui128 = ::NPrivate::TSafelyConvertible<ui64, ui128>::Result; - const auto convertibleUi128Ui64 = ::NPrivate::TSafelyConvertible<ui128, ui64>::Result; - UNIT_ASSERT_EQUAL(convertibleUi128Ui128, true); // from ui128 to ui128 => safe - UNIT_ASSERT_EQUAL(convertibleUi64Ui128, false); // from ui128 to ui64 => not safe - UNIT_ASSERT_EQUAL(convertibleUi128Ui64, true); // from ui64 to ui128 => safe - } - - Y_UNIT_TEST(SafeIntegerCastTest) { - ui128 narrowNumber = 1; - - UNIT_ASSERT_NO_EXCEPTION(SafeIntegerCast<ui64>(narrowNumber)); - - ui128 wideNumber{0}; - wideNumber -= 1; - UNIT_ASSERT_EXCEPTION(SafeIntegerCast<ui64>(wideNumber), yexception); - } - - Y_UNIT_TEST(SignbitTest) { - UNIT_ASSERT(!std::signbit(ui128{0})); - UNIT_ASSERT(!std::signbit(ui128{-1})); - UNIT_ASSERT(!std::signbit(i128{0})); - UNIT_ASSERT(std::signbit(i128{-1})); - } + +#include <util/generic/cast.h> + +#include <type_traits> + +Y_UNIT_TEST_SUITE(Uint128Suite) { + Y_UNIT_TEST(Uint128DefaultCtor) { + const ui128 value{}; + UNIT_ASSERT_EQUAL(GetLow(value), 0); + UNIT_ASSERT_EQUAL(GetHigh(value), 0); + } + + Y_UNIT_TEST(Uint128NumericLimits) { + UNIT_ASSERT_EQUAL(std::numeric_limits<ui128>::digits, 128); + UNIT_ASSERT_EQUAL(std::numeric_limits<ui128>::max() + 1, ui128{0}); + } + + Y_UNIT_TEST(Uint128Sizeof) { + UNIT_ASSERT_EQUAL(sizeof(ui128), sizeof(ui64) * 2); + } + + Y_UNIT_TEST(Uint128Cast) { + // see util/generic/cast.h + const auto underlyingTypeIsSelf = std::is_same<::NPrivate::TUnderlyingTypeOrSelf<ui128>, ui128>::value; + UNIT_ASSERT_EQUAL(underlyingTypeIsSelf, true); + + const auto convertibleUi128Ui128 = ::NPrivate::TSafelyConvertible<ui128, ui128>::Result; + const auto convertibleUi64Ui128 = ::NPrivate::TSafelyConvertible<ui64, ui128>::Result; + const auto convertibleUi128Ui64 = ::NPrivate::TSafelyConvertible<ui128, ui64>::Result; + UNIT_ASSERT_EQUAL(convertibleUi128Ui128, true); // from ui128 to ui128 => safe + UNIT_ASSERT_EQUAL(convertibleUi64Ui128, false); // from ui128 to ui64 => not safe + UNIT_ASSERT_EQUAL(convertibleUi128Ui64, true); // from ui64 to ui128 => safe + } + + Y_UNIT_TEST(SafeIntegerCastTest) { + ui128 narrowNumber = 1; + + UNIT_ASSERT_NO_EXCEPTION(SafeIntegerCast<ui64>(narrowNumber)); + + ui128 wideNumber{0}; + wideNumber -= 1; + UNIT_ASSERT_EXCEPTION(SafeIntegerCast<ui64>(wideNumber), yexception); + } + + Y_UNIT_TEST(SignbitTest) { + UNIT_ASSERT(!std::signbit(ui128{0})); + UNIT_ASSERT(!std::signbit(ui128{-1})); + UNIT_ASSERT(!std::signbit(i128{0})); + UNIT_ASSERT(std::signbit(i128{-1})); + } Y_UNIT_TEST(ToStringTest) { // int128 @@ -80,4 +80,4 @@ Y_UNIT_TEST_SUITE(Uint128Suite) { ), "235108557486403940296800289353599800327"); } -} +} diff --git a/library/cpp/int128/ut/int128_ut_helpers.cpp b/library/cpp/int128/ut/int128_ut_helpers.cpp index e6c3e24d10..cb712f869a 100644 --- a/library/cpp/int128/ut/int128_ut_helpers.cpp +++ b/library/cpp/int128/ut/int128_ut_helpers.cpp @@ -1,56 +1,56 @@ -#include "int128_ut_helpers.h" - -namespace NInt128Private { -#if defined(_little_endian_) - std::array<ui8, 16> GetAsArray(const ui128 value) { - std::array<ui8, 16> result; - const ui64 low = GetLow(value); - const ui64 high = GetHigh(value); - MemCopy(result.data(), reinterpret_cast<const ui8*>(&low), sizeof(low)); - MemCopy(result.data() + sizeof(low), reinterpret_cast<const ui8*>(&high), sizeof(high)); - return result; - } - - std::array<ui8, 16> GetAsArray(const i128 value) { - std::array<ui8, 16> result; - const ui64 low = GetLow(value); - const ui64 high = GetHigh(value); - MemCopy(result.data(), reinterpret_cast<const ui8*>(&low), sizeof(low)); - MemCopy(result.data() + sizeof(low), reinterpret_cast<const ui8*>(&high), sizeof(high)); - return result; - } -#elif defined(_big_endian_) - std::array<ui8, 16> GetAsArray(const i128 value) { - std::array<ui8, 16> result; - const ui64 low = GetLow(value); - const ui64 high = GetHigh(value); - MemCopy(result.data(), reinterpret_cast<const ui8*>(&high), sizeof(high)); - MemCopy(result.data() + sizeof(high), reinterpret_cast<const ui8*>(&low), sizeof(low)); - return result; - } - - std::array<ui8, 16> GetAsArray(const ui128 value) { - std::array<ui8, 16> result; - const ui64 low = GetLow(value); - const ui64 high = GetHigh(value); - MemCopy(result.data(), reinterpret_cast<const ui8*>(&high), sizeof(high)); - MemCopy(result.data() + sizeof(high), reinterpret_cast<const ui8*>(&low), sizeof(low)); - return result; - } -#endif - -#if defined(Y_HAVE_INT128) - std::array<ui8, 16> GetAsArray(const unsigned __int128 value) { - std::array<ui8, 16> result; - MemCopy(result.data(), reinterpret_cast<const ui8*>(&value), sizeof(value)); - return result; - } - - std::array<ui8, 16> GetAsArray(const signed __int128 value) { - std::array<ui8, 16> result; - MemCopy(result.data(), reinterpret_cast<const ui8*>(&value), sizeof(value)); - return result; - } -#endif - -} +#include "int128_ut_helpers.h" + +namespace NInt128Private { +#if defined(_little_endian_) + std::array<ui8, 16> GetAsArray(const ui128 value) { + std::array<ui8, 16> result; + const ui64 low = GetLow(value); + const ui64 high = GetHigh(value); + MemCopy(result.data(), reinterpret_cast<const ui8*>(&low), sizeof(low)); + MemCopy(result.data() + sizeof(low), reinterpret_cast<const ui8*>(&high), sizeof(high)); + return result; + } + + std::array<ui8, 16> GetAsArray(const i128 value) { + std::array<ui8, 16> result; + const ui64 low = GetLow(value); + const ui64 high = GetHigh(value); + MemCopy(result.data(), reinterpret_cast<const ui8*>(&low), sizeof(low)); + MemCopy(result.data() + sizeof(low), reinterpret_cast<const ui8*>(&high), sizeof(high)); + return result; + } +#elif defined(_big_endian_) + std::array<ui8, 16> GetAsArray(const i128 value) { + std::array<ui8, 16> result; + const ui64 low = GetLow(value); + const ui64 high = GetHigh(value); + MemCopy(result.data(), reinterpret_cast<const ui8*>(&high), sizeof(high)); + MemCopy(result.data() + sizeof(high), reinterpret_cast<const ui8*>(&low), sizeof(low)); + return result; + } + + std::array<ui8, 16> GetAsArray(const ui128 value) { + std::array<ui8, 16> result; + const ui64 low = GetLow(value); + const ui64 high = GetHigh(value); + MemCopy(result.data(), reinterpret_cast<const ui8*>(&high), sizeof(high)); + MemCopy(result.data() + sizeof(high), reinterpret_cast<const ui8*>(&low), sizeof(low)); + return result; + } +#endif + +#if defined(Y_HAVE_INT128) + std::array<ui8, 16> GetAsArray(const unsigned __int128 value) { + std::array<ui8, 16> result; + MemCopy(result.data(), reinterpret_cast<const ui8*>(&value), sizeof(value)); + return result; + } + + std::array<ui8, 16> GetAsArray(const signed __int128 value) { + std::array<ui8, 16> result; + MemCopy(result.data(), reinterpret_cast<const ui8*>(&value), sizeof(value)); + return result; + } +#endif + +} diff --git a/library/cpp/int128/ut/int128_ut_helpers.h b/library/cpp/int128/ut/int128_ut_helpers.h index b7778c3f32..99a8fa7436 100644 --- a/library/cpp/int128/ut/int128_ut_helpers.h +++ b/library/cpp/int128/ut/int128_ut_helpers.h @@ -1,15 +1,15 @@ -#pragma once - +#pragma once + #include <library/cpp/int128/int128.h> - -#include <array> - -namespace NInt128Private { - std::array<ui8, 16> GetAsArray(const ui128 value); - std::array<ui8, 16> GetAsArray(const i128 value); - -#if defined(Y_HAVE_INT128) - std::array<ui8, 16> GetAsArray(const unsigned __int128 value); - std::array<ui8, 16> GetAsArray(const signed __int128 value); -#endif -} + +#include <array> + +namespace NInt128Private { + std::array<ui8, 16> GetAsArray(const ui128 value); + std::array<ui8, 16> GetAsArray(const i128 value); + +#if defined(Y_HAVE_INT128) + std::array<ui8, 16> GetAsArray(const unsigned __int128 value); + std::array<ui8, 16> GetAsArray(const signed __int128 value); +#endif +} diff --git a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp index 9decc2fd48..e1eff5fcb3 100644 --- a/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp +++ b/library/cpp/int128/ut/int128_via_intrinsic_ut.cpp @@ -2,33 +2,33 @@ #include <library/cpp/testing/unittest/registar.h> -// from https://a.yandex-team.ru/arc/trunk/arcadia/library/ticket_parser/c/src/ut/utils_ut.cpp?rev=4221861 +// from https://a.yandex-team.ru/arc/trunk/arcadia/library/ticket_parser/c/src/ut/utils_ut.cpp?rev=4221861 -#if defined(Y_HAVE_INT128) -Y_UNIT_TEST_SUITE(Int128ViaIntrinsicSuite) { +#if defined(Y_HAVE_INT128) +Y_UNIT_TEST_SUITE(Int128ViaIntrinsicSuite) { using guint128_t = unsigned __int128; - guint128_t toGcc(ui128 num) { + guint128_t toGcc(ui128 num) { guint128_t res = 0; - res |= GetLow(num); - res |= guint128_t(GetHigh(num)) << 64; + res |= GetLow(num); + res |= guint128_t(GetHigh(num)) << 64; return res; } Y_UNIT_TEST(bigintTest) { - UNIT_ASSERT(guint128_t(127) == toGcc(ui128(127))); - UNIT_ASSERT(guint128_t(127) * guint128_t(127) == toGcc(ui128(127) * ui128(127))); - UNIT_ASSERT(guint128_t(127) + guint128_t(127) == toGcc(ui128(127) + ui128(127))); - UNIT_ASSERT(guint128_t(127) << 3 == toGcc(ui128(127) << 3)); - UNIT_ASSERT(guint128_t(127) >> 1 == toGcc(ui128(127) >> 1)); + UNIT_ASSERT(guint128_t(127) == toGcc(ui128(127))); + UNIT_ASSERT(guint128_t(127) * guint128_t(127) == toGcc(ui128(127) * ui128(127))); + UNIT_ASSERT(guint128_t(127) + guint128_t(127) == toGcc(ui128(127) + ui128(127))); + UNIT_ASSERT(guint128_t(127) << 3 == toGcc(ui128(127) << 3)); + UNIT_ASSERT(guint128_t(127) >> 1 == toGcc(ui128(127) >> 1)); - UNIT_ASSERT(guint128_t(1000000000027UL) * guint128_t(1000000000027UL) == toGcc(ui128(1000000000027UL) * ui128(1000000000027UL))); - UNIT_ASSERT(guint128_t(1000000000027UL) + guint128_t(1000000000027UL) == toGcc(ui128(1000000000027UL) + ui128(1000000000027UL))); - UNIT_ASSERT(guint128_t(1000000000027UL) << 3 == toGcc(ui128(1000000000027UL) << 3)); - UNIT_ASSERT(guint128_t(1000000000027UL) >> 1 == toGcc(ui128(1000000000027UL) >> 1)); - UNIT_ASSERT((guint128_t(1000000000027UL) * guint128_t(1000000000027UL)) << 3 == toGcc((ui128(1000000000027UL) * ui128(1000000000027UL)) << 3)); - UNIT_ASSERT((guint128_t(1000000000027UL) + guint128_t(1000000000027UL)) >> 1 == toGcc((ui128(1000000000027UL) + ui128(1000000000027UL)) >> 1)); + UNIT_ASSERT(guint128_t(1000000000027UL) * guint128_t(1000000000027UL) == toGcc(ui128(1000000000027UL) * ui128(1000000000027UL))); + UNIT_ASSERT(guint128_t(1000000000027UL) + guint128_t(1000000000027UL) == toGcc(ui128(1000000000027UL) + ui128(1000000000027UL))); + UNIT_ASSERT(guint128_t(1000000000027UL) << 3 == toGcc(ui128(1000000000027UL) << 3)); + UNIT_ASSERT(guint128_t(1000000000027UL) >> 1 == toGcc(ui128(1000000000027UL) >> 1)); + UNIT_ASSERT((guint128_t(1000000000027UL) * guint128_t(1000000000027UL)) << 3 == toGcc((ui128(1000000000027UL) * ui128(1000000000027UL)) << 3)); + UNIT_ASSERT((guint128_t(1000000000027UL) + guint128_t(1000000000027UL)) >> 1 == toGcc((ui128(1000000000027UL) + ui128(1000000000027UL)) >> 1)); - UNIT_ASSERT((ui64)(guint128_t(1000000000027UL) * guint128_t(1000000000027UL)) == GetLow(ui128(1000000000027UL) * ui128(1000000000027UL))); + UNIT_ASSERT((ui64)(guint128_t(1000000000027UL) * guint128_t(1000000000027UL)) == GetLow(ui128(1000000000027UL) * ui128(1000000000027UL))); } } -#endif +#endif diff --git a/library/cpp/int128/ut/ui128_division_ut.cpp b/library/cpp/int128/ut/ui128_division_ut.cpp index 4826a531e0..488738d429 100644 --- a/library/cpp/int128/ut/ui128_division_ut.cpp +++ b/library/cpp/int128/ut/ui128_division_ut.cpp @@ -1,262 +1,262 @@ #include <library/cpp/testing/unittest/registar.h> - + #include <library/cpp/int128/int128.h> - -#include <util/generic/cast.h> - -Y_UNIT_TEST_SUITE(Ui128DivisionBy1Suite) { - Y_UNIT_TEST(Ui128Divide0By1) { - ui128 dividend = 0; - ui128 divider = 1; - ui128 expectedQuotient = 0; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide1By1) { - ui128 dividend = 1; - ui128 divider = 1; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide2By1) { - ui128 dividend = 2; - ui128 divider = 1; - ui128 expectedQuotient = 2; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide42By1) { - ui128 dividend = 42; - ui128 divider = 1; - ui128 expectedQuotient = 42; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64By1) { - ui128 dividend = std::numeric_limits<ui64>::max(); - ui128 divider = 1; - ui128 expectedQuotient = std::numeric_limits<ui64>::max(); - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64Plus1By1) { - ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; - ui128 divider = 1; - ui128 expectedQuotient = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64Plus42By1) { - ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; - ui128 divider = 1; - ui128 expectedQuotient = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi128By1) { - ui128 dividend = std::numeric_limits<ui128>::max(); - ui128 divider = 1; - ui128 expectedQuotient = std::numeric_limits<ui128>::max(); - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi128Minus1By1) { - ui128 dividend = std::numeric_limits<ui128>::max() - 1; - ui128 divider = 1; - ui128 expectedQuotient = std::numeric_limits<ui128>::max() - 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(Ui128DivisionByEqualSuite) { - Y_UNIT_TEST(Ui128Divide1ByEqual) { - ui128 dividend = 1; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide2ByEqual) { - ui128 dividend = 2; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide42ByEqual) { - ui128 dividend = 42; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64ByEqual) { - ui128 dividend = std::numeric_limits<ui64>::max(); - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64Plus1ByEqual) { - ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64Plus42ByEqual) { - ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi128ByEqual) { - ui128 dividend = std::numeric_limits<ui128>::max(); - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi128Minus1ByEqual) { - ui128 dividend = std::numeric_limits<ui128>::max() - 1; - ui128 divider = dividend; - ui128 expectedQuotient = 1; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(Ui128DivisionLessByHigherSuite) { - Y_UNIT_TEST(Ui128Divide42By84) { - ui128 dividend = 42; - ui128 divider = 84; - ui128 expectedQuotient = 0; - ui128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide42ByMaxUi64) { - ui128 dividend = 42; - ui128 divider = std::numeric_limits<ui64>::max(); - ui128 expectedQuotient = 0; - ui128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128Divide42ByMaxUi64Plus1) { - ui128 dividend = 42; - ui128 divider = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; - ui128 expectedQuotient = 0; - ui128 expectedRemainder = 42; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideMaxUi64ByMaxUi64Plus1) { - ui128 dividend = ui128{std::numeric_limits<ui64>::max()}; - ui128 divider = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; - ui128 expectedQuotient = 0; - ui128 expectedRemainder = ui128{std::numeric_limits<ui64>::max()}; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(Ui128DivisionBigByBigSuite) { - Y_UNIT_TEST(Ui128DivideBigByBig1) { - ui128 dividend = {64, 0}; - ui128 divider = {1, 0}; - ui128 expectedQuotient = 64; - ui128 expectedRemainder = 0; - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } - - Y_UNIT_TEST(Ui128DivideBigByBig2) { - ui128 dividend = {64, 0}; - ui128 divider = {12, 5}; - ui128 expectedQuotient = 5; - ui128 expectedRemainder = ui128{3, 18446744073709551591ull}; // plz don't ask - - UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); - UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); - } -} - -Y_UNIT_TEST_SUITE(Ui128DivisionAlgo) { - Y_UNIT_TEST(Ui128DivideAlgoCheck) { - /* - 49672666804009505000000 / 10000000 == 4967266680400950 - 49672666804009505000000 % 10000000 == 5000000 - */ - ui128 dividend = {2692ull, 14031757583392049728ull}; - ui64 divider = 10000000; - ui128 expectedQuotient = {0, 4967266680400950ull}; - ui128 expectedRemainder = {0, 5000000ull}; - - ui128 quotient = dividend / divider; - ui128 reminder = dividend % divider; - - UNIT_ASSERT_EQUAL(quotient, expectedQuotient); - UNIT_ASSERT_EQUAL(reminder, expectedRemainder); - } -} + +#include <util/generic/cast.h> + +Y_UNIT_TEST_SUITE(Ui128DivisionBy1Suite) { + Y_UNIT_TEST(Ui128Divide0By1) { + ui128 dividend = 0; + ui128 divider = 1; + ui128 expectedQuotient = 0; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide1By1) { + ui128 dividend = 1; + ui128 divider = 1; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide2By1) { + ui128 dividend = 2; + ui128 divider = 1; + ui128 expectedQuotient = 2; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide42By1) { + ui128 dividend = 42; + ui128 divider = 1; + ui128 expectedQuotient = 42; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64By1) { + ui128 dividend = std::numeric_limits<ui64>::max(); + ui128 divider = 1; + ui128 expectedQuotient = std::numeric_limits<ui64>::max(); + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64Plus1By1) { + ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; + ui128 divider = 1; + ui128 expectedQuotient = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64Plus42By1) { + ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; + ui128 divider = 1; + ui128 expectedQuotient = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi128By1) { + ui128 dividend = std::numeric_limits<ui128>::max(); + ui128 divider = 1; + ui128 expectedQuotient = std::numeric_limits<ui128>::max(); + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi128Minus1By1) { + ui128 dividend = std::numeric_limits<ui128>::max() - 1; + ui128 divider = 1; + ui128 expectedQuotient = std::numeric_limits<ui128>::max() - 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(Ui128DivisionByEqualSuite) { + Y_UNIT_TEST(Ui128Divide1ByEqual) { + ui128 dividend = 1; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide2ByEqual) { + ui128 dividend = 2; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide42ByEqual) { + ui128 dividend = 42; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64ByEqual) { + ui128 dividend = std::numeric_limits<ui64>::max(); + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64Plus1ByEqual) { + ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64Plus42ByEqual) { + ui128 dividend = ui128{std::numeric_limits<ui64>::max()} + ui128{42}; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi128ByEqual) { + ui128 dividend = std::numeric_limits<ui128>::max(); + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi128Minus1ByEqual) { + ui128 dividend = std::numeric_limits<ui128>::max() - 1; + ui128 divider = dividend; + ui128 expectedQuotient = 1; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(Ui128DivisionLessByHigherSuite) { + Y_UNIT_TEST(Ui128Divide42By84) { + ui128 dividend = 42; + ui128 divider = 84; + ui128 expectedQuotient = 0; + ui128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide42ByMaxUi64) { + ui128 dividend = 42; + ui128 divider = std::numeric_limits<ui64>::max(); + ui128 expectedQuotient = 0; + ui128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128Divide42ByMaxUi64Plus1) { + ui128 dividend = 42; + ui128 divider = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; + ui128 expectedQuotient = 0; + ui128 expectedRemainder = 42; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideMaxUi64ByMaxUi64Plus1) { + ui128 dividend = ui128{std::numeric_limits<ui64>::max()}; + ui128 divider = ui128{std::numeric_limits<ui64>::max()} + ui128{1}; + ui128 expectedQuotient = 0; + ui128 expectedRemainder = ui128{std::numeric_limits<ui64>::max()}; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(Ui128DivisionBigByBigSuite) { + Y_UNIT_TEST(Ui128DivideBigByBig1) { + ui128 dividend = {64, 0}; + ui128 divider = {1, 0}; + ui128 expectedQuotient = 64; + ui128 expectedRemainder = 0; + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } + + Y_UNIT_TEST(Ui128DivideBigByBig2) { + ui128 dividend = {64, 0}; + ui128 divider = {12, 5}; + ui128 expectedQuotient = 5; + ui128 expectedRemainder = ui128{3, 18446744073709551591ull}; // plz don't ask + + UNIT_ASSERT_EQUAL(dividend / divider, expectedQuotient); + UNIT_ASSERT_EQUAL(dividend % divider, expectedRemainder); + } +} + +Y_UNIT_TEST_SUITE(Ui128DivisionAlgo) { + Y_UNIT_TEST(Ui128DivideAlgoCheck) { + /* + 49672666804009505000000 / 10000000 == 4967266680400950 + 49672666804009505000000 % 10000000 == 5000000 + */ + ui128 dividend = {2692ull, 14031757583392049728ull}; + ui64 divider = 10000000; + ui128 expectedQuotient = {0, 4967266680400950ull}; + ui128 expectedRemainder = {0, 5000000ull}; + + ui128 quotient = dividend / divider; + ui128 reminder = dividend % divider; + + UNIT_ASSERT_EQUAL(quotient, expectedQuotient); + UNIT_ASSERT_EQUAL(reminder, expectedRemainder); + } +} diff --git a/library/cpp/int128/ut/ya.make b/library/cpp/int128/ut/ya.make index fd43531c5f..63211431bc 100644 --- a/library/cpp/int128/ut/ya.make +++ b/library/cpp/int128/ut/ya.make @@ -1,20 +1,20 @@ UNITTEST_FOR(library/cpp/int128) - -OWNER(vladon) + +OWNER(vladon) SRCS( - int128_ut_helpers.cpp - int128_ut_helpers.h - int128_ut.cpp - int128_typetraits_ut.cpp - int128_old_ut.cpp - int128_via_intrinsic_ut.cpp - i128_ut.cpp - i128_and_intrinsic_identity_ut.cpp - i128_comparison_ut.cpp - i128_division_ut.cpp - i128_type_traits_ut.cpp - ui128_division_ut.cpp + int128_ut_helpers.cpp + int128_ut_helpers.h + int128_ut.cpp + int128_typetraits_ut.cpp + int128_old_ut.cpp + int128_via_intrinsic_ut.cpp + i128_ut.cpp + i128_and_intrinsic_identity_ut.cpp + i128_comparison_ut.cpp + i128_division_ut.cpp + i128_type_traits_ut.cpp + ui128_division_ut.cpp ) END() diff --git a/library/cpp/int128/ya.make b/library/cpp/int128/ya.make index 95e453e6f1..ae581746c7 100644 --- a/library/cpp/int128/ya.make +++ b/library/cpp/int128/ya.make @@ -1,13 +1,13 @@ LIBRARY() -OWNER( - vladon +OWNER( + vladon # g:zora -) +) SRCS( - int128.cpp - int128.h + int128.cpp + int128.h ) END() diff --git a/library/cpp/ipv6_address/ipv6_address.cpp b/library/cpp/ipv6_address/ipv6_address.cpp index be8fcbae13..7cfb17f06a 100644 --- a/library/cpp/ipv6_address/ipv6_address.cpp +++ b/library/cpp/ipv6_address/ipv6_address.cpp @@ -12,17 +12,17 @@ #include <util/system/byteorder.h> #include <util/ysaveload.h> -#include <array> - -namespace { - // reinterpret_cast from memory, where most significant bit is first - inline ui128 FromMemMSF(const char* memPtr) { - Y_VERIFY(memPtr, " "); - return ui128{ - *reinterpret_cast<const ui64*>(memPtr), - *(reinterpret_cast<const ui64*>(memPtr) + 1) - }; - } +#include <array> + +namespace { + // reinterpret_cast from memory, where most significant bit is first + inline ui128 FromMemMSF(const char* memPtr) { + Y_VERIFY(memPtr, " "); + return ui128{ + *reinterpret_cast<const ui64*>(memPtr), + *(reinterpret_cast<const ui64*>(memPtr) + 1) + }; + } // zero-terminated copy of address string template <size_t N> @@ -33,17 +33,17 @@ namespace { res[len] = '\0'; return res; } -} - +} + void TIpv6Address::InitFrom(const in6_addr& addr) { const ui64* const ui64Ptr = reinterpret_cast<const ui64*>(&addr); const ui64 raw[2] = {SwapBytes(*ui64Ptr), SwapBytes(*(ui64Ptr + 1))}; - Ip = FromMemMSF(reinterpret_cast<const char*>(raw)); + Ip = FromMemMSF(reinterpret_cast<const char*>(raw)); Type_ = Ipv6; } void TIpv6Address::InitFrom(const in_addr& addr) { - unsigned long swapped = SwapBytes(addr.s_addr); - Ip = ui128{0, swapped}; + unsigned long swapped = SwapBytes(addr.s_addr); + Ip = ui128{0, swapped}; Type_ = Ipv4; } @@ -114,7 +114,7 @@ TString TIpv6Address::ToString(bool* ok) const noexcept { return ToString(true, ok); } TString TIpv6Address::ToString(bool PrintScopeId, bool* ok) const noexcept { - TString result; + TString result; bool isOk = true; if (Type_ == TIpv6Address::Ipv4) { @@ -176,16 +176,16 @@ void TIpv6Address::ToInAddr(in_addr& Addr4) const { Y_VERIFY(Type_ == TIpv6Address::Ipv4); Zero(Addr4); - ui32 Value = GetLow(Ip); - Y_VERIFY(Value == GetLow(Ip), " "); - Y_VERIFY(GetHigh(Ip) == 0, " "); + ui32 Value = GetLow(Ip); + Y_VERIFY(Value == GetLow(Ip), " "); + Y_VERIFY(GetHigh(Ip) == 0, " "); Addr4.s_addr = SwapBytes(Value); } void TIpv6Address::ToIn6Addr(in6_addr& Addr6) const { Y_VERIFY(Type_ == TIpv6Address::Ipv6); Zero(Addr6); - ui64 Raw[2] = {GetHigh(Ip), GetLow(Ip)}; + ui64 Raw[2] = {GetHigh(Ip), GetLow(Ip)}; *Raw = SwapBytes(*Raw); Raw[1] = SwapBytes(1 [Raw]); memcpy(&Addr6, Raw, sizeof(Raw)); @@ -213,10 +213,10 @@ bool TIpv6Address::Isv4MappedTov6() const noexcept { if (Type_ != Ipv6) return false; - if (GetHigh(Ip) != 0) + if (GetHigh(Ip) != 0) return false; // First 64 bit are not zero -> it is not ipv4-mapped-ipv6 address - const ui64 Low = GetLow(Ip) >> 32; + const ui64 Low = GetLow(Ip) >> 32; if (Low != 0x0000ffff) return false; @@ -227,8 +227,8 @@ TIpv6Address TIpv6Address::TryToExtractIpv4From6() const noexcept { if (Isv4MappedTov6() == false) return TIpv6Address(); - const ui64 NewLow = GetLow(Ip) & 0x00000000ffffffff; - TIpv6Address Result(ui128(0, NewLow), Ipv4); + const ui64 NewLow = GetLow(Ip) & 0x00000000ffffffff; + TIpv6Address Result(ui128(0, NewLow), Ipv4); return Result; } @@ -310,7 +310,7 @@ std::tuple<THostAddressAndPort, TString, TIpPort> ParseHostAndMayBePortFromStrin bool& Ok) noexcept { // Cout << "ParseHostAndMayBePortFromString: " << RawStr << ", Port: " << DefaultPort << Endl; - using TRes = std::tuple<THostAddressAndPort, TString, TIpPort>; + using TRes = std::tuple<THostAddressAndPort, TString, TIpPort>; // --------------------------------------------------------------------- diff --git a/library/cpp/ipv6_address/ipv6_address.h b/library/cpp/ipv6_address/ipv6_address.h index 1d7eb0b65f..e497d6a2cb 100644 --- a/library/cpp/ipv6_address/ipv6_address.h +++ b/library/cpp/ipv6_address/ipv6_address.h @@ -147,7 +147,7 @@ private: void InitFrom(const sockaddr_in6& Addr); void InitFrom(const sockaddr_in& Addr); - ui128 Ip{}; + ui128 Ip{}; TIpType Type_ = LAST; ui32 ScopeId_ = 0; }; @@ -189,7 +189,7 @@ IOutputStream& operator<<(IOutputStream& Out, const THostAddressAndPort& HostAdd /// /// Returns /// 1. either valid THostAddressAndPort -/// 2. or TString with hostname (which you should resolve) and TIpPort with port +/// 2. or TString with hostname (which you should resolve) and TIpPort with port /// 3. or error, if Ok == false /// /// Supported RawStrs are @@ -203,13 +203,13 @@ std::tuple<THostAddressAndPort, TString, TIpPort> ParseHostAndMayBePortFromStrin TIpPort DefaultPort, bool& Ok) noexcept; -using TIpv6AddressesSet = THashSet<TIpv6Address>; +using TIpv6AddressesSet = THashSet<TIpv6Address>; template <> struct THash<TIpv6Address> { inline size_t operator()(const TIpv6Address& ip) const { - const ui128& Tmp = static_cast<ui128>(ip); - return CombineHashes(THash<ui128>()(Tmp), THash<ui8>()(static_cast<ui8>(ip.Type()))); + const ui128& Tmp = static_cast<ui128>(ip); + return CombineHashes(THash<ui128>()(Tmp), THash<ui8>()(static_cast<ui8>(ip.Type()))); } }; template <> diff --git a/library/cpp/json/domscheme_traits.h b/library/cpp/json/domscheme_traits.h index a5a99cd8cf..91c3351b22 100644 --- a/library/cpp/json/domscheme_traits.h +++ b/library/cpp/json/domscheme_traits.h @@ -9,7 +9,7 @@ struct TJsonTraits { using TValue = NJson::TJsonValue; using TValueRef = TValue*; using TConstValueRef = const TValue*; - using TStringType = TStringBuf; + using TStringType = TStringBuf; // anyvalue defaults template <class T> @@ -104,7 +104,7 @@ struct TJsonTraits { return v->GetMap().size(); } - using TDictIterator = NJson::TJsonValue::TMapType::const_iterator; + using TDictIterator = NJson::TJsonValue::TMapType::const_iterator; static inline TDictIterator DictBegin(TConstValueRef v) { return v->GetMap().begin(); @@ -200,8 +200,8 @@ struct TJsonTraits { } // validation ops - static inline TVector<TString> GetKeys(TConstValueRef v) { - TVector<TString> res; + static inline TVector<TString> GetKeys(TConstValueRef v) { + TVector<TString> res; for (const auto& it : v->GetMap()) { res.push_back(it.first); } diff --git a/library/cpp/json/easy_parse/json_easy_parser.h b/library/cpp/json/easy_parse/json_easy_parser.h index 59d7791ab1..6a74f6c3d4 100644 --- a/library/cpp/json/easy_parse/json_easy_parser.h +++ b/library/cpp/json/easy_parse/json_easy_parser.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/stream/input.h> #include <util/stream/output.h> @@ -23,13 +23,13 @@ namespace NJson { */ class TJsonParser { - TString Prefix; + TString Prefix; struct TField { - TVector<TPathElem> Path; + TVector<TPathElem> Path; bool NonEmpty; }; - TVector<TField> Fields; + TVector<TField> Fields; friend class TRewriteJsonImpl; 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 ec55d838b3..491b684df7 100644 --- a/library/cpp/json/easy_parse/json_easy_parser_impl.h +++ b/library/cpp/json/easy_parse/json_easy_parser_impl.h @@ -10,10 +10,10 @@ namespace NJson { MAP_KEY }; } - template <class TStringType> + template <class TStringType> struct TPathElemImpl { NImpl::EType Type; - TStringType Key; + TStringType Key; int ArrayCounter; TPathElemImpl(NImpl::EType type) @@ -36,5 +36,5 @@ namespace NJson { } }; - typedef TPathElemImpl<TString> TPathElem; + typedef TPathElemImpl<TString> TPathElem; } diff --git a/library/cpp/json/fast_sax/parser.rl6 b/library/cpp/json/fast_sax/parser.rl6 index edb4e9ee1b..885f141c3d 100644 --- a/library/cpp/json/fast_sax/parser.rl6 +++ b/library/cpp/json/fast_sax/parser.rl6 @@ -58,7 +58,7 @@ struct TParserCtx { if (!token) { Hndl.OnError(off, reason); } else { - Hndl.OnError(off, TString::Join(reason, " at token: '", token, "'")); + Hndl.OnError(off, TString::Join(reason, " at token: '", token, "'")); } return false; diff --git a/library/cpp/json/fuzzy_test/main.cpp b/library/cpp/json/fuzzy_test/main.cpp index 29a53aac14..3f6dbc3117 100644 --- a/library/cpp/json/fuzzy_test/main.cpp +++ b/library/cpp/json/fuzzy_test/main.cpp @@ -4,7 +4,7 @@ #include <util/stream/str.h> extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - const auto json = TString((const char*)data, size); + const auto json = TString((const char*)data, size); try { NJson::TJsonValue value; diff --git a/library/cpp/json/json_writer.h b/library/cpp/json/json_writer.h index c7f5c9499a..ecd4dcc671 100644 --- a/library/cpp/json/json_writer.h +++ b/library/cpp/json/json_writer.h @@ -8,7 +8,7 @@ #include <util/stream/output.h> #include <util/generic/hash.h> -#include <util/generic/maybe.h> +#include <util/generic/maybe.h> #include <util/generic/strbuf.h> namespace NJson { @@ -154,8 +154,8 @@ namespace NJson { void WriteOptional(const TStringBuf&, const TNothing&) { // nothing to do - } - + } + void WriteKey(const TStringBuf key) { Buf.WriteKey(key); } @@ -179,7 +179,7 @@ namespace NJson { NJsonWriter::TBufState State() const { return Buf.State(); } - + void Reset(const NJsonWriter::TBufState& from) { return Buf.Reset(from); } diff --git a/library/cpp/json/ut/json_reader_fast_ut.cpp b/library/cpp/json/ut/json_reader_fast_ut.cpp index 60dffc91c7..4ecd698d56 100644 --- a/library/cpp/json/ut/json_reader_fast_ut.cpp +++ b/library/cpp/json/ut/json_reader_fast_ut.cpp @@ -280,7 +280,7 @@ public: } void TestReadJsonFastTree() { - const TString json = R"( + const TString json = R"( { "a": { "b": {} diff --git a/library/cpp/json/ut/json_reader_ut.cpp b/library/cpp/json/ut/json_reader_ut.cpp index cd31afa0b8..dd75332971 100644 --- a/library/cpp/json/ut/json_reader_ut.cpp +++ b/library/cpp/json/ut/json_reader_ut.cpp @@ -68,9 +68,9 @@ public: Y_UNIT_TEST_SUITE(TJsonReaderTest) { Y_UNIT_TEST(JsonReformatTest) { - TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; + TString data = "{\"null value\": null, \"intkey\": 10, \"double key\": 11.11, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; - TString result1, result2; + TString result1, result2; { TStringStream in; in << data; @@ -120,7 +120,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } Y_UNIT_TEST(TJsonTreeTest) { - TString data = "{\"intkey\": 10, \"double key\": 11.11, \"null value\":null, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; + TString data = "{\"intkey\": 10, \"double key\": 11.11, \"null value\":null, \"string key\": \"string\", \"array\": [1,2,3,\"TString\"], \"bool key\": true}"; TStringStream in; in << data; TJsonValue value; @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { UNIT_ASSERT_DOUBLES_EQUAL(value["double key"].GetDouble(), 11.11, 0.001); UNIT_ASSERT_VALUES_EQUAL(value["bool key"].GetBoolean(), true); UNIT_ASSERT_VALUES_EQUAL(value["absent string key"].GetString(), TString("")); - UNIT_ASSERT_VALUES_EQUAL(value["string key"].GetString(), TString("string")); + UNIT_ASSERT_VALUES_EQUAL(value["string key"].GetString(), TString("string")); UNIT_ASSERT_VALUES_EQUAL(value["array"][0].GetInteger(), 1); UNIT_ASSERT_VALUES_EQUAL(value["array"][1].GetInteger(), 2); UNIT_ASSERT_VALUES_EQUAL(value["array"][2].GetInteger(), 3); @@ -155,19 +155,19 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } Y_UNIT_TEST(TJsonRomaTest) { - TString data = "{\"test\": [ {\"name\": \"A\"} ]}"; + TString data = "{\"test\": [ {\"name\": \"A\"} ]}"; TStringStream in; in << data; TJsonValue value; ReadJsonTree(&in, &value); - UNIT_ASSERT_VALUES_EQUAL(value["test"][0]["name"].GetString(), TString("A")); + UNIT_ASSERT_VALUES_EQUAL(value["test"][0]["name"].GetString(), TString("A")); } Y_UNIT_TEST(TJsonReadTreeWithComments) { { - TString leadingCommentData = "{ // \"test\" : 1 \n}"; + TString leadingCommentData = "{ // \"test\" : 1 \n}"; { // No comments allowed TStringStream in; @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { } { - TString trailingCommentData = "{ \"test1\" : 1 // \"test2\" : 2 \n }"; + TString trailingCommentData = "{ \"test1\" : 1 // \"test2\" : 2 \n }"; { // No comments allowed TStringStream in; @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TJsonReaderTest) { Y_UNIT_TEST(TJsonMemoryLeakTest) { // after https://clubs.at.yandex-team.ru/stackoverflow/3691 - TString s = "."; + TString s = "."; NJson::TJsonValue json; try { TStringInput in(s); diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index ca11d34dad..ae60f208d4 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -7,9 +7,9 @@ using namespace NJson; Y_UNIT_TEST_SUITE(TJsonWriterTest) { Y_UNIT_TEST(SimpleWriteTest) { - TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; + TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; TString expected2 = expected1 + ",\"array\":[\"stroka\",false]"; - TString expected3 = expected2 + "}"; + TString expected3 = expected2 + "}"; TStringStream out; @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(SimpleWriteValueTest) { - TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; + TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; TJsonValue v; v["key1"] = JSON_NULL; v["key2"]["subkey1"].AppendValue(1); @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(FormatOutput) { - TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; + TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; TJsonValue v; v["key1"] = JSON_NULL; v["key2"]["subkey1"].AppendValue(1); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(SortKeys) { - TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; + TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; TJsonValue v; v["z"] = JSON_NULL; v["n"] = JSON_NULL; @@ -84,7 +84,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { { - TString expected = "{\"test\":1}"; + TString expected = "{\"test\":1}"; TJsonValue v; v.InsertValue("test", 1ull); TStringStream out; @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 1 { - TString expected = "{\"test\":-1}"; + TString expected = "{\"test\":-1}"; TJsonValue v; v.InsertValue("test", -1); TStringStream out; @@ -102,7 +102,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // -1 { - TString expected = "{\"test\":18446744073709551615}"; + TString expected = "{\"test\":18446744073709551615}"; TJsonValue v; v.InsertValue("test", 18446744073709551615ull); TStringStream out; @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 18446744073709551615 { - TString expected = "{\"test\":[1,18446744073709551615]}"; + TString expected = "{\"test\":[1,18446744073709551615]}"; TJsonValue v; v.InsertValue("test", TJsonValue()); v["test"].AppendValue(1); @@ -123,62 +123,62 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // SimpleUnsignedIntegerWriteTest Y_UNIT_TEST(WriteOptionalTest) { - { - TString expected = "{\"test\":1}"; - - TStringStream out; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", MakeMaybe<int>(1)); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TMaybe<int> nothing = Nothing(); - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", nothing); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TMaybe<int> empty; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", empty); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", Nothing()); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - } + { + TString expected = "{\"test\":1}"; + + TStringStream out; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", MakeMaybe<int>(1)); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TMaybe<int> nothing = Nothing(); + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", nothing); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TMaybe<int> empty; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", empty); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", Nothing()); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + } Y_UNIT_TEST(Callback) { NJsonWriter::TBuf json; diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 0aae2531b9..d7c77f9c63 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -2,7 +2,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> #include <util/stream/str.h> @@ -36,7 +36,7 @@ namespace NJsonWriter { struct TBufState { bool NeedComma; bool NeedNewline; - TVector<EJsonEntity> Stack; + TVector<EJsonEntity> Stack; }; class TBuf : TNonCopyable { @@ -88,7 +88,7 @@ namespace NJsonWriter { /*** Return the string formed in the internal TStringStream. * You may only call it if the `stream' parameter was NULL * at construction time. */ - const TString& Str() const; + const TString& Str() const; /*** Dump and forget the string constructed so far. * You may only call it if the `stream' parameter was NULL @@ -147,10 +147,10 @@ namespace NJsonWriter { private: IOutputStream* Stream; THolder<TStringStream> StringStream; - typedef TVector<const TString*> TKeys; + typedef TVector<const TString*> TKeys; TKeys Keys; - TVector<EJsonEntity> Stack; + TVector<EJsonEntity> Stack; bool NeedComma; bool NeedNewline; const EHtmlEscapeMode EscapeMode; diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp index 9980555683..a05d39f0a9 100644 --- a/library/cpp/json/writer/json_ut.cpp +++ b/library/cpp/json/writer/json_ut.cpp @@ -32,14 +32,14 @@ Y_UNIT_TEST_SUITE(JsonWriter) { Y_UNIT_TEST(EscapedString) { NJsonWriter::TBuf w(NJsonWriter::HEM_ESCAPE_HTML); w.WriteString(" \n \r \t \007 \b \f ' <tag> &ent; \"txt\" "); - TString ws = w.Str(); + TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\u0007 \\b \\f ' <tag> &ent; "txt" \""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } Y_UNIT_TEST(UnescapedString) { NJsonWriter::TBuf w; w.WriteString(" \n \r \t \b \f '; -- <tag> &ent; \"txt\"", NJsonWriter::HEM_DONT_ESCAPE_HTML); - TString ws = w.Str(); + TString ws = w.Str(); const char* exp = "\" \\n \\r \\t \\b \\f \\u0027; -- \\u003Ctag\\u003E &ent; \\\"txt\\\"\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } @@ -48,12 +48,12 @@ Y_UNIT_TEST_SUITE(JsonWriter) { w.UnsafeWriteRawBytes("(", 1); w.BeginList().WriteString("<>&'\\").BeginList(); w.EndList().EndList(); - TString ws = w.Str(); + TString ws = w.Str(); const char* exp = "([\"\\u003C\\u003E&\\u0027\\\\\",[]]"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } Y_UNIT_TEST(Utf8) { - TString ws = NJsonWriter::TBuf().WriteString("яЯ σΣ ש א").Str(); + TString ws = NJsonWriter::TBuf().WriteString("яЯ σΣ ש א").Str(); const char* exp = "\"яЯ σΣ ש א\""; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } @@ -80,14 +80,14 @@ Y_UNIT_TEST_SUITE(JsonWriter) { .CompatWriteKeyWithoutQuotes("n") .WriteInt(0) .EndObject(); - TString ws = w.Str(); + TString ws = w.Str(); const char* exp = "{p:1,n:0}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } Y_UNIT_TEST(UnescapedStringInObject) { NJsonWriter::TBuf w(NJsonWriter::HEM_DONT_ESCAPE_HTML); w.BeginObject().WriteKey("key").WriteString("</&>'").EndObject(); - TString ws = w.Str(); + TString ws = w.Str(); const char* exp = "{\"key\":\"\\u003C\\/&\\u003E\\u0027\"}"; UNIT_ASSERT_STRINGS_EQUAL(ws.c_str(), exp); } diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index c61e8d1dc4..79623a732a 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -23,15 +23,15 @@ AreJsonMapsEqual(const NJson::TJsonValue& lhs, const NJson::TJsonValue& rhs) { if (rhs.GetType() != JSON_MAP) return false; - typedef TJsonValue::TMapType TMapType; - const TMapType& lhsMap = lhs.GetMap(); - const TMapType& rhsMap = rhs.GetMap(); + typedef TJsonValue::TMapType TMapType; + const TMapType& lhsMap = lhs.GetMap(); + const TMapType& rhsMap = rhs.GetMap(); if (lhsMap.size() != rhsMap.size()) return false; for (const auto& lhsIt : lhsMap) { - TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); + TMapType::const_iterator rhsIt = rhsMap.find(lhsIt.first); if (rhsIt == rhsMap.end()) return false; diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 3f0f50bc4c..97bf582550 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -2,7 +2,7 @@ #include <library/cpp/json/common/defs.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/hash.h> #include <util/generic/vector.h> #include <util/generic/deque.h> diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index dc7f6affdf..30b8dda6f8 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -500,8 +500,8 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { expectedJson.InsertValue("foo", "bar"); UNIT_ASSERT(json == expectedJson); - TJsonValue::TMapType jsonMap = std::move(json.GetMapSafe()); - TJsonValue::TMapType expectedMap = {{"foo", TJsonValue{"bar"}}}; + TJsonValue::TMapType jsonMap = std::move(json.GetMapSafe()); + TJsonValue::TMapType expectedMap = {{"foo", TJsonValue{"bar"}}}; UNIT_ASSERT(jsonMap == expectedMap); } } @@ -601,7 +601,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } Y_UNIT_TEST(GetIntegerRobustBignumStringTest) { - TString value = "1626862681464633683"; + TString value = "1626862681464633683"; TJsonValue json(value); UNIT_ASSERT_VALUES_EQUAL(json.GetUIntegerRobust(), FromString<ui64>(value)); UNIT_ASSERT_VALUES_EQUAL(json.GetIntegerRobust(), FromString<i64>(value)); @@ -619,7 +619,7 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { "Testing TJsonValue& operator=(TJsonValue&&) subpart self moving " "after TJsonValue was constrcuted from TString&&."; - json["hello"] = TString{longTestString}; + json["hello"] = TString{longTestString}; json = std::move(json["hello"]); UNIT_ASSERT_VALUES_EQUAL(json.GetString(), longTestString); } diff --git a/library/cpp/json/yson/json2yson.cpp b/library/cpp/json/yson/json2yson.cpp index f72cb7a9ef..97e81d15b5 100644 --- a/library/cpp/json/yson/json2yson.cpp +++ b/library/cpp/json/yson/json2yson.cpp @@ -36,7 +36,7 @@ namespace NJson2Yson { } case NJson::JSON_MAP: { adapter->OnOpenMap(); - const NJson::TJsonValue::TMapType& map = jsonValue.GetMap(); + const NJson::TJsonValue::TMapType& map = jsonValue.GetMap(); for (const auto& it : map) { adapter->OnMapKey(it.first); WriteJsonValue(it.second, adapter); diff --git a/library/cpp/json/yson/json2yson_ut.cpp b/library/cpp/json/yson/json2yson_ut.cpp index 9eb23354cf..e17ef14e35 100644 --- a/library/cpp/json/yson/json2yson_ut.cpp +++ b/library/cpp/json/yson/json2yson_ut.cpp @@ -26,7 +26,7 @@ static TString GetRequestsWithDecoding(const TString& inputPath, const NBlockCod Y_UNIT_TEST_SUITE(Json2Yson) { Y_UNIT_TEST(NOAPACHE_REQUESTS) { const ui32 warmUpRetries = 5; - const TVector<double> percentiles = {0.25, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.99, 1.0}; + const TVector<double> percentiles = {0.25, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.99, 1.0}; NSimpleHistogram::TMultiHistogramCalcer<ui64> calcer; diff --git a/library/cpp/lcs/lcs_via_lis.h b/library/cpp/lcs/lcs_via_lis.h index d26733d94e..c652c31c81 100644 --- a/library/cpp/lcs/lcs_via_lis.h +++ b/library/cpp/lcs/lcs_via_lis.h @@ -11,9 +11,9 @@ namespace NLCS { template <typename TVal> struct TLCSCtx { - typedef TVector<ui32> TSubsequence; - typedef THashMap<TVal, TSubsequence, THash<TVal>, TEqualTo<TVal>, ::TPoolAllocator> TEncounterIndex; - typedef TVector<std::pair<ui32, ui32>> TLastIndex; + typedef TVector<ui32> TSubsequence; + typedef THashMap<TVal, TSubsequence, THash<TVal>, TEqualTo<TVal>, ::TPoolAllocator> TEncounterIndex; + typedef TVector<std::pair<ui32, ui32>> TLastIndex; typedef NPagedVector::TPagedVector<TSubsequence, 4096> TCover; TMemoryPool Pool; @@ -183,7 +183,7 @@ namespace NLCS { template <typename TVal, typename TIter> size_t MeasureLCS(TIter beg1, TIter end1, TIter beg2, TIter end2, TLCSCtx<TVal>* ctx = nullptr) { - return MakeLCS<TVal>(beg1, end1, beg2, end2, (TVector<TVal>*)nullptr, ctx); + return MakeLCS<TVal>(beg1, end1, beg2, end2, (TVector<TVal>*)nullptr, ctx); } template <typename TVal, typename TColl> diff --git a/library/cpp/lcs/lcs_via_lis_ut.cpp b/library/cpp/lcs/lcs_via_lis_ut.cpp index f6ad5152b6..88c6bb4d94 100644 --- a/library/cpp/lcs/lcs_via_lis_ut.cpp +++ b/library/cpp/lcs/lcs_via_lis_ut.cpp @@ -10,7 +10,7 @@ class TLCSTest: public TTestBase { private: size_t Length(TStringBuf s1, TStringBuf s2) { - TVector<TVector<size_t>> c; + TVector<TVector<size_t>> c; c.resize(s1.size() + 1); for (size_t i = 0; i < c.size(); ++i) { @@ -37,7 +37,7 @@ private: } void CheckLCSString(TStringBuf s1, TStringBuf s2, TStringBuf reflcs) { - TString lcs; + TString lcs; size_t len = NLCS::MakeLCS<char>(s1, s2, &lcs); const char* comment = Sprintf("%s & %s = %s", s1.data(), s2.data(), reflcs.data()).c_str(); diff --git a/library/cpp/lfalloc/alloc_profiler/profiler.cpp b/library/cpp/lfalloc/alloc_profiler/profiler.cpp index 0e30927a5a..593521d657 100644 --- a/library/cpp/lfalloc/alloc_profiler/profiler.cpp +++ b/library/cpp/lfalloc/alloc_profiler/profiler.cpp @@ -4,7 +4,7 @@ #include <util/generic/algorithm.h> #include <util/generic/singleton.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/stream/str.h> diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp index fded4e2fd1..55ecc8213f 100644 --- a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp +++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp @@ -208,7 +208,7 @@ public: const TFrameInfo* frames = TBase::GetFrames(); size_t framesCount = TBase::GetFramesCount(); - TVector<const TFrameInfo*> stacks; + TVector<const TFrameInfo*> stacks; for (size_t i = 0; i < framesCount; ++i) { if (frames[i].Stats.Allocs) { stacks.push_back(&frames[i]); diff --git a/library/cpp/lfalloc/lf_allocX64.cpp b/library/cpp/lfalloc/lf_allocX64.cpp index 2eb90761fe..b15bfc1026 100644 --- a/library/cpp/lfalloc/lf_allocX64.cpp +++ b/library/cpp/lfalloc/lf_allocX64.cpp @@ -3,14 +3,14 @@ ////////////////////////////////////////////////////////////////////////// // hooks #if defined(USE_INTELCC) || defined(_darwin_) || defined(_freebsd_) || defined(_STLPORT_VERSION) -#define OP_THROWNOTHING noexcept +#define OP_THROWNOTHING noexcept #else #define OP_THROWNOTHING #endif #ifndef _darwin_ #if !defined(YMAKE) -void* operator new(size_t size) { +void* operator new(size_t size) { return LFAlloc(size); } @@ -26,7 +26,7 @@ void operator delete(void* p, const std::nothrow_t&)OP_THROWNOTHING { LFFree(p); } -void* operator new[](size_t size) { +void* operator new[](size_t size) { return LFAlloc(size); } diff --git a/library/cpp/linear_regression/benchmark/pool.cpp b/library/cpp/linear_regression/benchmark/pool.cpp index 7f2c6a7004..5e014e575c 100644 --- a/library/cpp/linear_regression/benchmark/pool.cpp +++ b/library/cpp/linear_regression/benchmark/pool.cpp @@ -3,7 +3,7 @@ #include <util/string/cast.h> #include <util/stream/file.h> -TInstance TInstance::FromFeaturesString(const TString& featuresString) { +TInstance TInstance::FromFeaturesString(const TString& featuresString) { TInstance instance; TStringBuf featuresStringBuf(featuresString); @@ -29,7 +29,7 @@ TPool::TCVIterator::TCVIterator(const TPool& parentPool, const size_t foldsCount } void TPool::TCVIterator::ResetShuffle() { - TVector<size_t> instanceNumbers(ParentPool.size()); + TVector<size_t> instanceNumbers(ParentPool.size()); for (size_t instanceNumber = 0; instanceNumber < ParentPool.size(); ++instanceNumber) { instanceNumbers[instanceNumber] = instanceNumber; } @@ -83,9 +83,9 @@ bool TPool::TCVIterator::TakeCurrent() const { return false; } -void TPool::ReadFromFeatures(const TString& featuresPath) { - TFileInput featuresIn(featuresPath); - TString featuresString; +void TPool::ReadFromFeatures(const TString& featuresPath) { + TFileInput featuresIn(featuresPath); + TString featuresString; while (featuresIn.ReadLine(featuresString)) { this->push_back(TInstance::FromFeaturesString(featuresString)); } diff --git a/library/cpp/linear_regression/benchmark/pool.h b/library/cpp/linear_regression/benchmark/pool.h index 43288319c8..88140b7dd1 100644 --- a/library/cpp/linear_regression/benchmark/pool.h +++ b/library/cpp/linear_regression/benchmark/pool.h @@ -1,17 +1,17 @@ #pragma once #include <util/generic/vector.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/random/mersenne.h> #include <util/random/shuffle.h> struct TInstance { - TVector<double> Features; + TVector<double> Features; double Goal; double Weight; - static TInstance FromFeaturesString(const TString& featuresString); + static TInstance FromFeaturesString(const TString& featuresString); }; struct TPool: public TVector<TInstance> { @@ -29,7 +29,7 @@ struct TPool: public TVector<TInstance> { EIteratorType IteratorType; size_t TestFoldNumber; - TVector<size_t> InstanceFoldNumbers; + TVector<size_t> InstanceFoldNumbers; const size_t* Current; TMersenne<ui64> RandomGenerator; @@ -54,7 +54,7 @@ struct TPool: public TVector<TInstance> { bool TakeCurrent() const; }; - void ReadFromFeatures(const TString& featuresPath); + void ReadFromFeatures(const TString& featuresPath); TCVIterator CrossValidationIterator(const size_t foldsCount, const EIteratorType iteratorType) const; TPool InjurePool(const double injureFactir, const double injureOffset) const; diff --git a/library/cpp/linear_regression/linear_regression.cpp b/library/cpp/linear_regression/linear_regression.cpp index 150f9d214e..6fc5a40178 100644 --- a/library/cpp/linear_regression/linear_regression.cpp +++ b/library/cpp/linear_regression/linear_regression.cpp @@ -12,17 +12,17 @@ #include <functional> namespace { - inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedOLSTriangleMatrix); + inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedOLSTriangleMatrix); - TVector<double> Solve(const TVector<double>& olsMatrix, const TVector<double>& olsVector); + TVector<double> Solve(const TVector<double>& olsMatrix, const TVector<double>& olsVector); - double SumSquaredErrors(const TVector<double>& olsMatrix, - const TVector<double>& olsVector, - const TVector<double>& solution, + double SumSquaredErrors(const TVector<double>& olsMatrix, + const TVector<double>& olsVector, + const TVector<double>& solution, const double goalsDeviation); } -bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { +bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { const size_t featuresCount = features.size(); if (LinearizedOLSMatrix.empty()) { @@ -45,7 +45,7 @@ bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const dou return true; } -bool TLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { +bool TLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { const size_t featuresCount = features.size(); if (FeatureMeans.empty()) { @@ -114,7 +114,7 @@ bool TLinearRegressionSolver::Add(const TVector<double>& features, const double } TLinearModel TFastLinearRegressionSolver::Solve() const { - TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); + TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); double intercept = 0.; if (!coefficients.empty()) { @@ -126,7 +126,7 @@ TLinearModel TFastLinearRegressionSolver::Solve() const { } TLinearModel TLinearRegressionSolver::Solve() const { - TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); + TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); double intercept = GoalsMean; const size_t featuresCount = OLSVector.size(); @@ -138,12 +138,12 @@ TLinearModel TLinearRegressionSolver::Solve() const { } double TFastLinearRegressionSolver::SumSquaredErrors() const { - const TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); + const TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); return ::SumSquaredErrors(LinearizedOLSMatrix, OLSVector, coefficients, SumSquaredGoals.Get()); } double TLinearRegressionSolver::SumSquaredErrors() const { - const TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); + const TVector<double> coefficients = ::Solve(LinearizedOLSMatrix, OLSVector); return ::SumSquaredErrors(LinearizedOLSMatrix, OLSVector, coefficients, GoalsDeviation); } @@ -194,10 +194,10 @@ double TSLRSolver::SumSquaredErrors(const double regularizationParameter) const namespace { // LDL matrix decomposition, see http://en.wikipedia.org/wiki/Cholesky_decomposition#LDL_decomposition_2 - bool LDLDecomposition(const TVector<double>& linearizedOLSMatrix, + bool LDLDecomposition(const TVector<double>& linearizedOLSMatrix, const double regularizationThreshold, const double regularizationParameter, - TVector<double>& decompositionTrace, + TVector<double>& decompositionTrace, TVector<TVector<double>>& decompositionMatrix) { const size_t featuresCount = decompositionTrace.size(); @@ -206,7 +206,7 @@ namespace { double& decompositionTraceElement = decompositionTrace[rowNumber]; decompositionTraceElement = linearizedOLSMatrix[olsMatrixElementIdx] + regularizationParameter; - TVector<double>& decompositionRow = decompositionMatrix[rowNumber]; + TVector<double>& decompositionRow = decompositionMatrix[rowNumber]; for (size_t i = 0; i < rowNumber; ++i) { decompositionTraceElement -= decompositionRow[i] * decompositionRow[i] * decompositionTrace[i]; } @@ -218,7 +218,7 @@ namespace { ++olsMatrixElementIdx; decompositionRow[rowNumber] = 1.; for (size_t columnNumber = rowNumber + 1; columnNumber < featuresCount; ++columnNumber) { - TVector<double>& secondDecompositionRow = decompositionMatrix[columnNumber]; + TVector<double>& secondDecompositionRow = decompositionMatrix[columnNumber]; double& decompositionMatrixElement = secondDecompositionRow[rowNumber]; decompositionMatrixElement = linearizedOLSMatrix[olsMatrixElementIdx]; @@ -237,8 +237,8 @@ namespace { return true; } - void LDLDecomposition(const TVector<double>& linearizedOLSMatrix, - TVector<double>& decompositionTrace, + void LDLDecomposition(const TVector<double>& linearizedOLSMatrix, + TVector<double>& decompositionTrace, TVector<TVector<double>>& decompositionMatrix) { const double regularizationThreshold = 1e-5; double regularizationParameter = 0.; @@ -253,16 +253,16 @@ namespace { } TVector<double> SolveLower(const TVector<TVector<double>>& decompositionMatrix, - const TVector<double>& decompositionTrace, + const TVector<double>& decompositionTrace, const TVector<double>& olsVector) { const size_t featuresCount = olsVector.size(); - TVector<double> solution(featuresCount); + TVector<double> solution(featuresCount); for (size_t featureNumber = 0; featureNumber < featuresCount; ++featureNumber) { double& solutionElement = solution[featureNumber]; solutionElement = olsVector[featureNumber]; - const TVector<double>& decompositionRow = decompositionMatrix[featureNumber]; + const TVector<double>& decompositionRow = decompositionMatrix[featureNumber]; for (size_t i = 0; i < featureNumber; ++i) { solutionElement -= solution[i] * decompositionRow[i]; } @@ -279,12 +279,12 @@ namespace { const TVector<double>& lowerSolution) { const size_t featuresCount = lowerSolution.size(); - TVector<double> solution(featuresCount); + TVector<double> solution(featuresCount); for (size_t featureNumber = featuresCount; featureNumber > 0; --featureNumber) { double& solutionElement = solution[featureNumber - 1]; solutionElement = lowerSolution[featureNumber - 1]; - const TVector<double>& decompositionRow = decompositionMatrix[featureNumber - 1]; + const TVector<double>& decompositionRow = decompositionMatrix[featureNumber - 1]; for (size_t i = featureNumber; i < featuresCount; ++i) { solutionElement -= solution[i] * decompositionRow[i]; } @@ -293,10 +293,10 @@ namespace { return solution; } - TVector<double> Solve(const TVector<double>& olsMatrix, const TVector<double>& olsVector) { + TVector<double> Solve(const TVector<double>& olsMatrix, const TVector<double>& olsVector) { const size_t featuresCount = olsVector.size(); - TVector<double> decompositionTrace(featuresCount); + TVector<double> decompositionTrace(featuresCount); TVector<TVector<double>> decompositionMatrix(featuresCount, TVector<double>(featuresCount)); LDLDecomposition(olsMatrix, decompositionTrace, decompositionMatrix); @@ -304,9 +304,9 @@ namespace { return SolveUpper(decompositionMatrix, SolveLower(decompositionMatrix, decompositionTrace, olsVector)); } - double SumSquaredErrors(const TVector<double>& olsMatrix, - const TVector<double>& olsVector, - const TVector<double>& solution, + double SumSquaredErrors(const TVector<double>& olsMatrix, + const TVector<double>& olsVector, + const TVector<double>& solution, const double goalsDeviation) { const size_t featuresCount = olsVector.size(); @@ -325,7 +325,7 @@ namespace { } #ifdef _sse2_ - inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedOLSTriangleMatrix) { + inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedOLSTriangleMatrix) { const double* leftFeature = features.data(); const double* featuresEnd = features.data() + features.size(); double* matrixElement = linearizedOLSTriangleMatrix.data(); @@ -351,7 +351,7 @@ namespace { linearizedOLSTriangleMatrix.back() += weight; } #else - inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedTriangleMatrix) { + inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedTriangleMatrix) { const double* leftFeature = features.data(); const double* featuresEnd = features.data() + features.size(); double* matrixElement = linearizedTriangleMatrix.data(); diff --git a/library/cpp/linear_regression/linear_regression.h b/library/cpp/linear_regression/linear_regression.h index e57de5ff6c..f1596fb024 100644 --- a/library/cpp/linear_regression/linear_regression.h +++ b/library/cpp/linear_regression/linear_regression.h @@ -13,11 +13,11 @@ class TFastLinearRegressionSolver { private: TKahanAccumulator<double> SumSquaredGoals; - TVector<double> LinearizedOLSMatrix; - TVector<double> OLSVector; + TVector<double> LinearizedOLSMatrix; + TVector<double> OLSVector; public: - bool Add(const TVector<double>& features, const double goal, const double weight = 1.); + bool Add(const TVector<double>& features, const double goal, const double weight = 1.); TLinearModel Solve() const; double SumSquaredErrors() const; }; @@ -27,17 +27,17 @@ private: double GoalsMean = 0.; double GoalsDeviation = 0.; - TVector<double> FeatureMeans; - TVector<double> LastMeans; - TVector<double> NewMeans; - TVector<double> LinearizedOLSMatrix; + TVector<double> FeatureMeans; + TVector<double> LastMeans; + TVector<double> NewMeans; + TVector<double> LinearizedOLSMatrix; - TVector<double> OLSVector; + TVector<double> OLSVector; TKahanAccumulator<double> SumWeights; public: - bool Add(const TVector<double>& features, const double goal, const double weight = 1.); + bool Add(const TVector<double>& features, const double goal, const double weight = 1.); TLinearModel Solve() const; double SumSquaredErrors() const; }; @@ -145,12 +145,12 @@ public: bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin); bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin, const double* weightsBegin); - bool Add(const TVector<double>& features, const TVector<double>& goals) { + bool Add(const TVector<double>& features, const TVector<double>& goals) { Y_ASSERT(features.size() == goals.size()); return Add(features.data(), features.data() + features.size(), goals.data()); } - bool Add(const TVector<double>& features, const TVector<double>& goals, const TVector<double>& weights) { + bool Add(const TVector<double>& features, const TVector<double>& goals, const TVector<double>& weights) { Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); return Add(features.data(), features.data() + features.size(), goals.data(), weights.data()); } @@ -177,10 +177,10 @@ public: template <typename TSLRSolverType> class TTypedBestSLRSolver { private: - TVector<TSLRSolverType> SLRSolvers; + TVector<TSLRSolverType> SLRSolvers; public: - bool Add(const TVector<double>& features, const double goal, const double weight = 1.) { + bool Add(const TVector<double>& features, const double goal, const double weight = 1.) { if (SLRSolvers.empty()) { SLRSolvers.resize(features.size()); } @@ -200,7 +200,7 @@ public: } } - TVector<double> coefficients(SLRSolvers.size()); + TVector<double> coefficients(SLRSolvers.size()); double intercept = 0.0; if (bestSolver) { bestSolver->Solve(coefficients[bestSolver - SLRSolvers.begin()], intercept, regularizationParameter); @@ -289,7 +289,7 @@ private: float MaximalArgument = Min<float>(); ETransformationType TransformationType; - TVector<TPoint> Points; + TVector<TPoint> Points; public: TFeaturesTransformerLearner(const ETransformationType transformationType) @@ -315,7 +315,7 @@ private: TMeanCalculator TargetsMean; }; - THashMap<double, TBucket> Buckets; + THashMap<double, TBucket> Buckets; double Step; public: diff --git a/library/cpp/linear_regression/linear_regression_ut.cpp b/library/cpp/linear_regression/linear_regression_ut.cpp index e71a16b67a..6915c3821d 100644 --- a/library/cpp/linear_regression/linear_regression_ut.cpp +++ b/library/cpp/linear_regression/linear_regression_ut.cpp @@ -15,8 +15,8 @@ namespace { Y_UNIT_TEST_SUITE(TLinearRegressionTest) { Y_UNIT_TEST(MeanAndDeviationTest) { - TVector<double> arguments; - TVector<double> weights; + TVector<double> arguments; + TVector<double> weights; const size_t argumentsCount = 100; for (size_t i = 0; i < argumentsCount; ++i) { @@ -78,9 +78,9 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { } Y_UNIT_TEST(CovariationTest) { - TVector<double> firstValues; - TVector<double> secondValues; - TVector<double> weights; + TVector<double> firstValues; + TVector<double> secondValues; + TVector<double> weights; const size_t argumentsCount = 100; for (size_t i = 0; i < argumentsCount; ++i) { @@ -130,9 +130,9 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { template <typename TSLRSolverType> void SLRTest() { - TVector<double> arguments; - TVector<double> weights; - TVector<double> goals; + TVector<double> arguments; + TVector<double> weights; + TVector<double> goals; const double factor = 2.; const double intercept = 105.; @@ -194,18 +194,18 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { const size_t instancesCount = 10000; const double randomError = 0.01; - TVector<double> coefficients; + TVector<double> coefficients; for (size_t featureNumber = 0; featureNumber < featuresCount; ++featureNumber) { coefficients.push_back(featureNumber); } const double intercept = 10; TVector<TVector<double>> featuresMatrix; - TVector<double> goals; - TVector<double> weights; + TVector<double> goals; + TVector<double> weights; for (size_t instanceNumber = 0; instanceNumber < instancesCount; ++instanceNumber) { - TVector<double> features; + TVector<double> features; for (size_t featureNumber = 0; featureNumber < featuresCount; ++featureNumber) { features.push_back(RandomNumber<double>()); } @@ -240,8 +240,8 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { } void TransformationTest(const ETransformationType transformationType, const size_t pointsCount) { - TVector<float> arguments; - TVector<float> goals; + TVector<float> arguments; + TVector<float> goals; const double regressionFactor = 10.; const double regressionIntercept = 100; @@ -300,8 +300,8 @@ Y_UNIT_TEST_SUITE(TLinearRegressionTest) { } Y_UNIT_TEST(ResetCalculatorTest) { - TVector<double> arguments; - TVector<double> weights; + TVector<double> arguments; + TVector<double> weights; const double eps = 1e-10; const size_t argumentsCount = 100; diff --git a/library/cpp/linear_regression/unimodal.cpp b/library/cpp/linear_regression/unimodal.cpp index 729011012a..bbca9e9463 100644 --- a/library/cpp/linear_regression/unimodal.cpp +++ b/library/cpp/linear_regression/unimodal.cpp @@ -22,7 +22,7 @@ namespace { double SSE = 0.; - TOptimizationState(const TVector<double>& values) { + TOptimizationState(const TVector<double>& values) { SSE = InnerProduct(values, values); } @@ -44,7 +44,7 @@ double TGreedyParams::Point(const size_t step) const { return LowerBound * (1 - alpha) + UpperBound * alpha; } -double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimizationParams) { +double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimizationParams) { TOptimizationState state(values); TOptimizationState bestState = state; @@ -80,19 +80,19 @@ double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimiza return determination; } -double MakeUnimodal(TVector<double>& values) { +double MakeUnimodal(TVector<double>& values) { return MakeUnimodal(values, TOptimizationParams::Default(values)); } -double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, const TOptimizationParams& optimizationParams) { +double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, const TOptimizationParams& optimizationParams) { Y_ASSERT(values.size() == arguments.size()); - TMap<double, double> mapping; + TMap<double, double> mapping; for (size_t i = 0; i < values.size(); ++i) { mapping[arguments[i]] = values[i]; } - TVector<double> preparedValues; + TVector<double> preparedValues; preparedValues.reserve(mapping.size()); for (auto&& argWithValue : mapping) { @@ -113,6 +113,6 @@ double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, c return result; } -double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments) { +double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments) { return MakeUnimodal(values, arguments, TOptimizationParams::Default(values, arguments)); } diff --git a/library/cpp/linear_regression/unimodal.h b/library/cpp/linear_regression/unimodal.h index e11b1118f6..21d6ae8782 100644 --- a/library/cpp/linear_regression/unimodal.h +++ b/library/cpp/linear_regression/unimodal.h @@ -21,7 +21,7 @@ struct TOptimizationParams { TOptimizationParams() = default; - static TOptimizationParams Default(const TVector<double>& values) { + static TOptimizationParams Default(const TVector<double>& values) { TOptimizationParams optimizationParams; optimizationParams.ModeParams.LowerBound = 0; @@ -35,7 +35,7 @@ struct TOptimizationParams { return optimizationParams; } - static TOptimizationParams Default(const TVector<double>& values, const TVector<double>& arguments) { + static TOptimizationParams Default(const TVector<double>& values, const TVector<double>& arguments) { Y_ASSERT(values.size() == arguments.size()); TOptimizationParams optimizationParams; @@ -52,8 +52,8 @@ struct TOptimizationParams { } }; -double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimizationParams); -double MakeUnimodal(TVector<double>& values); +double MakeUnimodal(TVector<double>& values, const TOptimizationParams& optimizationParams); +double MakeUnimodal(TVector<double>& values); -double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, const TOptimizationParams& optimizationParams); -double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments); +double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments, const TOptimizationParams& optimizationParams); +double MakeUnimodal(TVector<double>& values, const TVector<double>& arguments); diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index b26bf5e88c..405884960c 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -7,7 +7,7 @@ namespace { class TGlobalLogsStorage { private: - TVector<TLogBackend*> Backends; + TVector<TLogBackend*> Backends; TMutex Mutex; public: @@ -50,11 +50,11 @@ ELogPriority TLogBackend::FiltrationLevel() const { return LOG_MAX_PRIORITY; } -TLogBackend::TLogBackend() noexcept { +TLogBackend::TLogBackend() noexcept { Singleton<TGlobalLogsStorage>()->Register(this); } -TLogBackend::~TLogBackend() { +TLogBackend::~TLogBackend() { Singleton<TGlobalLogsStorage>()->UnRegister(this); } diff --git a/library/cpp/logger/element.cpp b/library/cpp/logger/element.cpp index b510fe16e1..7a3ea3228f 100644 --- a/library/cpp/logger/element.cpp +++ b/library/cpp/logger/element.cpp @@ -17,7 +17,7 @@ TLogElement::TLogElement(const TLog* parent, ELogPriority priority) Reset(); } -TLogElement::~TLogElement() { +TLogElement::~TLogElement() { try { Finish(); } catch (...) { diff --git a/library/cpp/logger/element.h b/library/cpp/logger/element.h index fc9bff851f..f5d240d1ee 100644 --- a/library/cpp/logger/element.h +++ b/library/cpp/logger/element.h @@ -13,10 +13,10 @@ class TLogElement: public TTempBufOutput { public: TLogElement(const TLog* parent); TLogElement(const TLog* parent, ELogPriority priority); - + TLogElement(TLogElement&&) noexcept = default; TLogElement& operator=(TLogElement&&) noexcept = default; - + ~TLogElement() override; template <class T> diff --git a/library/cpp/logger/element_ut.cpp b/library/cpp/logger/element_ut.cpp index 32edc52dfb..bc6f1b4f0f 100644 --- a/library/cpp/logger/element_ut.cpp +++ b/library/cpp/logger/element_ut.cpp @@ -2,7 +2,7 @@ #include "element.h" #include "stream.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/str.h> #include <util/generic/ptr.h> #include <utility> @@ -26,7 +26,7 @@ void TLogElementTest::TestMoveCtor() { THolder<TLogElement> src = MakeHolder<TLogElement>(&log); - TString message = "Hello, World!"; + TString message = "Hello, World!"; (*src) << message; THolder<TLogElement> dst = MakeHolder<TLogElement>(std::move(*src)); diff --git a/library/cpp/logger/file.cpp b/library/cpp/logger/file.cpp index 15a4946eda..650be581ec 100644 --- a/library/cpp/logger/file.cpp +++ b/library/cpp/logger/file.cpp @@ -3,14 +3,14 @@ #include <util/system/file.h> #include <util/system/rwlock.h> -#include <util/generic/string.h> +#include <util/generic/string.h> /* * file log */ class TFileLogBackend::TImpl { public: - inline TImpl(const TString& path) + inline TImpl(const TString& path) : File_(OpenFile(path)) { } @@ -30,7 +30,7 @@ public: } private: - static inline TFile OpenFile(const TString& path) { + static inline TFile OpenFile(const TString& path) { return TFile(path, OpenAlways | WrOnly | ForAppend | Seq | NoReuse); } @@ -39,12 +39,12 @@ private: TFile File_; }; -TFileLogBackend::TFileLogBackend(const TString& path) +TFileLogBackend::TFileLogBackend(const TString& path) : Impl_(new TImpl(path)) { } -TFileLogBackend::~TFileLogBackend() { +TFileLogBackend::~TFileLogBackend() { } void TFileLogBackend::WriteData(const TLogRecord& rec) { diff --git a/library/cpp/logger/file.h b/library/cpp/logger/file.h index 10b4cd0c20..ce6561898f 100644 --- a/library/cpp/logger/file.h +++ b/library/cpp/logger/file.h @@ -7,7 +7,7 @@ class TFileLogBackend: public TLogBackend { public: - TFileLogBackend(const TString& path); + TFileLogBackend(const TString& path); ~TFileLogBackend() override; void WriteData(const TLogRecord& rec) override; diff --git a/library/cpp/logger/global/common.cpp b/library/cpp/logger/global/common.cpp index 4fb05c19b4..1b64867546 100644 --- a/library/cpp/logger/global/common.cpp +++ b/library/cpp/logger/global/common.cpp @@ -3,7 +3,7 @@ #include <util/generic/yexception.h> namespace NLoggingImpl { - TString GetLocalTimeSSimple() { + TString GetLocalTimeSSimple() { struct tm tm; return Strftime("%b%d_%H%M%S", Now().LocalTime(&tm)); } diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 7dcf650dec..364097d1bc 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -4,7 +4,7 @@ #include <util/folder/path.h> #include <util/generic/singleton.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ptr.h> #include <util/generic/yexception.h> #include <util/string/printf.h> @@ -66,7 +66,7 @@ public: namespace NLoggingImpl { - TString GetLocalTimeSSimple(); + TString GetLocalTimeSSimple(); // Returns correct log type to use TString PrepareToOpenLog(TString logType, int logLevel, bool rotation, bool startAsDaemon); diff --git a/library/cpp/logger/global/rty_formater.cpp b/library/cpp/logger/global/rty_formater.cpp index 305f8470c5..5721733860 100644 --- a/library/cpp/logger/global/rty_formater.cpp +++ b/library/cpp/logger/global/rty_formater.cpp @@ -52,12 +52,12 @@ namespace NLoggingImpl { return string.RNextTok(LOCSLASH_C); } - TString GetSystemResources() { + TString GetSystemResources() { NMemInfo::TMemInfo mi = NMemInfo::GetMemInfo(); return PrintSystemResources(mi); } - TString PrintSystemResources(const NMemInfo::TMemInfo& 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..471a050598 100644 --- a/library/cpp/logger/global/rty_formater.h +++ b/library/cpp/logger/global/rty_formater.h @@ -40,8 +40,8 @@ namespace NLoggingImpl { return TLocalTimeS(); } - TString GetSystemResources(); - TString PrintSystemResources(const NMemInfo::TMemInfo& info); + TString GetSystemResources(); + TString PrintSystemResources(const NMemInfo::TMemInfo& info); struct TLoggerFormatterTraits { static ILoggerFormatter* CreateDefault() { diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index e1d70cc3d2..2f5fc33356 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -8,7 +8,7 @@ #include <util/string/cast.h> #include <util/stream/printf.h> #include <util/system/yassert.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/scope.h> #include <util/generic/yexception.h> @@ -146,7 +146,7 @@ TLog::~TLog() = default; TLog& TLog::operator=(const TLog&) = default; TLog& TLog::operator=(TLog&&) = default; -bool TLog::IsOpen() const noexcept { +bool TLog::IsOpen() const noexcept { return Impl_->IsOpen(); } @@ -218,7 +218,7 @@ void TLog::ResetBackend(THolder<TLogBackend> backend) noexcept { Impl_->ResetBackend(std::move(backend)); } -bool TLog::IsNullLog() const noexcept { +bool TLog::IsNullLog() const noexcept { return Impl_->IsNullLog(); } diff --git a/library/cpp/logger/log_ut.cpp b/library/cpp/logger/log_ut.cpp index 8de46f17f5..a46bf5c7b3 100644 --- a/library/cpp/logger/log_ut.cpp +++ b/library/cpp/logger/log_ut.cpp @@ -7,7 +7,7 @@ #include <util/system/yield.h> #include <util/memory/blob.h> #include <util/stream/file.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> class TLogTest: public TTestBase { @@ -56,7 +56,7 @@ void TLogTest::TestFile() { TBlob data = TBlob::FromFileSingleThreaded(LOGFILE); - UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); + UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); } void TLogTest::TestThreaded() { @@ -75,7 +75,7 @@ void TLogTest::TestThreaded() { TBlob data = TBlob::FromFileSingleThreaded(LOGFILE); - UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); + UNIT_ASSERT_EQUAL(TString((const char*)data.Begin(), data.Size()), "some useful data 12, 34, 3.000000, qwqwqw\n"); } void TLogTest::TestThreadedWithOverflow() { @@ -166,13 +166,13 @@ void TLogTest::TestFormat() { void TLogTest::TestWrite() { TStringStream data; - TString test; + TString test; { TLog log(THolder(new TStreamLogBackend(&data))); for (size_t i = 0; i < 1000; ++i) { - TVector<char> buf(i, (char)i); + TVector<char> buf(i, (char)i); test.append(buf.data(), buf.size()); log.Write(buf.data(), buf.size()); diff --git a/library/cpp/logger/null.cpp b/library/cpp/logger/null.cpp index debb22f794..2ec47aed53 100644 --- a/library/cpp/logger/null.cpp +++ b/library/cpp/logger/null.cpp @@ -3,7 +3,7 @@ TNullLogBackend::TNullLogBackend() { } -TNullLogBackend::~TNullLogBackend() { +TNullLogBackend::~TNullLogBackend() { } void TNullLogBackend::WriteData(const TLogRecord&) { diff --git a/library/cpp/logger/stream.cpp b/library/cpp/logger/stream.cpp index 96787ad94b..c1bb222ff7 100644 --- a/library/cpp/logger/stream.cpp +++ b/library/cpp/logger/stream.cpp @@ -8,7 +8,7 @@ TStreamLogBackend::TStreamLogBackend(IOutputStream* slave) { } -TStreamLogBackend::~TStreamLogBackend() { +TStreamLogBackend::~TStreamLogBackend() { } void TStreamLogBackend::WriteData(const TLogRecord& rec) { diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp index 42233f63d2..0e9a647d28 100644 --- a/library/cpp/logger/system.cpp +++ b/library/cpp/logger/system.cpp @@ -46,7 +46,7 @@ TSysLogBackend::TSysLogBackend(const char* ident, EFacility facility, int flags) #endif } -TSysLogBackend::~TSysLogBackend() { +TSysLogBackend::~TSysLogBackend() { #if defined(_unix_) closelog(); #endif diff --git a/library/cpp/logger/system.h b/library/cpp/logger/system.h index b8c60b3023..471dee3ac1 100644 --- a/library/cpp/logger/system.h +++ b/library/cpp/logger/system.h @@ -39,7 +39,7 @@ public: void WriteData(const TLogRecord& rec) override; void ReopenLog() override; - virtual TString GetIdent() const { + virtual TString GetIdent() const { return Ident; } @@ -54,7 +54,7 @@ public: protected: int ELogPriority2SyslogPriority(ELogPriority priority); - TString Ident; + TString Ident; EFacility Facility; int Flags; }; diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp index 0ccf9e374b..7ff8f86463 100644 --- a/library/cpp/logger/thread.cpp +++ b/library/cpp/logger/thread.cpp @@ -126,7 +126,7 @@ TThreadedLogBackend::TThreadedLogBackend(TLogBackend* slave, size_t queuelen, st { } -TThreadedLogBackend::~TThreadedLogBackend() { +TThreadedLogBackend::~TThreadedLogBackend() { } void TThreadedLogBackend::WriteData(const TLogRecord& rec) { diff --git a/library/cpp/lwtrace/all.h b/library/cpp/lwtrace/all.h index d7aa57c49d..df00bdb42c 100644 --- a/library/cpp/lwtrace/all.h +++ b/library/cpp/lwtrace/all.h @@ -15,7 +15,7 @@ // #include <yweb/robot/kiwi/lwtrace/all.h> // #define MY_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ // name of your provider // PROBE(MyProbe, GROUPS("MyGroup1", "MyGroup2"), TYPES(), NAMES()) \ // probe specification w/o argiments -// PROBE(MyAnotherProbe, GROUPS("MyGroup2"), TYPES(int, TString), NAMES("arg1", "arg2")) \ // another probe with arguments +// PROBE(MyAnotherProbe, GROUPS("MyGroup2"), TYPES(int, TString), NAMES("arg1", "arg2")) \ // another probe with arguments // PROBE(MyScopedProbe, GROUPS(), TYPES(ui64, int), NAMES("duration", "stage")) \ // scoped probe with argument // /**/ // LWTRACE_DECLARE_PROVIDER(MY_PROVIDER) diff --git a/library/cpp/lwtrace/example1/lwtrace_example1.cpp b/library/cpp/lwtrace/example1/lwtrace_example1.cpp index 6b32c405ee..c1e15572f9 100644 --- a/library/cpp/lwtrace/example1/lwtrace_example1.cpp +++ b/library/cpp/lwtrace/example1/lwtrace_example1.cpp @@ -26,7 +26,7 @@ long double Fact(int n) { void FactorialCalculator() { i32 n; Cout << "Enter a number: "; - TString str; + TString str; Cin >> n; double factN = Fact(n); Cout << n << "! = " << factN << Endl << Endl; diff --git a/library/cpp/lwtrace/example2/lwtrace_example2.cpp b/library/cpp/lwtrace/example2/lwtrace_example2.cpp index 7a4f7a1daf..9a2fc7193d 100644 --- a/library/cpp/lwtrace/example2/lwtrace_example2.cpp +++ b/library/cpp/lwtrace/example2/lwtrace_example2.cpp @@ -20,7 +20,7 @@ THolder<NLWTrace::TManager> traceManager; struct TConfig { bool UnsafeLWTrace; - TString TraceRequestPath; + TString TraceRequestPath; }; void InitLWTrace(TConfig& cfg) { @@ -28,7 +28,7 @@ void InitLWTrace(TConfig& cfg) { } void AddLWTraceRequest(TConfig& cfg) { - TString queryStr = TUnbufferedFileInput(cfg.TraceRequestPath).ReadAll(); + TString queryStr = TUnbufferedFileInput(cfg.TraceRequestPath).ReadAll(); NLWTrace::TQuery query; google::protobuf::TextFormat::ParseFromString(queryStr, &query); traceManager->New("TraceRequest1", query); @@ -42,7 +42,7 @@ public: Cout << " time=" << item.Timestamp; } if (item.SavedParamsCount > 0) { - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); Cout << " params: "; for (size_t i = 0; i < item.SavedParamsCount; ++i) { @@ -78,7 +78,7 @@ void FactorialCalculator() { i32 n; Cout << "Enter a number: "; - TString str; + TString str; Cin >> n; GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, AfterInputProbe, n); diff --git a/library/cpp/lwtrace/example3/lwtrace_example3.cpp b/library/cpp/lwtrace/example3/lwtrace_example3.cpp index 4493dc0077..8556cc484f 100644 --- a/library/cpp/lwtrace/example3/lwtrace_example3.cpp +++ b/library/cpp/lwtrace/example3/lwtrace_example3.cpp @@ -30,7 +30,7 @@ long double Fact(int n) { void FactorialCalculator() { i32 n; Cout << "Enter a number: "; - TString str; + TString str; Cin >> n; double factN = Fact(n); Cout << n << "! = " << factN << Endl << Endl; diff --git a/library/cpp/lwtrace/example3/my_action.h b/library/cpp/lwtrace/example3/my_action.h index 9a04293ba2..0068774484 100644 --- a/library/cpp/lwtrace/example3/my_action.h +++ b/library/cpp/lwtrace/example3/my_action.h @@ -8,7 +8,7 @@ class TMyFile: public NLWTrace::IResource { private: TMutex Mutex; - THolder<TUnbufferedFileOutput> File; + THolder<TUnbufferedFileOutput> File; public: // Note that this class must have default ctor (it's declared here just for clearness) @@ -27,7 +27,7 @@ public: // if the same file was specified in Opts return; } - File.Reset(new TUnbufferedFileOutput(path)); + File.Reset(new TUnbufferedFileOutput(path)); } // Outputs a line to opened file @@ -63,7 +63,7 @@ public: private: virtual bool DoExecute(NLWTrace::TOrbit&, const NLWTrace::TParams& params) { // Serialize param values to strings - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; Probe->Event.Signature.SerializeParams(params, paramValues); // Generate output line diff --git a/library/cpp/lwtrace/example4/lwtrace_example4.cpp b/library/cpp/lwtrace/example4/lwtrace_example4.cpp index 7b55a07c75..4c1088d26b 100644 --- a/library/cpp/lwtrace/example4/lwtrace_example4.cpp +++ b/library/cpp/lwtrace/example4/lwtrace_example4.cpp @@ -34,7 +34,7 @@ void FactorialCalculator() { MY_BACKTRACK(); i32 n; Cout << "Enter a number: "; - TString str; + TString str; Cin >> n; double factN = Fact(n); Cout << n << "! = " << factN << Endl << Endl; diff --git a/library/cpp/lwtrace/mon/analytics/csv_output.h b/library/cpp/lwtrace/mon/analytics/csv_output.h index 90ded32f5d..47e0805e1e 100644 --- a/library/cpp/lwtrace/mon/analytics/csv_output.h +++ b/library/cpp/lwtrace/mon/analytics/csv_output.h @@ -7,9 +7,9 @@ namespace NAnalytics { -inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = true) +inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = true) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -22,11 +22,11 @@ inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = if (head) { bool first = true; if (hasName) { - ss << (first? TString(): sep) << "Name"; + ss << (first? TString(): sep) << "Name"; first = false; } - for (const TString& c : cols) { - ss << (first? TString(): sep) << c; + for (const TString& c : cols) { + ss << (first? TString(): sep) << c; first = false; } ss << Endl; @@ -35,11 +35,11 @@ inline TString ToCsv(const TTable& in, TString sep = TString("\t"), bool head = for (const TRow& row : in) { bool first = true; if (hasName) { - ss << (first? TString(): sep) << row.Name; + ss << (first? TString(): sep) << row.Name; first = false; } - for (const TString& c : cols) { - ss << (first? TString(): sep); + for (const TString& c : cols) { + ss << (first? TString(): sep); first = false; TString value; ss << (row.GetAsString(c, value) ? value : TString("-")); diff --git a/library/cpp/lwtrace/mon/analytics/data.h b/library/cpp/lwtrace/mon/analytics/data.h index 4b643fe20b..fe635d4209 100644 --- a/library/cpp/lwtrace/mon/analytics/data.h +++ b/library/cpp/lwtrace/mon/analytics/data.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/hash.h> -#include <util/generic/vector.h> +#include <util/generic/vector.h> #include <util/string/builder.h> #include <util/string/cast.h> @@ -21,7 +21,7 @@ TString ToString(const TRowValue& val) { } struct TRow : public THashMap<TString, TRowValue> { - TString Name; + TString Name; template<typename T> bool Get(const TString& name, T& value) const { @@ -57,18 +57,18 @@ struct TRow : public THashMap<TString, TRowValue> { } }; -using TAttributes = THashMap<TString, TString>; +using TAttributes = THashMap<TString, TString>; -struct TTable : public TVector<TRow> { +struct TTable : public TVector<TRow> { TAttributes Attributes; }; -struct TMatrix : public TVector<double> { +struct TMatrix : public TVector<double> { size_t Rows; size_t Cols; explicit TMatrix(size_t rows = 0, size_t cols = 0) - : TVector<double>(rows * cols) + : TVector<double>(rows * cols) , Rows(rows) , Cols(cols) {} diff --git a/library/cpp/lwtrace/mon/analytics/html_output.h b/library/cpp/lwtrace/mon/analytics/html_output.h index f775f216b9..3b63a1ce5f 100644 --- a/library/cpp/lwtrace/mon/analytics/html_output.h +++ b/library/cpp/lwtrace/mon/analytics/html_output.h @@ -7,9 +7,9 @@ namespace NAnalytics { -inline TString ToHtml(const TTable& in) +inline TString ToHtml(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -24,7 +24,7 @@ inline TString ToHtml(const TTable& in) if (hasName) { ss << "<th>Name</th>"; } - for (const TString& c : cols) { + for (const TString& c : cols) { ss << "<th>" << c << "</th>"; } ss << "</tr></thead><tbody>"; @@ -34,7 +34,7 @@ inline TString ToHtml(const TTable& in) if (hasName) { ss << "<th>" << row.Name << "</th>"; } - for (const TString& c : cols) { + for (const TString& c : cols) { TString value; ss << "<td>" << (row.GetAsString(c, value) ? value : TString("-")) << "</td>"; } @@ -45,9 +45,9 @@ inline TString ToHtml(const TTable& in) return ss.Str(); } -inline TString ToTransposedHtml(const TTable& in) +inline TString ToTransposedHtml(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; bool hasName = false; for (const TRow& row : in) { hasName = hasName || !row.Name.empty(); @@ -69,7 +69,7 @@ inline TString ToTransposedHtml(const TTable& in) ss << "</thead><tbody>"; - for (const TString& c : cols) { + for (const TString& c : cols) { ss << "<tr>"; ss << "<th>" << c << "</th>"; for (const TRow& row : in) { diff --git a/library/cpp/lwtrace/mon/analytics/json_output.h b/library/cpp/lwtrace/mon/analytics/json_output.h index 189f9802d3..b03392e162 100644 --- a/library/cpp/lwtrace/mon/analytics/json_output.h +++ b/library/cpp/lwtrace/mon/analytics/json_output.h @@ -10,26 +10,26 @@ namespace NAnalytics { -inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TString>& ynos, const TString& opts = TString()) +inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TString>& ynos, const TString& opts = TString()) { TStringStream ss; ss << "[ "; bool first = true; - TString xn; - THashSet<TString> xopts; + TString xn; + THashSet<TString> xopts; ParseNameAndOpts(xno, xn, xopts); bool xstack = xopts.contains("stack"); - for (const TString& yno : ynos) { - TString yn; - THashSet<TString> yopts; + for (const TString& yno : ynos) { + TString yn; + THashSet<TString> yopts; ParseNameAndOpts(yno, yn, yopts); bool ystackOpt = yopts.contains("stack"); ss << (first? "": ",\n ") << "{ " << opts << (opts? ", ": "") << "\"label\": \"" << yn << "\", \"data\": [ "; bool first2 = true; - using TPt = std::tuple<double, double, TString>; + using TPt = std::tuple<double, double, TString>; std::vector<TPt> pts; for (const TRow& row : in) { double x, y; diff --git a/library/cpp/lwtrace/mon/analytics/transform.h b/library/cpp/lwtrace/mon/analytics/transform.h index f7dc9adb5b..60f7aac379 100644 --- a/library/cpp/lwtrace/mon/analytics/transform.h +++ b/library/cpp/lwtrace/mon/analytics/transform.h @@ -6,14 +6,14 @@ namespace NAnalytics { template <class TSkip, class TX, class TY> inline TTable Histogram(const TTable& in, TSkip skip, - const TString& xn_out, TX x_in, - const TString& yn_out, TY y_in, + const TString& xn_out, TX x_in, + const TString& yn_out, TY y_in, double x1, double x2, double dx) { long buckets = (x2 - x1) / dx; TTable out; - TString yn_sum = yn_out + "_sum"; - TString yn_share = yn_out + "_share"; + TString yn_sum = yn_out + "_sum"; + TString yn_share = yn_out + "_share"; double ysum = 0.0; out.resize(buckets); for (size_t i = 0; i < out.size(); i++) { @@ -46,14 +46,14 @@ inline TTable Histogram(const TTable& in, TSkip skip, return out; } -inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, double x2, double dx) +inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, double x2, double dx) { long buckets = (dx == 0.0? 1: (x2 - x1) / dx); TTable out; - THashMap<TString, double> colSum; + THashMap<TString, double> colSum; out.resize(buckets); - TSet<TString> cols; + TSet<TString> cols; for (auto& row : in) { for (auto& kv : row) { cols.insert(kv.first); @@ -62,7 +62,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl cols.insert("_count"); cols.erase(xn); - for (const TString& col : cols) { + for (const TString& col : cols) { colSum[col] = 0.0; } @@ -72,7 +72,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl TRow& row = out[i]; row.Name = "[" + ToString(lb) + ";" + ToString(ub) + (ub==x2? "]": ")"); row[xn] = (lb + ub) / 2; - for (const TString& col : cols) { + for (const TString& col : cols) { row[col + "_sum"] = 0.0; } } @@ -86,7 +86,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl i--; } for (const auto& kv : row_in) { - const TString& yn = kv.first; + const TString& yn = kv.first; if (yn == xn) { continue; } @@ -116,7 +116,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl } } for (TRow& row : out) { - for (const TString& col : cols) { + for (const TString& col : cols) { double ysum = colSum[col]; if (col != "_count") { if (row.GetOrDefault(col + "_cnt") != 0.0) { @@ -133,7 +133,7 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl inline TMatrix CovarianceMatrix(const TTable& in) { - TSet<TString> cols; + TSet<TString> cols; for (auto& row : in) { for (auto& kv : row) { cols.insert(kv.first); @@ -147,7 +147,7 @@ inline TMatrix CovarianceMatrix(const TTable& in) double Mean = 0; }; - THashMap<TString, TAggregate> colAggr; + THashMap<TString, TAggregate> colAggr; size_t colCount = 0; for (const TString& col : cols) { diff --git a/library/cpp/lwtrace/mon/analytics/util.h b/library/cpp/lwtrace/mon/analytics/util.h index e07d06cc43..e4b067f8a9 100644 --- a/library/cpp/lwtrace/mon/analytics/util.h +++ b/library/cpp/lwtrace/mon/analytics/util.h @@ -13,7 +13,7 @@ inline double Finitize(double x, double notFiniteValue = 0.0) return isfinite(x)? x: notFiniteValue; } -inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet<TString>& opts) +inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet<TString>& opts) { name.clear(); opts.clear(); @@ -29,18 +29,18 @@ inline void ParseNameAndOpts(const TString& nameAndOpts, TString& name, THashSet } } -inline TString ParseName(const TString& nameAndOpts) +inline TString ParseName(const TString& nameAndOpts) { auto vs = SplitString(nameAndOpts, "-"); if (vs.empty()) { - return TString(); + return TString(); } else { return vs[0]; } } template <class R, class T> -inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) +inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) { ForEach(table.begin(), table.end(), [=,&r] (const TRow& row) { double value; @@ -51,10 +51,10 @@ inline R AccumulateIfExist(const TString& name, const TTable& table, R r, T t) return r; } -inline double MinValue(const TString& nameAndOpts, const TTable& table) +inline double MinValue(const TString& nameAndOpts, const TTable& table) { - TString name; - THashSet<TString> opts; + TString name; + THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); bool stack = opts.contains("stack"); if (stack) { @@ -68,10 +68,10 @@ inline double MinValue(const TString& nameAndOpts, const TTable& table) } } -inline double MaxValue(const TString& nameAndOpts, const TTable& table) +inline double MaxValue(const TString& nameAndOpts, const TTable& table) { - TString name; - THashSet<TString> opts; + TString name; + THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); bool stack = opts.contains("stack"); if (stack) { @@ -88,14 +88,14 @@ inline double MaxValue(const TString& nameAndOpts, const TTable& table) } template <class T> -inline void Map(TTable& table, const TString& rname, T t) +inline void Map(TTable& table, const TString& rname, T t) { ForEach(table.begin(), table.end(), [=] (TRow& row) { row[rname] = t(row); }); } -inline std::function<bool(const TRow&)> HasNoValueFor(TString name) +inline std::function<bool(const TRow&)> HasNoValueFor(TString name) { return [=] (const TRow& row) -> bool { double value; @@ -104,7 +104,7 @@ inline std::function<bool(const TRow&)> HasNoValueFor(TString name) } -inline std::function<double(const TRow&)> GetValueFor(TString name, double defVal = 0.0) +inline std::function<double(const TRow&)> GetValueFor(TString name, double defVal = 0.0) { return [=] (const TRow& row) -> double { double value; diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index a61ee9ce22..4a61498b76 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -55,7 +55,7 @@ struct TTrackLogRefs { operator const NLWTrace::TLogItem&() const { return *Ptr; } }; - using TItems = TVector<TItem>; + using TItems = TVector<TItem>; TItems Items; TTrackLogRefs() {} @@ -278,10 +278,10 @@ private: } }; - TString Text; - TString Provider; - TString Probe; - TString ParamName; + TString Text; + TString Provider; + TString Probe; + TString ParamName; ESpecialParam SpecialParam = NotSpecial; i64 Index = 0; double TimeUnitSec = 1.0; @@ -292,7 +292,7 @@ private: public: TLogQuery() {} - explicit TLogQuery(const TString& text) + explicit TLogQuery(const TString& text) : Text(text) { try { @@ -350,7 +350,7 @@ private: return NLWTrace::TTypedParam(sec / TimeUnitSec); } - void ParseQuery(const TString& s) + void ParseQuery(const TString& s) { auto parts = SplitString(s, "."); WWW_CHECK(parts.size() <= 3, "too many name specifiers"); @@ -363,26 +363,26 @@ private: } } - void ParseParamSelector(const TString& s) + void ParseParamSelector(const TString& s) { size_t bracket = s.find('['); - if (bracket == TString::npos) { + if (bracket == TString::npos) { ParseParamName(s); Index = 0; } else { ParseParamName(s.substr(0, bracket)); size_t bracket2 = s.find(']', bracket); - WWW_CHECK(bracket2 != TString::npos, "closing braket ']' is missing"); + WWW_CHECK(bracket2 != TString::npos, "closing braket ']' is missing"); Index = FromString<i64>(s.substr(bracket + 1, bracket2 - bracket - 1)); } } - void ParseParamName(const TString& s) + void ParseParamName(const TString& s) { ParamName = s; - TString paramName = s; + TString paramName = s; - const static TVector<std::pair<TString, ESpecialParam>> specials = { + const static TVector<std::pair<TString, ESpecialParam>> specials = { { "_track", TrackDuration }, { "_begin", TrackBeginTime }, { "_end", TrackEndTime }, @@ -405,7 +405,7 @@ private: return; } - const static TVector<std::pair<TString, double>> timeUnits = { + const static TVector<std::pair<TString, double>> timeUnits = { { "Ms", 1e-3 }, { "Us", 1e-6 }, { "Ns", 1e-9 }, @@ -428,7 +428,7 @@ private: SpecialParam == TrackEndTime) { // Parse time zero for special instant params - const TVector<std::pair<TString, i64>> timeZeros = { + const TVector<std::pair<TString, i64>> timeZeros = { { "RTime", RTimeZeroTs }, { "NTime", NTimeZeroTs }, { "Time", 0ll } @@ -447,23 +447,23 @@ private: WWW_CHECK(paramName.empty(), "wrong special param name: %s", s.data()); } - void ParseProbeSelector(const TString& s) + void ParseProbeSelector(const TString& s) { Probe = s; } - void ParseProviderSelector(const TString& s) + void ParseProviderSelector(const TString& s) { Provider = s; } }; -using TVariants = TVector<std::pair<TString, TString>>; -using TTags = TSet<TString>; +using TVariants = TVector<std::pair<TString, TString>>; +using TTags = TSet<TString>; -TString GetProbeName(const NLWTrace::TProbe* probe, const char* sep = ".") +TString GetProbeName(const NLWTrace::TProbe* probe, const char* sep = ".") { - return TString(probe->Event.GetProvider()) + sep + probe->Event.Name; + return TString(probe->Event.GetProvider()) + sep + probe->Event.Name; } struct TAdHocTraceConfig { @@ -485,7 +485,7 @@ struct TAdHocTraceConfig { } } - TAdHocTraceConfig(const TString& provider, const TString& probe, ui16 logSize = 0, ui64 logDurationUs = 0, bool logShuttle = false) + TAdHocTraceConfig(const TString& provider, const TString& probe, ui16 logSize = 0, ui64 logDurationUs = 0, bool logShuttle = false) : TAdHocTraceConfig(logSize, logDurationUs, logShuttle) { auto block = Cfg.MutableBlocks(0); @@ -494,7 +494,7 @@ struct TAdHocTraceConfig { pdesc->SetName(probe); } - explicit TAdHocTraceConfig(const TString& group, ui16 logSize = 0, ui64 logDurationUs = 0, bool logShuttle = false) + explicit TAdHocTraceConfig(const TString& group, ui16 logSize = 0, ui64 logDurationUs = 0, bool logShuttle = false) : TAdHocTraceConfig(logSize, logDurationUs, logShuttle) { auto block = Cfg.MutableBlocks(0); @@ -502,7 +502,7 @@ struct TAdHocTraceConfig { pdesc->SetGroup(group); } - TString Id() const + TString Id() const { TStringStream ss; for (size_t blockIdx = 0; blockIdx < Cfg.BlocksSize(); blockIdx++) { @@ -572,7 +572,7 @@ struct TAdHocTraceConfig { return Cfg; } - bool ParseId(const TString& id) + bool ParseId(const TString& id) { if (IsAdHocId(id)) { for (const TString& block : SplitString(id, "/")) { @@ -592,7 +592,7 @@ struct TAdHocTraceConfig { } bool defaultAction = true; for (auto i = parts.begin() + 2, e = parts.end(); i != e; ++i) { - const TString& part = *i; + const TString& part = *i; if (part.empty()) { continue; } @@ -614,12 +614,12 @@ struct TAdHocTraceConfig { return false; } private: - static bool IsAdHocId(const TString& id) + static bool IsAdHocId(const TString& id) { return !id.empty() && id[0] == '.'; } - void ParsePredicate(NLWTrace::TOperator* op, const TString& p) + void ParsePredicate(NLWTrace::TOperator* op, const TString& p) { size_t sign = p.find_first_of("=!><"); WWW_CHECK(sign != TString::npos, "wrong predicate format in adhoc trace: %s", p.data()); @@ -661,7 +661,7 @@ private: op->AddArgument()->SetValue(p.substr(value)); } - void ParseAction(NLWTrace::TAction* action, const TString& a) + void ParseAction(NLWTrace::TAction* action, const TString& a) { // NOTE: checks for longer action names should go first, your captain. if (a.substr(0, 3) == "lsr") { @@ -704,7 +704,7 @@ private: } } - static ui64 ParseDuration(const TString& s) + static ui64 ParseDuration(const TString& s) { if (s.substr(s.length() - 2) == "us") return FromString<ui64>(s.substr(0, s.length() - 2)); @@ -727,7 +727,7 @@ private: TMutex Mtx; TCondVar WakeCondVar; - THashMap<TString, TInstant> Deadlines; + THashMap<TString, TInstant> Deadlines; volatile bool ThreadIsRunning = false; THolder<TThread> Thread; public: @@ -743,7 +743,7 @@ public: } // Returns deadline for specified trace id or zero - TInstant GetDeadline(const TString& id) const + TInstant GetDeadline(const TString& id) const { TGuard<TMutex> g(Mtx); auto iter = Deadlines.find(id); @@ -751,7 +751,7 @@ public: } // Postpone deletion of specified trace for specified timeout - void Postpone(const TString& id, TDuration timeout, bool allowLowering) + void Postpone(const TString& id, TDuration timeout, bool allowLowering) { TGuard<TMutex> g(Mtx); TInstant newDeadline = TInstant::Now() + timeout; @@ -770,7 +770,7 @@ public: } // Forget about specified trace deletion - void Forget(const TString& id) + void Forget(const TString& id) { TGuard<TMutex> g(Mtx); Deadlines.erase(id); @@ -786,7 +786,7 @@ private: TInstant now = TInstant::Now(); TInstant nextDeadline = TInstant::Max(); for (auto i = Deadlines.begin(), e = Deadlines.end(); i != e;) { - const TString& id = i->first; + const TString& id = i->first; TInstant deadline = i->second; if (deadline < now) { try { @@ -814,7 +814,7 @@ private: static void* ThreadProc(void* _this) { - TString name = "LWTraceCleaner"; + TString name = "LWTraceCleaner"; // Copy-pasted from kikimr/core/util/thread.h #if defined(_linux_) TStringStream linuxName; @@ -830,18 +830,18 @@ private: class TChromeTrace { private: - TMultiMap<double, TString> TraceEvents; - THashMap<TThread::TId, TString> Tids; + TMultiMap<double, TString> TraceEvents; + THashMap<TThread::TId, TString> Tids; public: - void Add(TThread::TId tid, ui64 tsCycles, const TString& ph, const TString& cat, + void Add(TThread::TId tid, ui64 tsCycles, const TString& ph, const TString& cat, const NLWTrace::TLogItem* argsItem = nullptr, - const TString& name = TString(), const TString& id = TString()) + const TString& name = TString(), const TString& id = TString()) { auto tidIter = Tids.find(tid); if (tidIter == Tids.end()) { tidIter = Tids.emplace(tid, ToString(Tids.size() + 1)).first; } - const TString& shortId = tidIter->second; + const TString& shortId = tidIter->second; double ts = Timestamp(tsCycles); TraceEvents.emplace(ts, Event(shortId, ts, ph, cat, argsItem, name, id)); } @@ -861,9 +861,9 @@ public: } private: - static TString Event(const TString& tid, double ts, const TString& ph, const TString& cat, + static TString Event(const TString& tid, double ts, const TString& ph, const TString& cat, const NLWTrace::TLogItem* argsItem, - const TString& name, const TString& id) + const TString& name, const TString& id) { TStringStream ss; pid_t pid = 1; @@ -880,14 +880,14 @@ private: } if (argsItem && argsItem->SavedParamsCount > 0) { ss << ",\"args\":{"; - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; argsItem->Probe->Event.Signature.SerializeParams(argsItem->Params, paramValues); bool first = true; for (size_t pi = 0; pi < argsItem->SavedParamsCount; pi++, first = false) { if (!first) { ss << ","; } - ss << "\"" << TString(argsItem->Probe->Event.Signature.ParamNames[pi]) << "\":" + ss << "\"" << TString(argsItem->Probe->Event.Signature.ParamNames[pi]) << "\":" "\"" << paramValues[pi] << "\""; } ss << "}"; @@ -919,7 +919,7 @@ TString MakeUrl(const TCgiParameters& e, const THashMap<TString, TString>& value return ss.Str(); } -TString MakeUrl(const TCgiParameters& e, const TString& key, const TString& value, bool keep = false) +TString MakeUrl(const TCgiParameters& e, const TString& key, const TString& value, bool keep = false) { TStringStream ss; bool first = true; @@ -933,7 +933,7 @@ TString MakeUrl(const TCgiParameters& e, const TString& key, const TString& valu return ss.Str(); } -TString MakeUrlAdd(const TCgiParameters& e, const TString& key, const TString& value) +TString MakeUrlAdd(const TCgiParameters& e, const TString& key, const TString& value) { TStringStream ss; bool first = true; @@ -945,7 +945,7 @@ TString MakeUrlAdd(const TCgiParameters& e, const TString& key, const TString& v return ss.Str(); } -TString MakeUrlReplace(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) +TString MakeUrlReplace(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) { TStringStream ss; bool first = true; @@ -968,7 +968,7 @@ TString MakeUrlReplace(const TCgiParameters& e, const TString& key, const TStrin return ss.Str(); } -TString MakeUrlErase(const TCgiParameters& e, const TString& key, const TString& value) +TString MakeUrlErase(const TCgiParameters& e, const TString& key, const TString& value) { TStringStream ss; bool first = true; @@ -981,9 +981,9 @@ TString MakeUrlErase(const TCgiParameters& e, const TString& key, const TString& return ss.Str(); } -TString EscapeSubvalue(const TString& s) +TString EscapeSubvalue(const TString& s) { - TString ret; + TString ret; ret.reserve(s.size()); for (size_t i = 0; i < s.size(); i++) { char c = s[i]; @@ -998,9 +998,9 @@ TString EscapeSubvalue(const TString& s) return ret; } -TString UnescapeSubvalue(const TString& s) +TString UnescapeSubvalue(const TString& s) { - TString ret; + TString ret; ret.reserve(s.size()); for (size_t i = 0; i < s.size(); i++) { char c = s[i]; @@ -1021,12 +1021,12 @@ TString UnescapeSubvalue(const TString& s) return ret; } -TVector<TString> Subvalues(const TCgiParameters& e, const TString& key) +TVector<TString> Subvalues(const TCgiParameters& e, const TString& key) { if (!e.Has(key)) { - return TVector<TString>(); + return TVector<TString>(); } else { - TVector<TString> ret; + TVector<TString> ret; for (const TString& s : SplitString(e.Get(key), ":", 0, KEEP_EMPTY_TOKENS)) { ret.push_back(UnescapeSubvalue(s)); } @@ -1037,44 +1037,44 @@ TVector<TString> Subvalues(const TCgiParameters& e, const TString& key) } } -TString ParseTagsOut(const TString& taggedStr, TTags& tags) +TString ParseTagsOut(const TString& taggedStr, TTags& tags) { auto vec = SplitString(taggedStr, "-"); if (vec.empty()) { return ""; } auto iter = vec.begin(); - TString value = *iter++; + TString value = *iter++; for (;iter != vec.end(); ++iter) { tags.insert(*iter); } return value; } -TString JoinTags(TTags tags) { - return JoinStrings(TVector<TString>(tags.begin(), tags.end()), "-"); +TString JoinTags(TTags tags) { + return JoinStrings(TVector<TString>(tags.begin(), tags.end()), "-"); } -TString MakeValue(const TVector<TString>& subvalues) +TString MakeValue(const TVector<TString>& subvalues) { - TVector<TString> subvaluesEsc; - for (const TString& s : subvalues) { + TVector<TString> subvaluesEsc; + for (const TString& s : subvalues) { subvaluesEsc.push_back(EscapeSubvalue(s)); } - return JoinStrings(subvaluesEsc, ":"); + return JoinStrings(subvaluesEsc, ":"); } -TString MakeUrlAddSub(const TCgiParameters& e, const TString& key, const TString& subvalue) +TString MakeUrlAddSub(const TCgiParameters& e, const TString& key, const TString& subvalue) { - const TString& value = e.Get(key); + const TString& value = e.Get(key); auto subvalues = Subvalues(e, key); subvalues.push_back(subvalue); return MakeUrlReplace(e, key, value, MakeValue(subvalues)); } -TString MakeUrlReplaceSub(const TCgiParameters& e, const TString& key, const TString& oldSubvalue, const TString& newSubvalue) +TString MakeUrlReplaceSub(const TCgiParameters& e, const TString& key, const TString& oldSubvalue, const TString& newSubvalue) { - const TString& value = e.Get(key); + const TString& value = e.Get(key); auto subvalues = Subvalues(e, key); auto iter = std::find(subvalues.begin(), subvalues.end(), oldSubvalue); if (iter != subvalues.end()) { @@ -1085,9 +1085,9 @@ TString MakeUrlReplaceSub(const TCgiParameters& e, const TString& key, const TSt return MakeUrlReplace(e, key, value, MakeValue(subvalues)); } -TString MakeUrlEraseSub(const TCgiParameters& e, const TString& key, const TString& subvalue) +TString MakeUrlEraseSub(const TCgiParameters& e, const TString& key, const TString& subvalue) { - const TString& value = e.Get(key); + const TString& value = e.Get(key); auto subvalues = Subvalues(e, key); auto iter = std::find(subvalues.begin(), subvalues.end(), subvalue); if (iter != subvalues.end()) { @@ -1100,27 +1100,27 @@ TString MakeUrlEraseSub(const TCgiParameters& e, const TString& key, const TStri } } -template <bool sub> TString UrlAdd(const TCgiParameters& e, const TString& key, const TString& value); -template <> TString UrlAdd<false>(const TCgiParameters& e, const TString& key, const TString& value) { +template <bool sub> TString UrlAdd(const TCgiParameters& e, const TString& key, const TString& value); +template <> TString UrlAdd<false>(const TCgiParameters& e, const TString& key, const TString& value) { return MakeUrlAdd(e, key, value); } -template <> TString UrlAdd<true>(const TCgiParameters& e, const TString& key, const TString& value) { +template <> TString UrlAdd<true>(const TCgiParameters& e, const TString& key, const TString& value) { return MakeUrlAddSub(e, key, value); } -template <bool sub> TString UrlReplace(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue); -template <> TString UrlReplace<false>(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) { +template <bool sub> TString UrlReplace(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue); +template <> TString UrlReplace<false>(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) { return MakeUrlReplace(e, key, oldValue, newValue); } -template <> TString UrlReplace<true>(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) { +template <> TString UrlReplace<true>(const TCgiParameters& e, const TString& key, const TString& oldValue, const TString& newValue) { return MakeUrlReplaceSub(e, key, oldValue, newValue); } -template <bool sub> TString UrlErase(const TCgiParameters& e, const TString& key, const TString& value); -template <> TString UrlErase<false>(const TCgiParameters& e, const TString& key, const TString& value) { +template <bool sub> TString UrlErase(const TCgiParameters& e, const TString& key, const TString& value); +template <> TString UrlErase<false>(const TCgiParameters& e, const TString& key, const TString& value) { return MakeUrlErase(e, key, value); } -template <> TString UrlErase<true>(const TCgiParameters& e, const TString& key, const TString& value) { +template <> TString UrlErase<true>(const TCgiParameters& e, const TString& key, const TString& value) { return MakeUrlEraseSub(e, key, value); } @@ -1157,7 +1157,7 @@ struct TScopedHtmlInner { IOutputStream &Str; }; -TString NavbarHeader() +TString NavbarHeader() { return "<div class=\"navbar-header\">" "<a class=\"navbar-brand\" href=\"?mode=\">LWTrace</a>" @@ -1203,8 +1203,8 @@ class TPageGenBase: public std::exception {}; template <class TContainer = TNullContainer> class TPageGen: public TPageGenBase { private: - TString Content; - TString HttpResponse; + TString Content; + TString HttpResponse; public: void BuildResponse() { @@ -1216,19 +1216,19 @@ public: HttpResponse = ss.Str(); } - explicit TPageGen(const TString& content = TString()) + explicit TPageGen(const TString& content = TString()) : Content(content) { BuildResponse(); } - void Append(const TString& moreContent) + void Append(const TString& moreContent) { Content.append(moreContent); BuildResponse(); } - void Prepend(const TString& moreContent) + void Prepend(const TString& moreContent) { Content.prepend(moreContent); BuildResponse(); @@ -1264,7 +1264,7 @@ enum EStyleFlags { }; template <ui64 flags> -TString BtnClass() { +TString BtnClass() { if ((flags & SizeMask) == Large) { return "btn btn-lg"; } else if ((flags & SizeMask) == Small) { @@ -1317,17 +1317,17 @@ void DropdownItem(IOutputStream& os, const TString& text, const TString& href, b os << "<li><a href=\"" << href << "\">" << text << "</a></li>"; } -TString SuggestSelection() +TString SuggestSelection() { return "--- "; } -TString RemoveSelection() +TString RemoveSelection() { return "Remove"; } -TString GetDescription(const TString& value, const TVariants& variants) +TString GetDescription(const TString& value, const TVariants& variants) { for (const auto& var : variants) { if (value == var.first) { @@ -1342,7 +1342,7 @@ TString GetDescription(const TString& value, const TVariants& variants) template <ui64 flags, bool sub = false> void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& param, const TString& value, - const TString& text, const TVariants& variants, const TString& realValue = TString()) + const TString& text, const TVariants& variants, const TString& realValue = TString()) { HTML(os) { SelectorTitle(os, text); @@ -1373,25 +1373,25 @@ void DropdownSelector(IOutputStream& os, const TCgiParameters& e, const TString& } } -void RequireSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, - const TString& text, const TVariants& variants) +void RequireSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, + const TString& text, const TVariants& variants) { - const TString& value = e.Get(param); + const TString& value = e.Get(param); DropdownSelector<Link>(ss, e, param, value, text, variants); if (!value) { throw TPageGen<TSelectorsContainer>(ss.Str()); } } -void RequireMultipleSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, - const TString& text, const TVariants& variants) +void RequireMultipleSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, + const TString& text, const TVariants& variants) { SelectorTitle(ss, text); - TSet<TString> selectedValues; - for (const TString& subvalue : Subvalues(e, param)) { + TSet<TString> selectedValues; + for (const TString& subvalue : Subvalues(e, param)) { selectedValues.insert(subvalue); } - for (const TString& subvalue : Subvalues(e, param)) { + for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } if (selectedValues.contains("")) { @@ -1422,17 +1422,17 @@ void OptionalSelection(TStringStream& ss, const TCgiParameters& e, const TString } } -void OptionalMultipleSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, - const TString& text, const TVariants& variants) +void OptionalMultipleSelection(TStringStream& ss, const TCgiParameters& e, const TString& param, + const TString& text, const TVariants& variants) { - TSet<TString> selectedValues; - for (const TString& subvalue : Subvalues(e, param)) { + TSet<TString> selectedValues; + for (const TString& subvalue : Subvalues(e, param)) { selectedValues.insert(subvalue); } if (!selectedValues.empty()) { SelectorTitle(ss, text); } - for (const TString& subvalue : Subvalues(e, param)) { + for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } if (selectedValues.contains("")) { @@ -1444,7 +1444,7 @@ void OptionalMultipleSelection(TStringStream& ss, const TCgiParameters& e, const TVariants ListColumns(const NAnalytics::TTable& table) { - TSet<TString> cols; + TSet<TString> cols; // bool addSpecialCols = false; // if (addSpecialCols) { // cols.insert("_count"); @@ -1461,7 +1461,7 @@ TVariants ListColumns(const NAnalytics::TTable& table) return result; } -TString TaggedValue(const TString& value, const TString& tag) +TString TaggedValue(const TString& value, const TString& tag) { if (!tag) { return value; @@ -1469,7 +1469,7 @@ TString TaggedValue(const TString& value, const TString& tag) return value + "-" + tag; } -TVariants ValueVars(const TVariants& values, const TString& tag) +TVariants ValueVars(const TVariants& values, const TString& tag) { TVariants ret; for (auto& p : values) { @@ -1478,7 +1478,7 @@ TVariants ValueVars(const TVariants& values, const TString& tag) return ret; } -TVariants TagVars(const TString& value, const TVariants& tags) +TVariants TagVars(const TString& value, const TVariants& tags) { TVariants ret; for (auto& p : tags) { @@ -1496,10 +1496,10 @@ TVariants SeriesTags() } void SeriesSelectors(TStringStream& ss, const TCgiParameters& e, - const TString& xparam, const TString& yparam, const NAnalytics::TTable& data) + const TString& xparam, const TString& yparam, const NAnalytics::TTable& data) { TTags xtags; - TString xn = ParseTagsOut(e.Get(xparam), xtags); + TString xn = ParseTagsOut(e.Get(xparam), xtags); DropdownSelector<Erasable, true>(ss, e, xparam, e.Get(xparam), "with Ox:", ValueVars(ListColumns(data), JoinTags(xtags))); if (xn) { @@ -1507,13 +1507,13 @@ void SeriesSelectors(TStringStream& ss, const TCgiParameters& e, TagVars(xn, SeriesTags())); } - TString yns = e.Get(yparam); + TString yns = e.Get(yparam); SelectorTitle(ss, "and Oy:"); bool first = true; bool hasEmpty = false; for (auto& subvalue : Subvalues(e, yparam)) { TTags ytags; - TString yn = ParseTagsOut(subvalue, ytags); + TString yn = ParseTagsOut(subvalue, ytags); DropdownSelector<Erasable, true>(ss, e, yparam, subvalue, first? "": ", ", ValueVars(ListColumns(data), JoinTags(ytags))); if (yn) { @@ -1539,7 +1539,7 @@ void SeriesSelectors(TStringStream& ss, const TCgiParameters& e, class TProbesHtmlPrinter { private: - TVector<TVector<TString>> TableData; + TVector<TVector<TString>> TableData; static constexpr int TimeoutSec = 15 * 60; // default timeout public: void Push(const NLWTrace::TProbe* probe) @@ -1548,19 +1548,19 @@ public: auto& row = TableData.back(); row.emplace_back(); - TString& groups = row.back(); + TString& groups = row.back(); bool first = true; for (const char* const* i = probe->Event.Groups; *i != nullptr; ++i, first = false) { - groups.append(TString(first? "": ", ") + GroupHtml(*i)); + groups.append(TString(first? "": ", ") + GroupHtml(*i)); } row.push_back(ProbeHtml(probe->Event.GetProvider(), probe->Event.Name)); row.emplace_back(); - TString& params = row.back(); + TString& params = row.back(); first = true; for (size_t i = 0; i < probe->Event.Signature.ParamCount; i++, first = false) { - params.append(TString(first? "": ", ") + probe->Event.Signature.ParamTypes[i] + params.append(TString(first? "": ", ") + probe->Event.Signature.ParamTypes[i] + " " + probe->Event.Signature.ParamNames[i]); } @@ -1580,7 +1580,7 @@ public: TABLEBODY() { for (auto& row : TableData) { TABLER() { - for (TString& cell : row) { + for (TString& cell : row) { TABLED() { os << cell; } } } @@ -1590,7 +1590,7 @@ public: } } private: - TString GroupHtml(const TString& group) + TString GroupHtml(const TString& group) { TStringStream ss; ss << "<div class=\"dropdown\" style=\"display:inline-block\">" @@ -1619,7 +1619,7 @@ private: return ss.Str(); } - TString ProbeHtml(const TString& provider, const TString& probe) + TString ProbeHtml(const TString& provider, const TString& probe) { TStringStream ss; ss << "<div class=\"dropdown\">" @@ -1701,7 +1701,7 @@ void TDashboardRegistry::Output(TStringStream& ss) { class ILogSource { public: virtual ~ILogSource() {} - virtual TString GetId() = 0; + virtual TString GetId() = 0; virtual TInstant GetStartTime() = 0; virtual TDuration GetTimeout(TInstant now) = 0; virtual ui64 GetEventsCount() = 0; @@ -1710,7 +1710,7 @@ public: class TTraceLogSource : public ILogSource { private: - TString Id; + TString Id; const TTraceCleaner& Cleaner; const NLWTrace::TSession* Trace; public: @@ -1720,7 +1720,7 @@ public: , Trace(trace) {} - TString GetId() override + TString GetId() override { return Id; } @@ -1755,19 +1755,19 @@ public: class TSnapshotLogSource : public ILogSource { private: - TString Sid; + TString Sid; // Log should be used for read-only purpose, because it can be accessed from multiple threads // Atomic pointer is used to avoid thread-safety issues with snapshot deletion // (I hope protobuf const-implementation doesn't use any mutable non-thread-safe stuff inside) TAtomicSharedPtr<NLWTrace::TLogPb> Log; public: // Constructor should be called under SnapshotsMtx lock - TSnapshotLogSource(const TString& sid, const TAtomicSharedPtr<NLWTrace::TLogPb>& log) + TSnapshotLogSource(const TString& sid, const TAtomicSharedPtr<NLWTrace::TLogPb>& log) : Sid(sid) , Log(log) {} - TString GetId() override + TString GetId() override { return Sid + "~"; } @@ -1799,14 +1799,14 @@ private: TTraceCleaner& Cleaner; TInstant Now; using TLogSourcePtr = std::unique_ptr<ILogSource>; - TMap<TString, TLogSourcePtr> LogSources; + TMap<TString, TLogSourcePtr> LogSources; public: explicit TLogSources(TTraceCleaner& cleaner, TInstant now = TInstant::Now()) : Cleaner(cleaner) , Now(now) {} - void Push(const TString& sid, const TAtomicSharedPtr<NLWTrace::TLogPb>& log) + void Push(const TString& sid, const TAtomicSharedPtr<NLWTrace::TLogPb>& log) { TLogSourcePtr ls(new TSnapshotLogSource(sid, log)); LogSources.emplace(ls->GetId(), std::move(ls)); @@ -1847,7 +1847,7 @@ public: void Push(ILogSource* src) { - TString id = src->GetId(); + TString id = src->GetId(); Os << "<tr>"; Os << "<td>"; try { @@ -1884,7 +1884,7 @@ public: << "</tr>\n"; } private: - static TString TimeoutToString(TDuration d) + static TString TimeoutToString(TDuration d) { TStringStream ss; if (d == TDuration::Zero()) { @@ -1941,7 +1941,7 @@ TVariants ListTraces(const TLogSources& srcs) class TTimestampCutter { private: - THashMap<TThread::TId, std::pair<ui64, TInstant>> CutTsForThread; // tid -> time of first item + THashMap<TThread::TId, std::pair<ui64, TInstant>> CutTsForThread; // tid -> time of first item mutable ui64 CutTsMax = 0; mutable TInstant CutInstantMax; bool Enabled; @@ -2007,14 +2007,14 @@ private: class TLogFilter { private: struct TFilter { - TString ParamName; - TString ParamValue; + TString ParamName; + TString ParamValue; bool Parsed; TLogQuery Query; NLWTrace::TLiteral Value; - explicit TFilter(const TString& text) + explicit TFilter(const TString& text) { if (!text) { // Neither ParamName nor ParamValue is selected ParamName.clear(); @@ -2023,7 +2023,7 @@ private: return; } size_t pos = text.find('='); - if (pos == TString::npos) { // Only ParamName has been selected + if (pos == TString::npos) { // Only ParamName has been selected ParamName = text; ParamValue.clear(); Parsed = false; @@ -2038,14 +2038,14 @@ private: Value = NLWTrace::TLiteral(ParamValue); } }; - TVector<TFilter> Filters; - THashSet<const NLWTrace::TSignature*> Signatures; // Just to list param names + TVector<TFilter> Filters; + THashSet<const NLWTrace::TSignature*> Signatures; // Just to list param names TVariants ParamNames; - THashMap<TString, THashSet<TString>> FilteredParamValues; // paramName -> { paramValue } + THashMap<TString, THashSet<TString>> FilteredParamValues; // paramName -> { paramValue } public: - explicit TLogFilter(const TVector<TString>& filters) + explicit TLogFilter(const TVector<TString>& filters) { - for (const TString& subvalue : filters) { + for (const TString& subvalue : filters) { TFilter filter(subvalue); FilteredParamValues[filter.ParamName]; // just create empty set to gather values later if (filter.Parsed) { @@ -2068,11 +2068,11 @@ public: return true; } - void FilterSelectors(TStringStream& ss, const TCgiParameters& e, const TString& fparam) + void FilterSelectors(TStringStream& ss, const TCgiParameters& e, const TString& fparam) { bool first = true; bool allParsed = true; - for (const TString& subvalue : Subvalues(e, fparam)) { + for (const TString& subvalue : Subvalues(e, fparam)) { TFilter filter(subvalue); allParsed = allParsed && filter.Parsed; if (first) { @@ -2101,7 +2101,7 @@ public: const TVariants& ListParamNames() { if (ParamNames.empty()) { - THashSet<TString> paramNames; + THashSet<TString> paramNames; for (const NLWTrace::TSignature* sgn: Signatures) { for (size_t pi = 0; pi < sgn->ParamCount; pi++) { paramNames.insert(sgn->ParamNames[pi]); @@ -2114,7 +2114,7 @@ public: return ParamNames; } - bool IsFiltered(const TString& paramName) const + bool IsFiltered(const TString& paramName) const { return FilteredParamValues.contains(paramName); } @@ -2125,7 +2125,7 @@ private: { Signatures.insert(&item.Probe->Event.Signature); if (!FilteredParamValues.empty() && item.SavedParamsCount > 0) { - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); for (size_t pi = 0; pi < item.SavedParamsCount; pi++) { auto iter = FilteredParamValues.find(item.Probe->Event.Signature.ParamNames[pi]); @@ -2143,12 +2143,12 @@ private: } } - TVariants ListParamValues(const TString& paramName) const + TVariants ListParamValues(const TString& paramName) const { TVariants result; auto iter = FilteredParamValues.find(paramName); if (iter != FilteredParamValues.end()) { - for (const TString& paramValue : iter->second) { + for (const TString& paramValue : iter->second) { result.emplace_back(paramName + "=" + paramValue, paramValue); } } @@ -2231,7 +2231,7 @@ public: ", {" ; if (item.SavedParamsCount > 0) { - TString ParamValues[LWTRACE_MAX_PARAMS]; + TString ParamValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, ParamValues); bool first = true; for (size_t i = 0; i < item.SavedParamsCount; i++, first = false) { @@ -2490,19 +2490,19 @@ private: class TLogAnalyzer: public TLogFilter { private: - TMultiMap<ui64, std::pair<TThread::TId, NLWTrace::TLogItem>> Items; - TVector<NLWTrace::TTrackLog> Depot; - THashMap<TString, TTrackLogRefs> Groups; + TMultiMap<ui64, std::pair<TThread::TId, NLWTrace::TLogItem>> Items; + TVector<NLWTrace::TTrackLog> Depot; + THashMap<TString, TTrackLogRefs> Groups; NAnalytics::TTable Table; bool TableCreated = false; - TVector<TString> GroupBy; + TVector<TString> GroupBy; TTimestampCutter CutTs; public: - TLogAnalyzer(const TVector<TString>& filters, const TVector<TString>& groupBy, bool cutTs) + TLogAnalyzer(const TVector<TString>& filters, const TVector<TString>& groupBy, bool cutTs) : TLogFilter(filters) , CutTs(cutTs) { - for (const TString& groupParam : groupBy) { + for (const TString& groupParam : groupBy) { GroupBy.push_back(groupParam); } } @@ -2544,7 +2544,7 @@ private: void FillRow(NAnalytics::TRow& row, const NLWTrace::TLogItem& item) { if (item.SavedParamsCount > 0) { - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); for (size_t i = 0; i < item.SavedParamsCount; i++) { double value = FromString<double>(paramValues[i].data(), paramValues[i].size(), NAN); @@ -2558,21 +2558,21 @@ private: } } - TString GetParam(const NLWTrace::TLogItem& item, TString* paramValues, const TString& paramName) + TString GetParam(const NLWTrace::TLogItem& item, TString* paramValues, const TString& paramName) { for (size_t pi = 0; pi < item.SavedParamsCount; pi++) { if (paramName == item.Probe->Event.Signature.ParamNames[pi]) { return paramValues[pi]; } } - return TString(); + return TString(); } - TString GetGroup(const NLWTrace::TLogItem& item, TString* paramValues) + TString GetGroup(const NLWTrace::TLogItem& item, TString* paramValues) { TStringStream ss; bool first = true; - for (const TString& groupParam : GroupBy) { + for (const TString& groupParam : GroupBy) { ss << (first? "": "|") << GetParam(item, paramValues, groupParam); first = false; } @@ -2602,7 +2602,7 @@ private: void Map(TThread::TId tid, const NLWTrace::TLogItem& item) { if (item.SavedParamsCount > 0 && !CutTs.Skip(item)) { - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); TTrackLogRefs& tl = Groups[GetGroup(item, paramValues)]; tl.Items.emplace_back(tid, item); @@ -2612,7 +2612,7 @@ private: void Reduce() { for (auto& v : Groups) { - const TString& group = v.first; + const TString& group = v.first; const TTrackLogRefs& tl = v.second; Table.emplace_back(); NAnalytics::TRow& row = Table.back(); @@ -2650,7 +2650,7 @@ class TPatternTree; struct TPatternNode; struct TTrack : public TTrackLogRefs { - TString TrackId; + TString TrackId; TPatternNode* LastNode = nullptr; }; @@ -2685,7 +2685,7 @@ public: // Track classification tree node struct TPatternNode { - TString Name; + TString Name; TPatternNode* Parent = nullptr; THolder<TClassifier> Classifier; struct TDesc { @@ -2694,8 +2694,8 @@ struct TPatternNode { const NLWTrace::TProbe* Probe = nullptr; // NT_PARAM size_t Rollbacks = 0; - TString ParamName; - TString ParamValue; + TString ParamName; + TString ParamValue; } Desc; ui64 TrackCount = 0; @@ -2711,20 +2711,20 @@ struct TPatternNode { {} }; - TVector<TTrackEntry> Tracks; + TVector<TTrackEntry> Tracks; ui64 ResTotalSum = 0; ui64 ResTotalMax = 0; - TVector<ui64> ResTotalAll; + TVector<ui64> ResTotalAll; ui64 ResLastSum = 0; ui64 ResLastMax = 0; - TVector<ui64> ResLastAll; + TVector<ui64> ResLastAll; - TVector<ui64> TimelineSum; + TVector<ui64> TimelineSum; NAnalytics::TTable Slices; - TString GetPath() const + TString GetPath() const { if (Parent) { return Parent->GetPath() + Name; @@ -2798,9 +2798,9 @@ public: // Per-node classifier by probe name class TClassifyByProbe : public TClassifier { private: - using TChildren = THashMap<NLWTrace::TProbe*, TPatternNode>; + using TChildren = THashMap<NLWTrace::TProbe*, TPatternNode>; TChildren Children; - TVector<TChildren::value_type*> SortedChildren; + TVector<TChildren::value_type*> SortedChildren; public: explicit TClassifyByProbe(TPatternNode* node) : TClassifier(node, NT_PROBE) @@ -2846,12 +2846,12 @@ public: class TClassifyByParam : public TClassifier { private: size_t Rollbacks; // How many items should we look back in track to locate probe - TString ParamName; - using TChildren = THashMap<TString, TPatternNode>; + TString ParamName; + using TChildren = THashMap<TString, TPatternNode>; TChildren Children; - TVector<TChildren::value_type*> SortedChildren; + TVector<TChildren::value_type*> SortedChildren; public: - TClassifyByParam(TPatternNode* node, size_t rollbacks, const TString& paramName) + TClassifyByParam(TPatternNode* node, size_t rollbacks, const TString& paramName) : TClassifier(node, NT_PARAM, true) , Rollbacks(rollbacks) , ParamName(paramName) @@ -2864,8 +2864,8 @@ public: const NLWTrace::TLogItem& item = *(cur - Rollbacks); WWW_CHECK(item.SavedParamsCount > 0, "classify by params on probe w/o param loggging in node '%s'", Node->GetPath().data()); - TString paramValues[LWTRACE_MAX_PARAMS]; - TString* paramValue = nullptr; + TString paramValues[LWTRACE_MAX_PARAMS]; + TString* paramValue = nullptr; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); for (size_t pi = 0; pi < item.SavedParamsCount; pi++) { if (item.Probe->Event.Signature.ParamNames[pi] == ParamName) { @@ -2906,18 +2906,18 @@ public: }; private: TPatternNode Root; - THashMap<TString, std::pair<size_t, TString>> ParamClassifiers; // path -> (rollbacks, param) - TString SelectedPattern; + THashMap<TString, std::pair<size_t, TString>> ParamClassifiers; // path -> (rollbacks, param) + TString SelectedPattern; TPatternNode* SelectedNode = nullptr; - TVector<ui64> Timeline; // Just to avoid reallocations + TVector<ui64> Timeline; // Just to avoid reallocations public: TPatternTree(const TCgiParameters& e) { - for (const TString& cl : Subvalues(e, "classify")) { + for (const TString& cl : Subvalues(e, "classify")) { size_t at = cl.find_last_of('@'); - if (at != TString::npos) { + if (at != TString::npos) { size_t dot = cl.find('.', at + 1); - if (dot != TString::npos) { + if (dot != TString::npos) { size_t rollbacks = FromString<size_t>(cl.substr(at + 1, dot - at - 1)); ParamClassifiers[cl.substr(0, at)] = std::make_pair(rollbacks, cl.substr(dot + 1)); } @@ -2950,7 +2950,7 @@ public: } // Register track in given node - void AddTrackToNode(TPatternNode* node, TTrack& track, ui64 resTotal, TVector<ui64>& timeline) + void AddTrackToNode(TPatternNode* node, TTrack& track, ui64 resTotal, TVector<ui64>& timeline) { if (!SelectedNode) { if (node->GetPath() == SelectedPattern) { @@ -3012,7 +3012,7 @@ public: #define WWW_CHECK_PATTERN(str) if (!CheckPattern(pi, pe, (str))) { return false; } - bool MatchTrack(const TTrack& track, const TString& patternStr) + bool MatchTrack(const TTrack& track, const TString& patternStr) { const char* pi = patternStr.data(); const char* pe = pi + patternStr.size(); @@ -3065,8 +3065,8 @@ public: if (mitem.SavedParamsCount == 0) { return false; } - TString paramValues[LWTRACE_MAX_PARAMS]; - TString* paramValue = nullptr; + TString paramValues[LWTRACE_MAX_PARAMS]; + TString* paramValue = nullptr; mitem.Probe->Event.Signature.SerializeParams(mitem.Params, paramValues); for (size_t pi = 0; pi < mitem.SavedParamsCount; pi++) { if (mitem.Probe->Event.Signature.ParamNames[pi] == paramName) { @@ -3175,25 +3175,25 @@ private: class TLogTrackExtractor: public TLogFilter { private: // Data storage - TMultiMap<ui64, std::pair<TThread::TId, NLWTrace::TLogItem>> Items; - TVector<NLWTrace::TTrackLog> Depot; + TMultiMap<ui64, std::pair<TThread::TId, NLWTrace::TLogItem>> Items; + TVector<NLWTrace::TTrackLog> Depot; // Data refs organized in tracks - THashMap<TString, TTrack> Tracks; - TVector<TTrack> TracksFromDepot; + THashMap<TString, TTrack> Tracks; + TVector<TTrack> TracksFromDepot; // Analysis - TVector<TString> GroupBy; - THashSet<TString> TrackIds; // The same content as in GroupBy + TVector<TString> GroupBy; + THashSet<TString> TrackIds; // The same content as in GroupBy TTimestampCutter CutTs; TPatternTree Tree; public: - TLogTrackExtractor(const TCgiParameters& e, const TVector<TString>& filters, const TVector<TString>& groupBy) + TLogTrackExtractor(const TCgiParameters& e, const TVector<TString>& filters, const TVector<TString>& groupBy) : TLogFilter(filters) , CutTs(true) // Always cut input data for tracks , Tree(e) { - for (const TString& groupParam : groupBy) { + for (const TString& groupParam : groupBy) { GroupBy.push_back(groupParam); TrackIds.insert(groupParam); } @@ -3305,7 +3305,7 @@ public: WWW_CHECK(percentile >= 0.0 && percentile <= 100.0, "wrong percentile: %lf", percentile); ui64 row = 0; - TVector<ui64> chain; + TVector<ui64> chain; HTML(os) { TABLE_CLASS("tracks-tree") { TABLEHEAD() { @@ -3333,11 +3333,11 @@ public: return; } Tree.Traverse([&] (TPatternNode* node) { - TString parentClass; + TString parentClass; if (!chain.empty()) { parentClass = " treegrid-parent-" + ToString(chain.back()); } - TString selectedClass; + TString selectedClass; if (e.Get("pattern") == node->GetPath()) { selectedClass = " danger"; } @@ -3399,7 +3399,7 @@ public: auto first = TTrackTr::begin(*track); auto last = TTrackTr::rbegin(*track); - TString name = track->LastNode->GetPath(); + TString name = track->LastNode->GetPath(); const NLWTrace::TLogItem& firstItem = *first; TThread::TId firstTid = first->ThreadId; @@ -3410,7 +3410,7 @@ public: tr.Add(cur->ThreadId, item.TimestampCycles, "i", "event", &item, GetProbeName(item.Probe)); - TString sliceName = GetProbeName(item.Probe); + TString sliceName = GetProbeName(item.Probe); auto next = cur + 1; if (next != end) { @@ -3498,8 +3498,8 @@ private: void OutputPattern(IOutputStream& os, const TCgiParameters& e, TPatternNode* node) { // Fill pattern name - TString patternName; - TString patternTitle; + TString patternName; + TString patternTitle; switch (node->Desc.Type) { case NT_ROOT: patternName = "All Tracks"; @@ -3549,7 +3549,7 @@ private: os << "<li class=\"dropdown-header\">" << GetProbeName(probe) << "</li>"; const NLWTrace::TSignature* sgn = &probe->Event.Signature; for (size_t pi = 0; pi < sgn->ParamCount; pi++) { - TString param = sgn->ParamNames[pi]; + TString param = sgn->ParamNames[pi]; if (TrackIds.contains(param) || IsFiltered(param)) { continue; } @@ -3589,7 +3589,7 @@ private: "</div>"; } - using TTimeline = TVector<std::pair<TPatternNode*, double>>; + using TTimeline = TVector<std::pair<TPatternNode*, double>>; TTimeline MakeTimeline(TPatternNode* node) { @@ -3648,14 +3648,14 @@ private: os << "</div>"; } - TString FormatTimelineTooltip(double time, double prevTime, TPatternNode* node) + TString FormatTimelineTooltip(double time, double prevTime, TPatternNode* node) { return FormatCycles(time - prevTime) + ": " + FormatCycles(prevTime) + " -> " + FormatCycles(time) + "(" + node->Name + ")"; } - TString FormatFloat(double value) + TString FormatFloat(double value) { if (value == 0.0) { return "0"; @@ -3695,7 +3695,7 @@ private: } } - TString FormatCycles(double timeCycles) + TString FormatCycles(double timeCycles) { double timeSec = timeCycles / NHPTimer::GetClockRate(); if (timeSec > 1.0) { @@ -3733,21 +3733,21 @@ private: } } - TString GetParam(const NLWTrace::TLogItem& item, TString* paramValues, const TString& paramName) + TString GetParam(const NLWTrace::TLogItem& item, TString* paramValues, const TString& paramName) { for (size_t pi = 0; pi < item.SavedParamsCount; pi++) { if (paramName == item.Probe->Event.Signature.ParamNames[pi]) { return paramValues[pi]; } } - return TString(); + return TString(); } - TString GetGroup(const NLWTrace::TLogItem& item, TString* paramValues) + TString GetGroup(const NLWTrace::TLogItem& item, TString* paramValues) { TStringStream ss; bool first = true; - for (const TString& groupParam : GroupBy) { + for (const TString& groupParam : GroupBy) { ss << (first? "": "|") << GetParam(item, paramValues, groupParam); first = false; } @@ -3759,7 +3759,7 @@ private: // Ensure cyclic per thread lwtrace logs wont drop *inner* items of a track // (note that some *starting* items can be dropped) if (item.SavedParamsCount > 0 && !CutTs.Skip(item)) { - TString paramValues[LWTRACE_MAX_PARAMS]; + TString paramValues[LWTRACE_MAX_PARAMS]; item.Probe->Event.Signature.SerializeParams(item.Params, paramValues); Tracks[GetGroup(item, paramValues)].Items.emplace_back(tid, item); } @@ -3767,7 +3767,7 @@ private: }; NLWTrace::TProbeRegistry g_Probes; -TString g_sanitizerTest("TString g_sanitizerTest"); +TString g_sanitizerTest("TString g_sanitizerTest"); NLWTrace::TManager g_SafeManager(g_Probes, false); NLWTrace::TManager g_UnsafeManager(g_Probes, true); TDashboardRegistry g_DashboardRegistry; @@ -3775,10 +3775,10 @@ TDashboardRegistry g_DashboardRegistry; class TLWTraceMonPage : public NMonitoring::IMonPage { private: NLWTrace::TManager* TraceMngr; - TString StartTime; + TString StartTime; TTraceCleaner Cleaner; TMutex SnapshotsMtx; - THashMap<TString, TAtomicSharedPtr<NLWTrace::TLogPb>> Snapshots; + THashMap<TString, TAtomicSharedPtr<NLWTrace::TLogPb>> Snapshots; public: explicit TLWTraceMonPage(bool allowUnsafe = false) : NMonitoring::IMonPage("trace", "Tracing") @@ -3842,7 +3842,7 @@ public: private: void OutputNavbar(const NMonitoring::IMonHttpRequest& request, IOutputStream& out) { - TString active = " class=\"active\""; + TString active = " class=\"active\""; out << "<nav class=\"navbar navbar-default\"><div class=\"container-fluid\">" << NavbarHeader() << @@ -4057,9 +4057,9 @@ private: if (request.GetParams().NumOfValues("id") == 0) { ythrow yexception() << "Cgi-parameter 'id' is not specified"; } else { - TString id = request.GetParams().Get("id"); + TString id = request.GetParams().Get("id"); const NLWTrace::TQuery& query = TraceMngr->GetTrace(id)->GetQuery(); - TString queryStr = query.DebugString(); + TString queryStr = query.DebugString(); WWW_HTML(out) { out << "<h2>Trace Query: " << id << "</h2><pre>" << queryStr; } @@ -4112,7 +4112,7 @@ private: Subvalues(request.GetParams(), "f"), Subvalues(request.GetParams(), "g") )); - for (const TString& id : Subvalues(request.GetParams(), "id")) { + for (const TString& id : Subvalues(request.GetParams(), "id")) { CheckAdHocTrace(id, TDuration::Minutes(1)); TraceMngr->ReadLog(id, *logTracks); TraceMngr->ReadDepot(id, *logTracks); @@ -4123,7 +4123,7 @@ private: Subvalues(request.GetParams(), "g"), request.GetParams().Get("cutts") == "y" )); - for (const TString& id : Subvalues(request.GetParams(), "id")) { + for (const TString& id : Subvalues(request.GetParams(), "id")) { CheckAdHocTrace(id, TDuration::Minutes(1)); TraceMngr->ReadLog(id, *logAnalyzer); TraceMngr->ReadDepot(id, *logAnalyzer); @@ -4148,7 +4148,7 @@ private: DropdownSelector<Link>(out, e, "reverse", e.Get("reverse"), "", variants); } - TString aggr = e.Get("aggr"); + TString aggr = e.Get("aggr"); TVariants variants1; // MSVS2013 doesn't understand complex initializer lists variants1.emplace_back("", "without aggregation"); variants1.emplace_back("hist", "as histogram"); @@ -4173,8 +4173,8 @@ private: DropdownSelector<Link>(out, e, "ile", e.Get("ile"), "and show", ileVars); out << "%-ile. "; TString patternAnalyzer; - TString distBy; - TString distType; + TString distBy; + TString distType; if (e.Get("pattern")) { TVariants analyzePatternVars; analyzePatternVars.emplace_back("resTotal", "distribution by total"); @@ -4229,7 +4229,7 @@ private: } } - TString selectors = out.Str(); + TString selectors = out.Str(); out.Clear(); out << NMonitoring::HTTPOKHTML; out << "<!DOCTYPE html>" << Endl; @@ -4320,7 +4320,7 @@ private: } else if (aggr == "hist") { RequireSelection(out, e, "bn", "by", logFilter->ListParamNames()); const NAnalytics::TTable& inputTable = logAnalyzer->GetTable(); - TString bn = e.Get("bn"); + TString bn = e.Get("bn"); double b1 = e.Get("b1")? FromString<double>(e.Get("b1")): MinValue(bn, inputTable); double b2 = e.Get("b2")? FromString<double>(e.Get("b2")): MaxValue(bn, inputTable); if (isfinite(b1) && isfinite(b2)) { @@ -4332,9 +4332,9 @@ private: } } - TString xn = e.Get("xn"); + TString xn = e.Get("xn"); - TString outFormat = e.Get("out"); + TString outFormat = e.Get("out"); TVariants variants2; variants2.emplace_back("html", "table"); variants2.emplace_back("flot", "chart"); @@ -4345,12 +4345,12 @@ private: RequireSelection(out, e, "out", "and show", variants2); if (outFormat == "csv") { - TString sep = e.Get("sep")? e.Get("sep"): TString("\t"); + TString sep = e.Get("sep")? e.Get("sep"): TString("\t"); out.Clear(); out << NMonitoring::HTTPOKTEXT; out << ToCsv(data, sep, e.Get("head") != "n"); } else if (outFormat == "html") { - TString selectors = out.Str(); + TString selectors = out.Str(); out.Clear(); WWW_HTML(out) { // Wrap selectors with navbar @@ -4366,7 +4366,7 @@ private: out << ToJsonFlot(data, xn, SplitString(e.Get("yns"), ":")); } else if (outFormat == "flot") { SeriesSelectors(out, e, "xn", "yns", data); - TString selectors = out.Str(); + TString selectors = out.Str(); TVector<TString> ynos = SplitString(e.Get("yns"), ":"); out.Clear(); @@ -4525,12 +4525,12 @@ private: void PostNew(const NMonitoring::IMonHttpRequest& request, IOutputStream& out) { WWW_CHECK(request.GetPostParams().Has("id"), "POST parameter 'id' is not specified"); - const TString& id = request.GetPostParams().Get("id"); + const TString& id = request.GetPostParams().Get("id"); bool ui = (request.GetParams().Get("ui") == "y"); TDuration timeout = GetGetTimeout(request); if (!CheckAdHocTrace(id, timeout)) { NLWTrace::TQuery query; - TString queryStr = request.GetPostParams().Get("query"); + TString queryStr = request.GetPostParams().Get("query"); if (!ui) { queryStr = Base64Decode(queryStr); // Needed for trace.sh (historically) } @@ -4565,7 +4565,7 @@ private: void PostDelete(const NMonitoring::IMonHttpRequest& request, IOutputStream& out) { WWW_CHECK(request.GetPostParams().Has("id"), "POST parameter 'id' is not specified"); - const TString& id = request.GetPostParams().Get("id"); + const TString& id = request.GetPostParams().Get("id"); bool ui = (request.GetParams().Get("ui") == "y"); TraceMngr->Delete(id); Cleaner.Forget(id); @@ -4592,14 +4592,14 @@ private: void PostSnapshot(const NMonitoring::IMonHttpRequest& request, IOutputStream& out) { WWW_CHECK(request.GetPostParams().Has("id"), "POST parameter 'id' is not specified"); - const TString& id = request.GetPostParams().Get("id"); + const TString& id = request.GetPostParams().Get("id"); bool ui = (request.GetParams().Get("ui") == "y"); TInstant now = TInstant::Now(); TGuard<TMutex> g(SnapshotsMtx); const NLWTrace::TSession* trace = TraceMngr->GetTrace(id); struct tm tm0; - TString sid = id + Strftime("_%Y%m%d-%H%M%S", now.GmTime(&tm0)); + TString sid = id + Strftime("_%Y%m%d-%H%M%S", now.GmTime(&tm0)); TAtomicSharedPtr<NLWTrace::TLogPb>& pbPtr = Snapshots[sid]; pbPtr.Reset(new NLWTrace::TLogPb()); trace->ToProtobuf(*pbPtr); @@ -4627,7 +4627,7 @@ private: void PostSetTimeout(const NMonitoring::IMonHttpRequest& request, IOutputStream& out) { WWW_CHECK(request.GetPostParams().Has("id"), "POST parameter 'id' is not specified"); - const TString& id = request.GetPostParams().Get("id"); + const TString& id = request.GetPostParams().Get("id"); TDuration timeout = GetGetTimeout(request); bool ui = (request.GetParams().Get("ui") == "y"); Cleaner.Postpone(id, timeout, true); @@ -4657,7 +4657,7 @@ private: private: // Returns true iff trace is ad-hoc and ensures trace is created - bool CheckAdHocTrace(const TString& id, TDuration timeout) + bool CheckAdHocTrace(const TString& id, TDuration timeout) { TAdHocTraceConfig cfg; if (cfg.ParseId(id)) { diff --git a/library/cpp/lwtrace/signature.h b/library/cpp/lwtrace/signature.h index 868bd9bcf2..cc11a93536 100644 --- a/library/cpp/lwtrace/signature.h +++ b/library/cpp/lwtrace/signature.h @@ -5,7 +5,7 @@ #include <library/cpp/lwtrace/protos/lwtrace.pb.h> #include <util/generic/cast.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/typetraits.h> #include <util/string/builder.h> #include <util/string/cast.h> diff --git a/library/cpp/lwtrace/stderr_writer.cpp b/library/cpp/lwtrace/stderr_writer.cpp index 6e5654c338..92f05dfdbf 100644 --- a/library/cpp/lwtrace/stderr_writer.cpp +++ b/library/cpp/lwtrace/stderr_writer.cpp @@ -5,7 +5,7 @@ using namespace NLWTrace; bool TStderrActionExecutor::DoExecute(TOrbit&, const TParams& params) { - TString ParamValues[LWTRACE_MAX_PARAMS]; + TString ParamValues[LWTRACE_MAX_PARAMS]; Probe->Event.Signature.SerializeParams(params, ParamValues); TStringStream ss; diff --git a/library/cpp/lwtrace/symbol.cpp b/library/cpp/lwtrace/symbol.cpp index 456652bcd0..b1840d5774 100644 --- a/library/cpp/lwtrace/symbol.cpp +++ b/library/cpp/lwtrace/symbol.cpp @@ -5,11 +5,11 @@ template <> NLWTrace::TSymbol FromStringImpl(const char*, size_t) { - static TString err("ERROR_dynamic_symbol"); + static TString err("ERROR_dynamic_symbol"); return NLWTrace::TSymbol(&err); } template <> void Out<NLWTrace::TSymbol>(IOutputStream& o, TTypeTraits<NLWTrace::TSymbol>::TFuncParam t) { - Out<TString>(o, *t.Str); + Out<TString>(o, *t.Str); } diff --git a/library/cpp/lwtrace/symbol.h b/library/cpp/lwtrace/symbol.h index ef9e6cdf94..76cbee7c01 100644 --- a/library/cpp/lwtrace/symbol.h +++ b/library/cpp/lwtrace/symbol.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/builder.h> #include <util/system/src_location.h> @@ -17,7 +17,7 @@ #define LWTRACE_LOCATION_SYMBOL \ [](const char* func) { \ - static TString _holder(TStringBuilder() << func << " (" << __LOCATION__ << ")"); \ + static TString _holder(TStringBuilder() << func << " (" << __LOCATION__ << ")"); \ return ::NLWTrace::TSymbol(&_holder); \ }(Y_FUNC_SIGNATURE) /**/ diff --git a/library/cpp/lwtrace/tests/trace_tests.cpp b/library/cpp/lwtrace/tests/trace_tests.cpp index 6762e344a7..8d3c65f48c 100644 --- a/library/cpp/lwtrace/tests/trace_tests.cpp +++ b/library/cpp/lwtrace/tests/trace_tests.cpp @@ -16,7 +16,7 @@ PROBE(SymbolParam, GROUPS("Group"), TYPES(NLWTrace::TSymbol), NAMES("symbol")) \ PROBE(CheckParam, GROUPS("Group"), TYPES(NLWTrace::TCheck), NAMES("value")) \ EVENT(TwoParamsEvent, GROUPS("Group"), TYPES(int, TString), NAMES("param1", "param2")) \ - EVENT(TwoParamsCheckEvent, GROUPS("Group"), TYPES(NLWTrace::TCheck, TString), NAMES("param1", "param2")) \ + EVENT(TwoParamsCheckEvent, GROUPS("Group"), TYPES(NLWTrace::TCheck, TString), NAMES("param1", "param2")) \ /**/ LWTRACE_DECLARE_PROVIDER(LWTRACE_TESTS_PROVIDER) diff --git a/library/cpp/messagebus/acceptor_status.cpp b/library/cpp/messagebus/acceptor_status.cpp index 5006ff68ae..e9818e03d3 100644 --- a/library/cpp/messagebus/acceptor_status.cpp +++ b/library/cpp/messagebus/acceptor_status.cpp @@ -40,7 +40,7 @@ TAcceptorStatus& TAcceptorStatus::operator+=(const TAcceptorStatus& that) { return *this; } -TString TAcceptorStatus::PrintToString() const { +TString TAcceptorStatus::PrintToString() const { TStringStream ss; if (!Summary) { diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 7a2227a458..eaf0751709 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -249,11 +249,11 @@ ui32 TExecutor::GetMaxQueueSizeAndClear() const { return max; } -TString TExecutor::GetStatus() const { +TString TExecutor::GetStatus() const { return GetStatusRecordInternal().Status; } -TString TExecutor::GetStatusSingleLine() const { +TString TExecutor::GetStatusSingleLine() const { TStringStream ss; ss << "work items: " << GetWorkQueueSize(); return ss.Str(); diff --git a/library/cpp/messagebus/actor/ring_buffer.h b/library/cpp/messagebus/actor/ring_buffer.h index ec5706f7c7..937d8d5a3d 100644 --- a/library/cpp/messagebus/actor/ring_buffer.h +++ b/library/cpp/messagebus/actor/ring_buffer.h @@ -14,7 +14,7 @@ private: ui32 Capacity; ui32 WritePos; ui32 ReadPos; - TVector<T> Data; + TVector<T> Data; void StateCheck() const { Y_ASSERT(Capacity == Data.size()); @@ -39,7 +39,7 @@ private: } ui32 newCapacity = 1u << newCapacityPow; ui32 newCapacityMask = newCapacity - 1u; - TVector<T> newData(newCapacity); + TVector<T> newData(newCapacity); ui32 oldSize = Size(); // Copy old elements for (size_t i = 0; i < oldSize; ++i) { diff --git a/library/cpp/messagebus/actor/temp_tls_vector.h b/library/cpp/messagebus/actor/temp_tls_vector.h index 675d92f5b0..7d9fbce088 100644 --- a/library/cpp/messagebus/actor/temp_tls_vector.h +++ b/library/cpp/messagebus/actor/temp_tls_vector.h @@ -10,15 +10,15 @@ class TTempTlsVector { private: struct TTagForTls {}; - TVectorType<T, std::allocator<T>>* Vector; + TVectorType<T, std::allocator<T>>* Vector; public: - TVectorType<T, std::allocator<T>>* GetVector() { + TVectorType<T, std::allocator<T>>* GetVector() { return Vector; } TTempTlsVector() { - Vector = FastTlsSingletonWithTag<TVectorType<T, std::allocator<T>>, TTagForTls>(); + Vector = FastTlsSingletonWithTag<TVectorType<T, std::allocator<T>>, TTagForTls>(); Y_ASSERT(Vector->empty()); } @@ -30,7 +30,7 @@ public: Vector->clear(); } - size_t Capacity() const noexcept { + size_t Capacity() const noexcept { return Vector->capacity(); } diff --git a/library/cpp/messagebus/actor/thread_extra.cpp b/library/cpp/messagebus/actor/thread_extra.cpp index 048480f255..826ae45670 100644 --- a/library/cpp/messagebus/actor/thread_extra.cpp +++ b/library/cpp/messagebus/actor/thread_extra.cpp @@ -7,10 +7,10 @@ namespace { #ifdef _linux_ - TString GetExecName() { - TString execPath = GetExecPath(); + TString GetExecName() { + TString execPath = GetExecPath(); size_t lastSlash = execPath.find_last_of('/'); - if (lastSlash == TString::npos) { + if (lastSlash == TString::npos) { return execPath; } else { return execPath.substr(lastSlash + 1); diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index fbbbb106c9..9b430033f3 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -16,7 +16,7 @@ TBusSessionConfig::TBusSessionConfig() { } -TString TBusSessionConfig::PrintToString() const { +TString TBusSessionConfig::PrintToString() const { TStringStream ss; BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_PRINT, ) return ss.Str(); @@ -66,7 +66,7 @@ static i64 ParseWithKmgSuffixS(const char* option) { } void TBusSessionConfig::ConfigureLastGetopt(NLastGetopt::TOpts& opts, - const TString& prefix) { + const TString& prefix) { opts.AddLongOption(prefix + "total-timeout") .RequiredArgument("MILLISECONDS") .DefaultValue(ToString(TotalTimeout)) diff --git a/library/cpp/messagebus/config/session_config.h b/library/cpp/messagebus/config/session_config.h index 84753350a9..2763a125f2 100644 --- a/library/cpp/messagebus/config/session_config.h +++ b/library/cpp/messagebus/config/session_config.h @@ -5,7 +5,7 @@ #include <library/cpp/getopt/last_getopt.h> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace NBus { #define BUS_SESSION_CONFIG_MAP(XX, comma) \ diff --git a/library/cpp/messagebus/coreconn.h b/library/cpp/messagebus/coreconn.h index fca228d82e..26e1dab675 100644 --- a/library/cpp/messagebus/coreconn.h +++ b/library/cpp/messagebus/coreconn.h @@ -13,7 +13,7 @@ #include <util/generic/list.h> #include <util/generic/map.h> #include <util/generic/set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/network/address.h> #include <util/network/ip.h> diff --git a/library/cpp/messagebus/duration_histogram.h b/library/cpp/messagebus/duration_histogram.h index ed060b0101..6b2f6a9bda 100644 --- a/library/cpp/messagebus/duration_histogram.h +++ b/library/cpp/messagebus/duration_histogram.h @@ -2,7 +2,7 @@ #include <util/datetime/base.h> #include <util/generic/bitops.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <array> @@ -39,7 +39,7 @@ struct TDurationHistogram { return *this; } - static TString LabelBefore(unsigned i); + static TString LabelBefore(unsigned i); - TString PrintToString() const; + TString PrintToString() const; }; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index f685135bed..009b5813a6 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -70,7 +70,7 @@ public: TChannelPtr Register(TSocket socket, TEventHandlerPtr eventHandler, void* cookie); void Unregister(SOCKET socket); - typedef THashMap<SOCKET, TChannelPtr> TData; + typedef THashMap<SOCKET, TChannelPtr> TData; void AddToPoller(SOCKET socket, void* cookie, int flags); diff --git a/library/cpp/messagebus/key_value_printer.cpp b/library/cpp/messagebus/key_value_printer.cpp index c8592145c7..41c2a19f57 100644 --- a/library/cpp/messagebus/key_value_printer.cpp +++ b/library/cpp/messagebus/key_value_printer.cpp @@ -2,7 +2,7 @@ #include <util/stream/format.h> -TKeyValuePrinter::TKeyValuePrinter(const TString& sep) +TKeyValuePrinter::TKeyValuePrinter(const TString& sep) : Sep(sep) { } @@ -10,15 +10,15 @@ TKeyValuePrinter::TKeyValuePrinter(const TString& sep) TKeyValuePrinter::~TKeyValuePrinter() { } -void TKeyValuePrinter::AddRowImpl(const TString& key, const TString& value, bool alignLeft) { +void TKeyValuePrinter::AddRowImpl(const TString& key, const TString& value, bool alignLeft) { Keys.push_back(key); Values.push_back(value); AlignLefts.push_back(alignLeft); } -TString TKeyValuePrinter::PrintToString() const { +TString TKeyValuePrinter::PrintToString() const { if (Keys.empty()) { - return TString(); + return TString(); } size_t keyWidth = 0; diff --git a/library/cpp/messagebus/key_value_printer.h b/library/cpp/messagebus/key_value_printer.h index bca1fde50e..82b63898ce 100644 --- a/library/cpp/messagebus/key_value_printer.h +++ b/library/cpp/messagebus/key_value_printer.h @@ -1,19 +1,19 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/typetraits.h> #include <util/generic/vector.h> #include <util/string/cast.h> class TKeyValuePrinter { private: - TString Sep; - TVector<TString> Keys; - TVector<TString> Values; - TVector<bool> AlignLefts; + TString Sep; + TVector<TString> Keys; + TVector<TString> Values; + TVector<bool> AlignLefts; public: - TKeyValuePrinter(const TString& sep = TString(": ")); + TKeyValuePrinter(const TString& sep = TString(": ")); ~TKeyValuePrinter(); template <typename TKey, typename TValue> @@ -21,8 +21,8 @@ public: return AddRowImpl(ToString(key), ToString(value), leftAlign); } - TString PrintToString() const; + TString PrintToString() const; private: - void AddRowImpl(const TString& key, const TString& value, bool leftAlign); + void AddRowImpl(const TString& key, const TString& value, bool leftAlign); }; diff --git a/library/cpp/messagebus/lfqueue_batch.h b/library/cpp/messagebus/lfqueue_batch.h index 8128d3154d..eeb921dc7c 100644 --- a/library/cpp/messagebus/lfqueue_batch.h +++ b/library/cpp/messagebus/lfqueue_batch.h @@ -8,7 +8,7 @@ template <typename T, template <typename, class> class TVectorType = TVector> class TLockFreeQueueBatch { private: - TLockFreeStack<TVectorType<T, std::allocator<T>>*> Stack; + TLockFreeStack<TVectorType<T, std::allocator<T>>*> Stack; public: bool IsEmpty() { @@ -19,11 +19,11 @@ public: Stack.Enqueue(vec.Release()); } - void DequeueAllSingleConsumer(TVectorType<T, std::allocator<T>>* r) { - TTempTlsVector<TVectorType<T, std::allocator<T>>*> vs; + void DequeueAllSingleConsumer(TVectorType<T, std::allocator<T>>* r) { + TTempTlsVector<TVectorType<T, std::allocator<T>>*> vs; Stack.DequeueAllSingleConsumer(vs.GetVector()); - for (typename TVector<TVectorType<T, std::allocator<T>>*>::reverse_iterator i = vs.GetVector()->rbegin(); + for (typename TVector<TVectorType<T, std::allocator<T>>*>::reverse_iterator i = vs.GetVector()->rbegin(); i != vs.GetVector()->rend(); ++i) { if (i == vs.GetVector()->rend()) { r->swap(**i); diff --git a/library/cpp/messagebus/lfqueue_batch_ut.cpp b/library/cpp/messagebus/lfqueue_batch_ut.cpp index f80434c0d4..dac7013343 100644 --- a/library/cpp/messagebus/lfqueue_batch_ut.cpp +++ b/library/cpp/messagebus/lfqueue_batch_ut.cpp @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { q.EnqueueAll(v); } - TVector<unsigned> r; + TVector<unsigned> r; q.DequeueAllSingleConsumer(&r); UNIT_ASSERT_VALUES_EQUAL(2u, r.size()); @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueBatch) { q.EnqueueAll(v); } - TVector<unsigned> r; + TVector<unsigned> r; q.DequeueAllSingleConsumer(&r); UNIT_ASSERT_VALUES_EQUAL(5u, r.size()); diff --git a/library/cpp/messagebus/local_flags.cpp b/library/cpp/messagebus/local_flags.cpp index 877e533f76..6725d9b0c0 100644 --- a/library/cpp/messagebus/local_flags.cpp +++ b/library/cpp/messagebus/local_flags.cpp @@ -6,7 +6,7 @@ using namespace NBus; using namespace NBus::NPrivate; -TString NBus::NPrivate::LocalFlagSetToString(ui32 flags0) { +TString NBus::NPrivate::LocalFlagSetToString(ui32 flags0) { if (flags0 == 0) { return "0"; } diff --git a/library/cpp/messagebus/local_flags.h b/library/cpp/messagebus/local_flags.h index f589283188..65c113a63f 100644 --- a/library/cpp/messagebus/local_flags.h +++ b/library/cpp/messagebus/local_flags.h @@ -2,7 +2,7 @@ #include <library/cpp/deprecated/enum_codegen/enum_codegen.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/output.h> namespace NBus { diff --git a/library/cpp/messagebus/mb_lwtrace.h b/library/cpp/messagebus/mb_lwtrace.h index e62728b265..597a02e7a6 100644 --- a/library/cpp/messagebus/mb_lwtrace.h +++ b/library/cpp/messagebus/mb_lwtrace.h @@ -5,7 +5,7 @@ #include <util/generic/string.h> #define LWTRACE_MESSAGEBUS_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ - PROBE(Error, GROUPS("MessagebusRare"), TYPES(TString, TString, TString), NAMES("status", "address", "misc")) \ + PROBE(Error, GROUPS("MessagebusRare"), TYPES(TString, TString, TString), NAMES("status", "address", "misc")) \ PROBE(ServerUnknownVersion, GROUPS("MessagebusRare"), TYPES(TString, ui32), NAMES("address", "version")) \ PROBE(Accepted, GROUPS("MessagebusRare"), TYPES(TString), NAMES("address")) \ PROBE(Disconnected, GROUPS("MessagebusRare"), TYPES(TString), NAMES("address")) \ diff --git a/library/cpp/messagebus/message.h b/library/cpp/messagebus/message.h index 005ca10c65..dee829a617 100644 --- a/library/cpp/messagebus/message.h +++ b/library/cpp/messagebus/message.h @@ -9,7 +9,7 @@ #include <util/generic/array_ref.h> #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/system/defaults.h> #include <util/system/type_name.h> #include <util/system/yassert.h> diff --git a/library/cpp/messagebus/message_counter.cpp b/library/cpp/messagebus/message_counter.cpp index 04d9343f6a..c2e31b77ca 100644 --- a/library/cpp/messagebus/message_counter.cpp +++ b/library/cpp/messagebus/message_counter.cpp @@ -23,7 +23,7 @@ TMessageCounter& TMessageCounter::operator+=(const TMessageCounter& that) { return *this; } -TString TMessageCounter::ToString(bool reader) const { +TString TMessageCounter::ToString(bool reader) const { if (reader) { Y_ASSERT(CountCompressionRequests == 0); } diff --git a/library/cpp/messagebus/message_status_counter.cpp b/library/cpp/messagebus/message_status_counter.cpp index 891c8f5bb2..d76732efca 100644 --- a/library/cpp/messagebus/message_status_counter.cpp +++ b/library/cpp/messagebus/message_status_counter.cpp @@ -21,7 +21,7 @@ TMessageStatusCounter& TMessageStatusCounter::operator+=(const TMessageStatusCou return *this; } -TString TMessageStatusCounter::PrintToString() const { +TString TMessageStatusCounter::PrintToString() const { TStringStream ss; TKeyValuePrinter p; bool hasNonZeros = false; diff --git a/library/cpp/messagebus/message_status_counter.h b/library/cpp/messagebus/message_status_counter.h index e8ba2fdd31..7288d62455 100644 --- a/library/cpp/messagebus/message_status_counter.h +++ b/library/cpp/messagebus/message_status_counter.h @@ -4,7 +4,7 @@ #include <library/cpp/messagebus/monitoring/mon_proto.pb.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <array> diff --git a/library/cpp/messagebus/messqueue.cpp b/library/cpp/messagebus/messqueue.cpp index 3474d62705..cc9b53391b 100644 --- a/library/cpp/messagebus/messqueue.cpp +++ b/library/cpp/messagebus/messqueue.cpp @@ -36,7 +36,7 @@ TBusMessageQueuePtr NBus::CreateMessageQueue(const char* name) { } namespace { - TBusQueueConfig QueueConfigFillDefaults(const TBusQueueConfig& orig, const TString& name) { + TBusQueueConfig QueueConfigFillDefaults(const TBusQueueConfig& orig, const TString& name) { TBusQueueConfig patched = orig; if (!patched.Name) { patched.Name = name; @@ -85,15 +85,15 @@ TBusMessageQueueStatus TBusMessageQueue::GetStatusRecordInternal() const { return r; } -TString TBusMessageQueue::GetStatusSelf() const { +TString TBusMessageQueue::GetStatusSelf() const { return GetStatusRecordInternal().PrintToString(); } -TString TBusMessageQueue::GetStatusSingleLine() const { +TString TBusMessageQueue::GetStatusSingleLine() const { return WorkQueue->GetStatusSingleLine(); } -TString TBusMessageQueue::GetStatus(ui16 flags) const { +TString TBusMessageQueue::GetStatus(ui16 flags) const { TStringStream ss; ss << GetStatusSelf(); @@ -193,6 +193,6 @@ void TBusMessageQueue::Schedule(IScheduleItemAutoPtr i) { Scheduler.Schedule(i); } -TString TBusMessageQueue::GetNameInternal() const { +TString TBusMessageQueue::GetNameInternal() const { return Config.Name; } diff --git a/library/cpp/messagebus/misc/granup.h b/library/cpp/messagebus/misc/granup.h index 36ecfebc93..d0bc621276 100644 --- a/library/cpp/messagebus/misc/granup.h +++ b/library/cpp/messagebus/misc/granup.h @@ -11,7 +11,7 @@ namespace NBus { public: TGranUp(TDuration gran) : Gran(gran) - , Next(TInstant::MicroSeconds(0)) + , Next(TInstant::MicroSeconds(0)) { } diff --git a/library/cpp/messagebus/network.cpp b/library/cpp/messagebus/network.cpp index 304bedae5a..eb034fc149 100644 --- a/library/cpp/messagebus/network.cpp +++ b/library/cpp/messagebus/network.cpp @@ -94,7 +94,7 @@ namespace { } std::pair<unsigned, TVector<TBindResult>> NBus::BindOnPort(int port, bool reusePort) { - std::pair<unsigned, TVector<TBindResult>> r; + std::pair<unsigned, TVector<TBindResult>> r; r.second.reserve(2); if (port != 0) { diff --git a/library/cpp/messagebus/network_ut.cpp b/library/cpp/messagebus/network_ut.cpp index f1798419db..d7dc830ee0 100644 --- a/library/cpp/messagebus/network_ut.cpp +++ b/library/cpp/messagebus/network_ut.cpp @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(Network) { TVector<TBindResult> r = BindOnPort(FixedPort, false).second; UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size()); - for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) { + for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) { UNIT_ASSERT_VALUES_EQUAL(i->Addr.GetPort(), GetSockPort(i->Socket->operator SOCKET())); } } @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(Network) { TVector<TBindResult> r = BindOnPort(0, false).second; UNIT_ASSERT_VALUES_EQUAL(size_t(2), r.size()); - for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) { + for (TVector<TBindResult>::iterator i = r.begin(); i != r.end(); ++i) { UNIT_ASSERT_VALUES_EQUAL(i->Addr.GetPort(), GetSockPort(i->Socket->operator SOCKET())); UNIT_ASSERT(i->Addr.GetPort() > 0); } diff --git a/library/cpp/messagebus/nondestroying_holder.h b/library/cpp/messagebus/nondestroying_holder.h index f4725d696f..af8d2ac6a3 100644 --- a/library/cpp/messagebus/nondestroying_holder.h +++ b/library/cpp/messagebus/nondestroying_holder.h @@ -5,12 +5,12 @@ template <typename T> class TNonDestroyingHolder: public THolder<T> { public: - TNonDestroyingHolder(T* t = nullptr) noexcept + TNonDestroyingHolder(T* t = nullptr) noexcept : THolder<T>(t) { } - TNonDestroyingHolder(TAutoPtr<T> t) noexcept + TNonDestroyingHolder(TAutoPtr<T> t) noexcept : THolder<T>(t) { } @@ -23,17 +23,17 @@ public: template <class T> class TNonDestroyingAutoPtr: public TAutoPtr<T> { public: - inline TNonDestroyingAutoPtr(T* t = 0) noexcept + inline TNonDestroyingAutoPtr(T* t = 0) noexcept : TAutoPtr<T>(t) { } - inline TNonDestroyingAutoPtr(const TAutoPtr<T>& t) noexcept + inline TNonDestroyingAutoPtr(const TAutoPtr<T>& t) noexcept : TAutoPtr<T>(t.Release()) { } - inline ~TNonDestroyingAutoPtr() { + inline ~TNonDestroyingAutoPtr() { Y_VERIFY(!*this, "stored object must be explicitly released"); } }; diff --git a/library/cpp/messagebus/oldmodule/module.cpp b/library/cpp/messagebus/oldmodule/module.cpp index 24bd778799..d29fe9d4a0 100644 --- a/library/cpp/messagebus/oldmodule/module.cpp +++ b/library/cpp/messagebus/oldmodule/module.cpp @@ -769,7 +769,7 @@ void TBusModuleImpl::AddJob(TJobRunner* jobRunner) { } void TBusModuleImpl::DestroyJob(TJobRunner* job) { - Y_ASSERT(job->JobStorageIterator != TList<TJobRunner*>::iterator()); + Y_ASSERT(job->JobStorageIterator != TList<TJobRunner*>::iterator()); { TWhatThreadDoesAcquireGuard<TMutex> G(Lock, "modules: acquiring lock for DestroyJob"); @@ -784,7 +784,7 @@ void TBusModuleImpl::DestroyJob(TJobRunner* job) { } } - job->JobStorageIterator = TList<TJobRunner*>::iterator(); + job->JobStorageIterator = TList<TJobRunner*>::iterator(); } void TBusModuleImpl::OnMessageReceived(TAutoPtr<TBusMessage> msg0, TOnMessageContext& context) { diff --git a/library/cpp/messagebus/queue_config.cpp b/library/cpp/messagebus/queue_config.cpp index 78fb52ee49..d8f7b4eb22 100644 --- a/library/cpp/messagebus/queue_config.cpp +++ b/library/cpp/messagebus/queue_config.cpp @@ -15,7 +15,7 @@ void TBusQueueConfig::ConfigureLastGetopt( .StoreResult(&NumWorkers); } -TString TBusQueueConfig::PrintToString() const { +TString TBusQueueConfig::PrintToString() const { TStringStream ss; ss << "NumWorkers=" << NumWorkers << "\n"; return ss.Str(); diff --git a/library/cpp/messagebus/rain_check/core/task.cpp b/library/cpp/messagebus/rain_check/core/task.cpp index a098437d53..eeed343dc9 100644 --- a/library/cpp/messagebus/rain_check/core/task.cpp +++ b/library/cpp/messagebus/rain_check/core/task.cpp @@ -207,7 +207,7 @@ ITaskBase* TTaskRunnerBase::CurrentTaskImpl() { return CurrentTask()->GetImplBase(); } -TString TTaskRunnerBase::GetStatusSingleLine() { +TString TTaskRunnerBase::GetStatusSingleLine() { return TypeName(*Impl); } diff --git a/library/cpp/messagebus/rain_check/core/task.h b/library/cpp/messagebus/rain_check/core/task.h index 7d8778bcda..4e8925966c 100644 --- a/library/cpp/messagebus/rain_check/core/task.h +++ b/library/cpp/messagebus/rain_check/core/task.h @@ -144,7 +144,7 @@ namespace NRainCheck { bool SetDoneCalled; // Subtasks currently executed. - TVector<TSubtaskCompletion*> Pending; + TVector<TSubtaskCompletion*> Pending; void Act(NActor::TDefaultTag); @@ -158,7 +158,7 @@ namespace NRainCheck { static TTaskRunnerBase* CurrentTask(); static ITaskBase* CurrentTaskImpl(); - TString GetStatusSingleLine(); + TString GetStatusSingleLine(); protected: //void RetainRef(); diff --git a/library/cpp/messagebus/rain_check/core/track.cpp b/library/cpp/messagebus/rain_check/core/track.cpp index 092a51a214..b2efe796b0 100644 --- a/library/cpp/messagebus/rain_check/core/track.cpp +++ b/library/cpp/messagebus/rain_check/core/track.cpp @@ -7,7 +7,7 @@ void TTaskTrackerReceipt::SetDone() { TaskTracker->GetQueue<TTaskTrackerReceipt*>()->EnqueueAndSchedule(this); } -TString TTaskTrackerReceipt::GetStatusSingleLine() { +TString TTaskTrackerReceipt::GetStatusSingleLine() { return Task->GetStatusSingleLine(); } diff --git a/library/cpp/messagebus/rain_check/core/track.h b/library/cpp/messagebus/rain_check/core/track.h index d387de7574..77ca882679 100644 --- a/library/cpp/messagebus/rain_check/core/track.h +++ b/library/cpp/messagebus/rain_check/core/track.h @@ -31,7 +31,7 @@ namespace NRainCheck { void SetDone() override; - TString GetStatusSingleLine(); + TString GetStatusSingleLine(); }; struct TTaskTrackerStatus { diff --git a/library/cpp/messagebus/rain_check/http/client.h b/library/cpp/messagebus/rain_check/http/client.h index d4199c4c98..5daa4aec63 100644 --- a/library/cpp/messagebus/rain_check/http/client.h +++ b/library/cpp/messagebus/rain_check/http/client.h @@ -6,7 +6,7 @@ #include <util/generic/maybe.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/system/defaults.h> #include <util/system/yassert.h> diff --git a/library/cpp/messagebus/rain_check/http/client_ut.cpp b/library/cpp/messagebus/rain_check/http/client_ut.cpp index 1628114391..0dc01ef18a 100644 --- a/library/cpp/messagebus/rain_check/http/client_ut.cpp +++ b/library/cpp/messagebus/rain_check/http/client_ut.cpp @@ -13,7 +13,7 @@ #include <util/generic/cast.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/network/ip.h> #include <util/stream/str.h> diff --git a/library/cpp/messagebus/remote_client_session.cpp b/library/cpp/messagebus/remote_client_session.cpp index 3bc421944f..da6a2b3b09 100644 --- a/library/cpp/messagebus/remote_client_session.cpp +++ b/library/cpp/messagebus/remote_client_session.cpp @@ -60,7 +60,7 @@ EMessageStatus TRemoteClientSession::SendMessageOneWay(TBusMessage* pMes, const return SendMessageImpl(pMes, addr, wait, true); } -int TRemoteClientSession::GetInFlight() const noexcept { +int TRemoteClientSession::GetInFlight() const noexcept { return ClientRemoteInFlight.GetCurrent(); } diff --git a/library/cpp/messagebus/remote_connection_status.cpp b/library/cpp/messagebus/remote_connection_status.cpp index 2c48b2a287..7fc4291573 100644 --- a/library/cpp/messagebus/remote_connection_status.cpp +++ b/library/cpp/messagebus/remote_connection_status.cpp @@ -47,7 +47,7 @@ TDurationCounter& TDurationCounter::operator+=(const TDurationCounter& that) { return *this; } -TString TDurationCounter::ToString() const { +TString TDurationCounter::ToString() const { if (Count == 0) { return "0"; } else { @@ -154,7 +154,7 @@ TConnectionStatusMonRecord TRemoteConnectionStatus::GetStatusProtobuf() const { return status; } -TString TRemoteConnectionStatus::PrintToString() const { +TString TRemoteConnectionStatus::PrintToString() const { TStringStream ss; TKeyValuePrinter p; @@ -231,7 +231,7 @@ TRemoteConnectionStatus::TRemoteConnectionStatus() { } -TString TSessionDumpStatus::PrintToString() const { +TString TSessionDumpStatus::PrintToString() const { if (Shutdown) { return "shutdown"; } diff --git a/library/cpp/messagebus/remote_server_session.cpp b/library/cpp/messagebus/remote_server_session.cpp index 6abbf88a60..66deb7de31 100644 --- a/library/cpp/messagebus/remote_server_session.cpp +++ b/library/cpp/messagebus/remote_server_session.cpp @@ -130,7 +130,7 @@ EMessageStatus TRemoteServerSession::SendReply(const TBusIdentity& ident, TBusMe return MESSAGE_OK; } -int TRemoteServerSession::GetInFlight() const noexcept { +int TRemoteServerSession::GetInFlight() const noexcept { return ServerOwnedMessages.GetCurrentCount(); } diff --git a/library/cpp/messagebus/session.h b/library/cpp/messagebus/session.h index fb12ab7c22..f9340a380b 100644 --- a/library/cpp/messagebus/session.h +++ b/library/cpp/messagebus/session.h @@ -126,7 +126,7 @@ namespace NBus { IBusServerHandler* handler, const TBusServerSessionConfig& config, TBusMessageQueuePtr queue, - const TVector<TBindResult>& bindTo); + const TVector<TBindResult>& bindTo); // TODO: make parameter non-const virtual EMessageStatus SendReply(const TBusIdentity& ident, TBusMessage* pRep) = 0; diff --git a/library/cpp/messagebus/session_impl.cpp b/library/cpp/messagebus/session_impl.cpp index ddf9f360c4..809e1c170f 100644 --- a/library/cpp/messagebus/session_impl.cpp +++ b/library/cpp/messagebus/session_impl.cpp @@ -52,7 +52,7 @@ struct TBusSessionImpl::TImpl { }; namespace { - TBusSessionConfig SessionConfigFillDefaults(const TBusSessionConfig& config, const TString& name) { + TBusSessionConfig SessionConfigFillDefaults(const TBusSessionConfig& config, const TString& name) { TBusSessionConfig copy = config; if (copy.TotalTimeout == 0 && copy.SendTimeout == 0) { copy.TotalTimeout = TDuration::Seconds(60).MilliSeconds(); @@ -154,7 +154,7 @@ void TBusSessionImpl::Shutdown() { // shutdown acceptors before connections // so they won't create more connections - TVector<TAcceptorPtr> acceptors; + TVector<TAcceptorPtr> acceptors; GetAcceptors(&acceptors); { TGuard<TMutex> guard(ConnectionsLock); @@ -166,7 +166,7 @@ void TBusSessionImpl::Shutdown() { } // shutdown connections - TVector<TRemoteConnectionPtr> cs; + TVector<TRemoteConnectionPtr> cs; GetConnections(&cs); for (auto& c : cs) { @@ -241,7 +241,7 @@ TSessionDumpStatus TBusSessionImpl::GetStatusRecordInternal() { return StatusData.StatusDumpCached; } -TString TBusSessionImpl::GetStatus(ui16 flags) { +TString TBusSessionImpl::GetStatus(ui16 flags) { Y_UNUSED(flags); return GetStatusRecordInternal().PrintToString(); @@ -256,7 +256,7 @@ TConnectionStatusMonRecord TBusSessionImpl::GetStatusProtobuf() { return StatusData.StatusDumpCached.ConnectionStatusSummary.GetStatusProtobuf(); } -TString TBusSessionImpl::GetStatusSingleLine() { +TString TBusSessionImpl::GetStatusSingleLine() { TSessionDumpStatus status = GetStatusRecordInternal(); TStringStream ss; @@ -308,7 +308,7 @@ void TBusSessionImpl::ProcessItem(TConnectionTag, TRemoveTag, TRemoteConnectionP } } - THashMap<ui64, TRemoteConnectionPtr>::iterator it2 = ConnectionsById.find(c->ConnectionId); + THashMap<ui64, TRemoteConnectionPtr>::iterator it2 = ConnectionsById.find(c->ConnectionId); if (it2 != ConnectionsById.end()) { ConnectionsById.erase(it2); } @@ -317,12 +317,12 @@ void TBusSessionImpl::ProcessItem(TConnectionTag, TRemoveTag, TRemoteConnectionP } void TBusSessionImpl::ProcessConnectionsAcceptorsShapshotQueueItem(TAtomicSharedPtr<TConnectionsAcceptorsSnapshot> snapshot) { - for (TVector<TRemoteConnectionPtr>::const_iterator connection = snapshot->Connections.begin(); + for (TVector<TRemoteConnectionPtr>::const_iterator connection = snapshot->Connections.begin(); connection != snapshot->Connections.end(); ++connection) { Y_ASSERT((*connection)->ConnectionId <= snapshot->LastConnectionId); } - for (TVector<TAcceptorPtr>::const_iterator acceptor = snapshot->Acceptors.begin(); + for (TVector<TAcceptorPtr>::const_iterator acceptor = snapshot->Acceptors.begin(); acceptor != snapshot->Acceptors.end(); ++acceptor) { Y_ASSERT((*acceptor)->AcceptorId <= snapshot->LastAcceptorId); } @@ -355,7 +355,7 @@ void TBusSessionImpl::StatusUpdateCachedDump() { { TStringStream ss; - TString name = Config.Name; + TString name = Config.Name; if (!name) { name = "unnamed"; } @@ -373,8 +373,8 @@ void TBusSessionImpl::StatusUpdateCachedDump() { r.Head = ss.Str(); } - TVector<TRemoteConnectionPtr>& connections = StatusData.ConnectionsAcceptorsSnapshot->Connections; - TVector<TAcceptorPtr>& acceptors = StatusData.ConnectionsAcceptorsSnapshot->Acceptors; + TVector<TRemoteConnectionPtr>& connections = StatusData.ConnectionsAcceptorsSnapshot->Connections; + TVector<TAcceptorPtr>& acceptors = StatusData.ConnectionsAcceptorsSnapshot->Acceptors; r.ConnectionStatusSummary = TRemoteConnectionStatus(); r.ConnectionStatusSummary.Summary = true; @@ -387,7 +387,7 @@ void TBusSessionImpl::StatusUpdateCachedDump() { { TStringStream ss; - for (TVector<TAcceptorPtr>::const_iterator acceptor = acceptors.begin(); + for (TVector<TAcceptorPtr>::const_iterator acceptor = acceptors.begin(); acceptor != acceptors.end(); ++acceptor) { const TAcceptorStatus status = (*acceptor)->GranStatus.Listen.Get(); @@ -405,7 +405,7 @@ void TBusSessionImpl::StatusUpdateCachedDump() { { TStringStream ss; - for (TVector<TRemoteConnectionPtr>::const_iterator connection = connections.begin(); + for (TVector<TRemoteConnectionPtr>::const_iterator connection = connections.begin(); connection != connections.end(); ++connection) { if (connection != connections.begin()) { ss << "\n"; @@ -544,17 +544,17 @@ void TBusSessionImpl::InsertAcceptorLockAcquired(TAcceptor* acceptor) { SendSnapshotToStatusActor(); } -void TBusSessionImpl::GetConnections(TVector<TRemoteConnectionPtr>* r) { +void TBusSessionImpl::GetConnections(TVector<TRemoteConnectionPtr>* r) { TConnectionsGuard guard(ConnectionsLock); GetConnectionsLockAquired(r); } -void TBusSessionImpl::GetAcceptors(TVector<TAcceptorPtr>* r) { +void TBusSessionImpl::GetAcceptors(TVector<TAcceptorPtr>* r) { TConnectionsGuard guard(ConnectionsLock); GetAcceptorsLockAquired(r); } -void TBusSessionImpl::GetConnectionsLockAquired(TVector<TRemoteConnectionPtr>* r) { +void TBusSessionImpl::GetConnectionsLockAquired(TVector<TRemoteConnectionPtr>* r) { //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Connections.size()); @@ -564,7 +564,7 @@ void TBusSessionImpl::GetConnectionsLockAquired(TVector<TRemoteConnectionPtr>* r } } -void TBusSessionImpl::GetAcceptorsLockAquired(TVector<TAcceptorPtr>* r) { +void TBusSessionImpl::GetAcceptorsLockAquired(TVector<TAcceptorPtr>* r) { //Y_ASSERT(ConnectionsLock.IsLocked()); r->reserve(Acceptors.size()); @@ -577,7 +577,7 @@ void TBusSessionImpl::GetAcceptorsLockAquired(TVector<TAcceptorPtr>* r) { TRemoteConnectionPtr TBusSessionImpl::GetConnectionById(ui64 id) { TConnectionsGuard guard(ConnectionsLock); - THashMap<ui64, TRemoteConnectionPtr>::const_iterator it = ConnectionsById.find(id); + THashMap<ui64, TRemoteConnectionPtr>::const_iterator it = ConnectionsById.find(id); if (it == ConnectionsById.end()) { return nullptr; } else { @@ -623,7 +623,7 @@ TRemoteConnectionPtr TBusSessionImpl::GetConnection(const TBusSocketAddr& addr, } void TBusSessionImpl::Cron() { - TVector<TRemoteConnectionPtr> connections; + TVector<TRemoteConnectionPtr> connections; GetConnections(&connections); for (const auto& it : connections) { @@ -642,7 +642,7 @@ void TBusSessionImpl::Cron() { Queue->Schedule(IScheduleItemAutoPtr(new TScheduleSession(this, TInstant::Now() + Config.Secret.TimeoutPeriod))); } -TString TBusSessionImpl::GetNameInternal() { +TString TBusSessionImpl::GetNameInternal() { if (!!Config.Name) { return Config.Name; } diff --git a/library/cpp/messagebus/socket_addr_ut.cpp b/library/cpp/messagebus/socket_addr_ut.cpp index 783bb62a86..0b6a19efa1 100644 --- a/library/cpp/messagebus/socket_addr_ut.cpp +++ b/library/cpp/messagebus/socket_addr_ut.cpp @@ -10,6 +10,6 @@ using namespace NBus::NPrivate; Y_UNIT_TEST_SUITE(TBusSocketAddr) { Y_UNIT_TEST(Simple) { - UNIT_ASSERT_VALUES_EQUAL(TString("127.0.0.1:80"), ToString(TBusSocketAddr("127.0.0.1", 80))); + UNIT_ASSERT_VALUES_EQUAL(TString("127.0.0.1:80"), ToString(TBusSocketAddr("127.0.0.1", 80))); } } diff --git a/library/cpp/messagebus/synchandler.cpp b/library/cpp/messagebus/synchandler.cpp index 8e891d66b3..ae69523ed9 100644 --- a/library/cpp/messagebus/synchandler.cpp +++ b/library/cpp/messagebus/synchandler.cpp @@ -186,7 +186,7 @@ const TBusClientSession* TBusSyncSourceSession::GetBusClientSessionWorkaroundDoN return Session.Get(); } -TBusSyncClientSessionPtr TBusMessageQueue::CreateSyncSource(TBusProtocol* proto, const TBusClientSessionConfig& config, bool needReply, const TString& name) { +TBusSyncClientSessionPtr TBusMessageQueue::CreateSyncSource(TBusProtocol* proto, const TBusClientSessionConfig& config, bool needReply, const TString& name) { TIntrusivePtr<TBusSyncSourceSessionImpl> session = new TBusSyncSourceSessionImpl(this, proto, config, needReply, name); Add(session.Get()); return new TBusSyncSourceSession(session); diff --git a/library/cpp/messagebus/test/helper/example.cpp b/library/cpp/messagebus/test/helper/example.cpp index 7c6d704042..f5b21be799 100644 --- a/library/cpp/messagebus/test/helper/example.cpp +++ b/library/cpp/messagebus/test/helper/example.cpp @@ -19,12 +19,12 @@ static void FillWithJunk(TArrayRef<char> data) { } } -static TString JunkString(size_t len) { +static TString JunkString(size_t len) { TTempBuf temp(len); TArrayRef<char> tempArrayRef(temp.Data(), len); FillWithJunk(tempArrayRef); - return TString(tempArrayRef.data(), tempArrayRef.size()); + return TString(tempArrayRef.data(), tempArrayRef.size()); } TExampleRequest::TExampleRequest(TAtomic* counterPtr, size_t payloadSize) diff --git a/library/cpp/messagebus/test/helper/hanging_server.h b/library/cpp/messagebus/test/helper/hanging_server.h index cc9fb274d8..f6b9af24e2 100644 --- a/library/cpp/messagebus/test/helper/hanging_server.h +++ b/library/cpp/messagebus/test/helper/hanging_server.h @@ -6,7 +6,7 @@ class THangingServer { private: - std::pair<unsigned, TVector<NBus::TBindResult>> BindResult; + std::pair<unsigned, TVector<NBus::TBindResult>> BindResult; public: // listen on given port, and nothing else diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index 8489319278..dd2dd69e4d 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -17,7 +17,7 @@ #include <library/cpp/threading/future/legacy_future.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> #include <util/random/random.h> @@ -76,7 +76,7 @@ struct TPerftestConfig { extern TPerftestConfig* TheConfig; extern bool TheExit; -TVector<TNetAddr> ServerAddresses; +TVector<TNetAddr> ServerAddresses; struct TConfig { TBusQueueConfig ServerQueueConfig; @@ -142,13 +142,13 @@ TAutoPtr<TBusMessage> NewRequest() { TAutoPtr<TPerftestRequest> r(new TPerftestRequest); r->SetCompressed(TheConfig->UseCompression); // TODO: use random content for better compression test - r->Record.SetData(TString(RequestSize(), '?')); + r->Record.SetData(TString(RequestSize(), '?')); return r.Release(); } } void CheckRequest(TPerftestRequest* request) { - const TString& data = request->Record.GetData(); + const TString& data = request->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { Y_VERIFY(data.at(i) == '?', "must be question mark"); } @@ -162,7 +162,7 @@ TAutoPtr<TPerftestResponse> NewResponse(TPerftestRequest* request) { } void CheckResponse(TPerftestResponse* response) { - const TString& data = response->Record.GetData(); + const TString& data = response->Record.GetData(); for (size_t i = 0; i != data.size(); ++i) { Y_VERIFY(data.at(i) == '.', "must be dot"); } @@ -237,7 +237,7 @@ public: TBusClientSessionPtr Session; THolder<TBusProtocol> Proto; TBusMessageQueuePtr Bus; - TVector<TBusClientConnectionPtr> Connections; + TVector<TBusClientConnectionPtr> Connections; public: /// constructor creates instances of protocol and session @@ -470,10 +470,10 @@ static TNetworkAddress ParseNetworkAddress(const char* string) { return TNetworkAddress(Name, Port); } -TVector<TNetAddr> ParseNodes(const TString nodes) { - TVector<TNetAddr> r; +TVector<TNetAddr> ParseNodes(const TString nodes) { + TVector<TNetAddr> r; - TVector<TString> hosts; + TVector<TString> hosts; size_t numh = Split(nodes.data(), ",", hosts); @@ -583,7 +583,7 @@ void TTestStats::PeriodicallyPrint() { stats << IndentText(client->Bus->GetStatus()); } - TUnbufferedFileOutput("stats").Write(stats.Str()); + TUnbufferedFileOutput("stats").Write(stats.Str()); } } diff --git a/library/cpp/messagebus/test/ut/locator_uniq_ut.cpp b/library/cpp/messagebus/test/ut/locator_uniq_ut.cpp index 3fdd175d73..a930e26dcd 100644 --- a/library/cpp/messagebus/test/ut/locator_uniq_ut.cpp +++ b/library/cpp/messagebus/test/ut/locator_uniq_ut.cpp @@ -31,7 +31,7 @@ void TLocatorRegisterUniqTest::TestRegister() { /// YBUS_KEYMIN YBUS_KEYMAX range UNIT_ASSERT(keys.size() == 1); - TVector<NBus::TNetAddr> hosts; + TVector<NBus::TNetAddr> hosts; UNIT_ASSERT(locator.LocateAll(serviceName, NBus::YBUS_KEYMIN, hosts) == 1); locator.Register(serviceName, hostName, port); diff --git a/library/cpp/messagebus/test/ut/messagebus_ut.cpp b/library/cpp/messagebus/test/ut/messagebus_ut.cpp index 040f9b7702..5bae0e7bb9 100644 --- a/library/cpp/messagebus/test/ut/messagebus_ut.cpp +++ b/library/cpp/messagebus/test/ut/messagebus_ut.cpp @@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) { TSystemEvent MessageReceivedEvent; // 1 wait for 1 message TBusServerSessionPtr Session; TMutex Lock_; - TDeque<TAutoPtr<TOnMessageContext>> DelayedMessages; + TDeque<TAutoPtr<TOnMessageContext>> DelayedMessages; TDelayReplyServer() : MessageReceivedEvent(TEventResetType::rAuto) diff --git a/library/cpp/messagebus/www/concat_strings.h b/library/cpp/messagebus/www/concat_strings.h index 7b730564eb..86f6609c1d 100644 --- a/library/cpp/messagebus/www/concat_strings.h +++ b/library/cpp/messagebus/www/concat_strings.h @@ -1,9 +1,9 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/str.h> -// ATTN: not equivalent to TString::Join - cat concat anything "outputable" to stream, not only TString convertable types. +// ATTN: not equivalent to TString::Join - cat concat anything "outputable" to stream, not only TString convertable types. inline void DoConcatStrings(TStringStream&) { } @@ -15,7 +15,7 @@ inline void DoConcatStrings(TStringStream& ss, const T& t, const R&... r) { } template <class... R> -inline TString ConcatStrings(const R&... r) { +inline TString ConcatStrings(const R&... r) { TStringStream ss; DoConcatStrings(ss, r...); return ss.Str(); diff --git a/library/cpp/messagebus/www/html_output.h b/library/cpp/messagebus/www/html_output.h index 27e77adefa..551f0ba693 100644 --- a/library/cpp/messagebus/www/html_output.h +++ b/library/cpp/messagebus/www/html_output.h @@ -29,7 +29,7 @@ struct THtmlOutputStreamPushPop { }; struct TChars { - TString Text; + TString Text; bool NeedEscape; TChars(TStringBuf text) @@ -53,7 +53,7 @@ struct TChars { { } - TString Escape() { + TString Escape() { if (NeedEscape) { return EncodeHtmlPcdata(Text); } else { @@ -63,8 +63,8 @@ struct TChars { }; struct TAttr { - TString Name; - TString Value; + TString Name; + TString Value; TAttr(TStringBuf name, TStringBuf value) : Name(name) @@ -157,7 +157,7 @@ static inline void Small(TStringBuf text) { } static inline void HnWithSmall(unsigned n, TStringBuf title, TStringBuf small) { - TString tagName = ConcatStrings("h", n); + TString tagName = ConcatStrings("h", n); Open(tagName); HtmlOutputStream() << title; Sp(); @@ -268,7 +268,7 @@ static inline void Code(TStringBuf content) { } struct TTagGuard { - const TString TagName; + const TString TagName; TTagGuard(TStringBuf tagName, TStringBuf cssClass, TStringBuf id = "") : TagName(tagName) diff --git a/library/cpp/messagebus/www/www.cpp b/library/cpp/messagebus/www/www.cpp index 62ec241d85..a285a6367a 100644 --- a/library/cpp/messagebus/www/www.cpp +++ b/library/cpp/messagebus/www/www.cpp @@ -48,7 +48,7 @@ namespace { return TValuePtr(); } - TString FindNameByPtr(TValuePtr value) { + TString FindNameByPtr(TValuePtr value) { Y_VERIFY(!!value); for (unsigned i = 0; i < Entries.size(); ++i) { @@ -80,11 +80,11 @@ namespace { } for (unsigned i = 1;; ++i) { - TString prefix = p->GetNameInternal(); + TString prefix = p->GetNameInternal(); if (!prefix) { prefix = "unnamed"; } - TString name = ConcatStrings(prefix, "-", i); + TString name = ConcatStrings(prefix, "-", i); TValuePtr current = FindByName(name); @@ -108,8 +108,8 @@ namespace { struct TSessionValues: public TNamedValues<TSessionPtr> { typedef TNamedValues<TSessionPtr> TBase; - TVector<TString> GetNamesForQueue(TBusMessageQueue* queue) { - TVector<TString> r; + TVector<TString> GetNamesForQueue(TBusMessageQueue* queue) { + TVector<TString> r; for (unsigned i = 0; i < TBase::size(); ++i) { if (TBase::Entries[i].second->GetQueue() == queue) { r.push_back(TBase::Entries[i].first); @@ -211,14 +211,14 @@ struct TBusWww::TImpl { TGuard<TMutex> g(Mutex); { - TVector<TBusClientSessionPtr> clientSessions = module->GetInternal()->GetClientSessionsInternal(); + TVector<TBusClientSessionPtr> clientSessions = module->GetInternal()->GetClientSessionsInternal(); for (unsigned i = 0; i < clientSessions.size(); ++i) { RegisterClientSession(clientSessions[i]); } } { - TVector<TBusServerSessionPtr> serverSessions = module->GetInternal()->GetServerSessionsInternal(); + TVector<TBusServerSessionPtr> serverSessions = module->GetInternal()->GetServerSessionsInternal(); for (unsigned i = 0; i < serverSessions.size(); ++i) { RegisterServerSession(serverSessions[i]); } @@ -228,7 +228,7 @@ struct TBusWww::TImpl { Modules.Add(module->GetInternal()); } - TString FindQueueNameBySessionName(TStringBuf sessionName, bool client) { + TString FindQueueNameBySessionName(TStringBuf sessionName, bool client) { TIntrusivePtr<TBusClientSession> clientSession; TIntrusivePtr<TBusServerSession> serverSession; TBusSession* session; @@ -288,7 +288,7 @@ struct TBusWww::TImpl { } void BreadcrumbSession(TStringBuf sessionName, bool client) { - TString queueName = Outer->FindQueueNameBySessionName(sessionName, client); + TString queueName = Outer->FindQueueNameBySessionName(sessionName, client); TStringBuf whatSession = client ? "client session" : "server session"; TTagGuard ol("ol", "breadcrumb"); @@ -299,9 +299,9 @@ struct TBusWww::TImpl { } void ServeSessionsOfQueue(TBusMessageQueuePtr queue, bool includeQueue) { - TVector<TString> clientNames = Outer->ClientSessions.GetNamesForQueue(queue.Get()); - TVector<TString> serverNames = Outer->ServerSessions.GetNamesForQueue(queue.Get()); - TVector<TString> moduleNames = Outer->Modules.GetNamesForQueue(queue.Get()); + TVector<TString> clientNames = Outer->ClientSessions.GetNamesForQueue(queue.Get()); + TVector<TString> serverNames = Outer->ServerSessions.GetNamesForQueue(queue.Get()); + TVector<TString> moduleNames = Outer->Modules.GetNamesForQueue(queue.Get()); TTagGuard table("table", "table table-condensed table-bordered"); @@ -320,7 +320,7 @@ struct TBusWww::TImpl { } if (includeQueue) { - TTagGuard tr1("tr"); + TTagGuard tr1("tr"); Td("queue"); { @@ -329,7 +329,7 @@ struct TBusWww::TImpl { } { - TTagGuard tr2("td"); + TTagGuard tr2("td"); Pre(queue->GetStatusSingleLine()); } } @@ -385,7 +385,7 @@ struct TBusWww::TImpl { } } - void ServeQueue(const TString& name) { + void ServeQueue(const TString& name) { TBusMessageQueuePtr queue = Outer->Queues.FindByName(name); if (!queue) { @@ -518,7 +518,7 @@ struct TBusWww::TImpl { TSessionDumpStatus dumpStatus = session->GetStatusRecordInternal(); TBusMessageQueuePtr queue = session->GetQueue(); - TString queueName = Outer->Queues.FindNameByPtr(session->GetQueue()); + TString queueName = Outer->Queues.FindNameByPtr(session->GetQueue()); BreadcrumbSession(name, client); @@ -585,7 +585,7 @@ struct TBusWww::TImpl { NJsonWriter::TBuf buf(NJsonWriter::HEM_ESCAPE_HTML); buf.BeginList(); for (unsigned i = 0; i < h.Times.size(); ++i) { - TString label = TDurationHistogram::LabelBefore(i); + TString label = TDurationHistogram::LabelBefore(i); buf.BeginList(); buf.WriteString(label); buf.WriteLongLong(h.Times[i]); @@ -612,7 +612,7 @@ struct TBusWww::TImpl { H1("MessageBus queues"); for (unsigned i = 0; i < Outer->Queues.size(); ++i) { - TString queueName = Outer->Queues.Entries[i].first; + TString queueName = Outer->Queues.Entries[i].first; TBusMessageQueuePtr queue = Outer->Queues.Entries[i].second; HnWithSmall(3, queueName, "(queue)"); @@ -680,7 +680,7 @@ struct TBusWww::TImpl { status.ConnectionStatusSummary.ReaderStatus.Incremental.MessageCounter); } - void ServeSolomonJson(const TString& q, const TString& cs, const TString& ss) { + void ServeSolomonJson(const TString& q, const TString& cs, const TString& ss) { Y_UNUSED(q); Y_UNUSED(cs); Y_UNUSED(ss); @@ -692,15 +692,15 @@ struct TBusWww::TImpl { sj.OpenMetrics(); for (unsigned i = 0; i < Outer->Queues.size(); ++i) { - TString queueName = Outer->Queues.Entries[i].first; + TString queueName = Outer->Queues.Entries[i].first; TBusMessageQueuePtr queue = Outer->Queues.Entries[i].second; if (all || q == queueName) { WriteQueueSensors(sj, queueName, &*queue); } - TVector<TString> clientNames = Outer->ClientSessions.GetNamesForQueue(queue.Get()); - TVector<TString> serverNames = Outer->ServerSessions.GetNamesForQueue(queue.Get()); - TVector<TString> moduleNames = Outer->Modules.GetNamesForQueue(queue.Get()); + TVector<TString> clientNames = Outer->ClientSessions.GetNamesForQueue(queue.Get()); + TVector<TString> serverNames = Outer->ServerSessions.GetNamesForQueue(queue.Get()); + TVector<TString> moduleNames = Outer->Modules.GetNamesForQueue(queue.Get()); for (auto& sessionName : clientNames) { if (all || cs == sessionName) { auto session = Outer->ClientSessions.FindByName(sessionName); @@ -728,7 +728,7 @@ struct TBusWww::TImpl { } else { os << HTTP_OK_BIN; } - TBlob blob = Singleton<TWwwStaticLoader>()->ObjectBlobByKey(TString("/") + TString(path)); + TBlob blob = Singleton<TWwwStaticLoader>()->ObjectBlobByKey(TString("/") + TString(path)); os.Write(blob.Data(), blob.Size()); } @@ -766,9 +766,9 @@ struct TBusWww::TImpl { if (solomonJson) { Os << HTTP_OK_JSON; - TString qp = q != CgiParams.end() ? q->first : ""; - TString csp = cs != CgiParams.end() ? cs->first : ""; - TString ssp = ss != CgiParams.end() ? ss->first : ""; + TString qp = q != CgiParams.end() ? q->first : ""; + TString csp = cs != CgiParams.end() ? cs->first : ""; + TString ssp = ss != CgiParams.end() ? ss->first : ""; ServeSolomonJson(qp, csp, ssp); } else { Os << HTTP_OK_HTML; @@ -870,7 +870,7 @@ struct TBusWwwHttpServer::TImpl: public THttpServer::ICallBack { } }; - TString MakeSimpleResponse(unsigned code, TString text, TString content = "") { + TString MakeSimpleResponse(unsigned code, TString text, TString content = "") { if (!content) { TStringStream contentSs; contentSs << code << " " << text; diff --git a/library/cpp/messagebus/www/www.h b/library/cpp/messagebus/www/www.h index 6cd652b477..7180b5b692 100644 --- a/library/cpp/messagebus/www/www.h +++ b/library/cpp/messagebus/www/www.h @@ -4,7 +4,7 @@ #include <library/cpp/messagebus/oldmodule/module.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <library/cpp/cgiparam/cgiparam.h> namespace NBus { diff --git a/library/cpp/mime/types/mime.cpp b/library/cpp/mime/types/mime.cpp index 706d776b24..8986cbc604 100644 --- a/library/cpp/mime/types/mime.cpp +++ b/library/cpp/mime/types/mime.cpp @@ -42,7 +42,7 @@ private: const char* Ext; }; - typedef THashMap<const char*, int> TRecordHash; + typedef THashMap<const char*, int> TRecordHash; // Fields private: diff --git a/library/cpp/mime/types/mime.h b/library/cpp/mime/types/mime.h index 05da389ea9..c2c97b58b2 100644 --- a/library/cpp/mime/types/mime.h +++ b/library/cpp/mime/types/mime.h @@ -69,4 +69,4 @@ MimeTypes mimeByStr(const TStringBuf& mimeStr); const char* strByMime(MimeTypes mime); // autogenerated with GENERATE_ENUM_SERIALIZATION -const TString& ToString(MimeTypes x); +const TString& ToString(MimeTypes x); diff --git a/library/cpp/monlib/counters/counters_ut.cpp b/library/cpp/monlib/counters/counters_ut.cpp index 2845efb97b..7c029e2e09 100644 --- a/library/cpp/monlib/counters/counters_ut.cpp +++ b/library/cpp/monlib/counters/counters_ut.cpp @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TDeprecatedCountersTest) { } // no duplication in group names - TSet<ui32> uniqueIds(ids->begin(), ids->end()); + TSet<ui32> uniqueIds(ids->begin(), ids->end()); UNIT_ASSERT_EQUAL(ids->size(), uniqueIds.size()); UNIT_ASSERT_EQUAL(ids->size(), GROUPS_COUNT); } diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index dc178cfbe0..52692f8149 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -201,11 +201,11 @@ namespace NMonitoring { typedef TIntrusivePtr<TCountableBase> TCountablePtr; struct TChildId { - TString LabelName; - TString LabelValue; + TString LabelName; + TString LabelValue; TChildId() { } - TChildId(const TString& labelName, const TString& labelValue) + TChildId(const TString& labelName, const TString& labelValue) : LabelName(labelName) , LabelValue(labelValue) { @@ -329,8 +329,8 @@ namespace NMonitoring { void RemoveCounter(const TString &value); void RemoveNamedCounter(const TString& name, const TString &value); - TIntrusivePtr<TDynamicCounters> GetSubgroup(const TString& name, const TString& value); - TIntrusivePtr<TDynamicCounters> FindSubgroup(const TString& name, const TString& value) const; + TIntrusivePtr<TDynamicCounters> GetSubgroup(const TString& name, const TString& value); + TIntrusivePtr<TDynamicCounters> FindSubgroup(const TString& name, const TString& value) const; void RemoveSubgroup(const TString& name, const TString& value); void ReplaceSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.cpp b/library/cpp/monlib/dynamic_counters/golovan_page.cpp index 49cf2d39bb..cda0fdfcf2 100644 --- a/library/cpp/monlib/dynamic_counters/golovan_page.cpp +++ b/library/cpp/monlib/dynamic_counters/golovan_page.cpp @@ -61,7 +61,7 @@ public: private: IOutputStream& out; bool FirstCounter; - TString prefix; + TString prefix; }; TGolovanCountersPage::TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters, diff --git a/library/cpp/monlib/dynamic_counters/page.cpp b/library/cpp/monlib/dynamic_counters/page.cpp index 5124a47bb3..649a232ca8 100644 --- a/library/cpp/monlib/dynamic_counters/page.cpp +++ b/library/cpp/monlib/dynamic_counters/page.cpp @@ -56,7 +56,7 @@ void TDynamicCountersPage::Output(NMonitoring::IMonHttpRequest& request) { for (const auto& escaped : parts) { const auto part = CGIUnescapeRet(escaped); - TVector<TString> labels; + TVector<TString> labels; StringSplitter(part).Split('=').SkipEmpty().Collect(&labels); if (labels.size() != 2U) diff --git a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp index 9fc3421d0b..8dc61d0113 100644 --- a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp +++ b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp @@ -63,22 +63,22 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) { strPool.Build(); - TVector<TString> strings; - TVector<ui32> indexes; - TVector<ui32> frequences; + TVector<TString> strings; + TVector<ui32> indexes; + TVector<ui32> frequences; strPool.ForEach([&](TStringBuf str, ui32 index, ui32 freq) { strings.emplace_back(str); indexes.push_back(index); frequences.push_back(freq); }); - TVector<TString> expectedStrings = {"three", "two", "one"}; + TVector<TString> expectedStrings = {"three", "two", "one"}; UNIT_ASSERT_EQUAL(strings, expectedStrings); - TVector<ui32> expectedIndexes = {0, 1, 2}; + TVector<ui32> expectedIndexes = {0, 1, 2}; UNIT_ASSERT_EQUAL(indexes, expectedIndexes); - TVector<ui32> expectedFrequences = {3, 2, 1}; + TVector<ui32> expectedFrequences = {3, 2, 1}; UNIT_ASSERT_EQUAL(frequences, expectedFrequences); } } diff --git a/library/cpp/monlib/messagebus/mon_service_messagebus.cpp b/library/cpp/monlib/messagebus/mon_service_messagebus.cpp index 4dd144ebe8..8fe79b9b3a 100644 --- a/library/cpp/monlib/messagebus/mon_service_messagebus.cpp +++ b/library/cpp/monlib/messagebus/mon_service_messagebus.cpp @@ -2,7 +2,7 @@ using namespace NMonitoring; -TMonServiceMessageBus::TMonServiceMessageBus(ui16 port, const TString& title) +TMonServiceMessageBus::TMonServiceMessageBus(ui16 port, const TString& title) : TMonService2(port, title) { } diff --git a/library/cpp/monlib/metrics/labels_ut.cpp b/library/cpp/monlib/metrics/labels_ut.cpp index f0e4f532ab..614ad8ffaf 100644 --- a/library/cpp/monlib/metrics/labels_ut.cpp +++ b/library/cpp/monlib/metrics/labels_ut.cpp @@ -124,12 +124,12 @@ Y_UNIT_TEST_SUITE(TLabelsTest) { UNIT_ASSERT_EQUAL(labels[0], TLabel("name1", "value1")); UNIT_ASSERT_EQUAL(labels[1], TLabel("name2", "value2")); - TVector<TLabel> labelsCopy; + TVector<TLabel> labelsCopy; for (auto&& label : labels) { labelsCopy.emplace_back(label.Name(), label.Value()); } - UNIT_ASSERT_EQUAL(labelsCopy, TVector<TLabel>({ + UNIT_ASSERT_EQUAL(labelsCopy, TVector<TLabel>({ {"name1", "value1"}, {"name2", "value2"}, })); diff --git a/library/cpp/monlib/service/mon_service_http_request.cpp b/library/cpp/monlib/service/mon_service_http_request.cpp index 5d805631d9..8abe33f0fb 100644 --- a/library/cpp/monlib/service/mon_service_http_request.cpp +++ b/library/cpp/monlib/service/mon_service_http_request.cpp @@ -9,7 +9,7 @@ IMonHttpRequest::~IMonHttpRequest() { TMonService2HttpRequest::~TMonService2HttpRequest() { } -TString TMonService2HttpRequest::GetServiceTitle() const { +TString TMonService2HttpRequest::GetServiceTitle() const { return MonService->GetTitle(); } diff --git a/library/cpp/monlib/service/mon_service_http_request.h b/library/cpp/monlib/service/mon_service_http_request.h index b4f2f8f0c5..14974f1a20 100644 --- a/library/cpp/monlib/service/mon_service_http_request.h +++ b/library/cpp/monlib/service/mon_service_http_request.h @@ -44,7 +44,7 @@ namespace NMonitoring { TMonService2HttpRequest( IOutputStream* out, const IHttpRequest* httpRequest, TMonService2* monService, IMonPage* monPage, - const TString& pathInfo, + const TString& pathInfo, TMonService2HttpRequest* parent) : Out(out) , HttpRequest(httpRequest) diff --git a/library/cpp/monlib/service/monservice.cpp b/library/cpp/monlib/service/monservice.cpp index d1b9cda1d2..fdb7f77c1a 100644 --- a/library/cpp/monlib/service/monservice.cpp +++ b/library/cpp/monlib/service/monservice.cpp @@ -78,7 +78,7 @@ void TMonService2::OutputIndexBody(IOutputStream& out) { } void TMonService2::ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request) { - TString path = request.GetPath(); + TString path = request.GetPath(); Y_VERIFY(path.StartsWith('/')); if (AuthProvider_) { @@ -112,15 +112,15 @@ void TMonService2::Register(TMonPagePtr page) { IndexMonPage->Register(std::move(page)); } -TIndexMonPage* TMonService2::RegisterIndexPage(const TString& path, const TString& title) { +TIndexMonPage* TMonService2::RegisterIndexPage(const TString& path, const TString& title) { return IndexMonPage->RegisterIndexPage(path, title); } -IMonPage* TMonService2::FindPage(const TString& relativePath) { +IMonPage* TMonService2::FindPage(const TString& relativePath) { return IndexMonPage->FindPage(relativePath); } -TIndexMonPage* TMonService2::FindIndexPage(const TString& relativePath) { +TIndexMonPage* TMonService2::FindIndexPage(const TString& relativePath) { return IndexMonPage->FindIndexPage(relativePath); } diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 83ff8b529a..87cb7e7f99 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -36,7 +36,7 @@ void TIndexMonPage::Output(IMonHttpRequest& request) { break; } size_t slash = pathTmp.find_last_of('/'); - Y_VERIFY(slash != TString::npos); + Y_VERIFY(slash != TString::npos); pathTmp = pathTmp.substr(0, slash); if (!pathTmp) { break; @@ -56,7 +56,7 @@ void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { for (auto& Page : Pages) { IMonPage* page = Page.Get(); if (page->IsInIndex()) { - TString pathToDir = ""; + TString pathToDir = ""; if (!pathEndsWithSlash) { pathToDir = this->GetPath() + "/"; } @@ -94,7 +94,7 @@ TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TStri return VerifyDynamicCast<TIndexMonPage*>(page); } -IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { +IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { TGuard<TMutex> g(Mtx); Y_VERIFY(!relativePath.StartsWith('/')); @@ -106,7 +106,7 @@ IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { } } -TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { +TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath)); } diff --git a/library/cpp/monlib/service/pages/mon_page.cpp b/library/cpp/monlib/service/pages/mon_page.cpp index 72033b1699..7bf9cce18e 100644 --- a/library/cpp/monlib/service/pages/mon_page.cpp +++ b/library/cpp/monlib/service/pages/mon_page.cpp @@ -2,7 +2,7 @@ using namespace NMonitoring; -IMonPage::IMonPage(const TString& path, const TString& title) +IMonPage::IMonPage(const TString& path, const TString& title) : Path(path) , Title(title) { diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h index e396612bb0..1a51dbfa60 100644 --- a/library/cpp/monlib/service/pages/mon_page.h +++ b/library/cpp/monlib/service/pages/mon_page.h @@ -3,7 +3,7 @@ #include <library/cpp/monlib/service/service.h> #include <library/cpp/monlib/service/mon_service_http_request.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ptr.h> namespace NMonitoring { diff --git a/library/cpp/monlib/service/pages/version_mon_page.cpp b/library/cpp/monlib/service/pages/version_mon_page.cpp index 41e29417da..01ec97d48f 100644 --- a/library/cpp/monlib/service/pages/version_mon_page.cpp +++ b/library/cpp/monlib/service/pages/version_mon_page.cpp @@ -9,7 +9,7 @@ using namespace NMonitoring; void TVersionMonPage::OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) { const char* version = GetProgramSvnVersion(); out << version; - if (!TString(version).EndsWith("\n")) + if (!TString(version).EndsWith("\n")) out << "\n"; out << GetBuildInfo() << "\n\n"; out << "linked with malloc: " << NMalloc::MallocInfo().Name << "\n"; diff --git a/library/cpp/monlib/service/pages/ya.make b/library/cpp/monlib/service/pages/ya.make index 48d44a0838..3631168ece 100644 --- a/library/cpp/monlib/service/pages/ya.make +++ b/library/cpp/monlib/service/pages/ya.make @@ -2,8 +2,8 @@ LIBRARY() OWNER(g:solomon) -NO_WSHADOW() - +NO_WSHADOW() + SRCS( diag_mon_page.cpp html_mon_page.cpp diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 929efbf816..b4b522939c 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -29,7 +29,7 @@ namespace NMonitoring { out << "HTTP/1.1 400 Invalid url\r\nConnection: Close\r\n\r\n"; return; } - TString path = GetPath(); + TString path = GetPath(); if (!path.StartsWith('/')) { out << "HTTP/1.1 400 Bad request\r\nConnection: Close\r\n\r\n"; return; @@ -133,7 +133,7 @@ namespace NMonitoring { const TCoHttpServer& Parent; }; - TCoHttpServer::TCoHttpServer(TContExecutor& executor, const TString& bindAddr, TIpPort port, THandler handler) + TCoHttpServer::TCoHttpServer(TContExecutor& executor, const TString& bindAddr, TIpPort port, THandler handler) : Executor(executor) , Listener(this, &executor) , Handler(std::move(handler)) diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 2f66dddaf8..9272266e50 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -33,7 +33,7 @@ namespace NMonitoring { class TCoHttpServer: private TContListener::ICallBack { public: // initialize and schedule coroutines for execution - TCoHttpServer(TContExecutor& executor, const TString& bindAddr, TIpPort port, THandler handler); + TCoHttpServer(TContExecutor& executor, const TString& bindAddr, TIpPort port, THandler handler); void Start(); void Stop(); @@ -54,7 +54,7 @@ namespace NMonitoring { TContExecutor& Executor; TContListener Listener; THandler Handler; - TString BindAddr; + TString BindAddr; TIpPort Port; }; diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index 06fb0739ff..841ffcc64d 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -2,13 +2,13 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/noncopyable.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ptr.h> using namespace NObjectFactory; struct TArgument { - TString Name; + TString Name; void* Discarded; }; @@ -17,43 +17,43 @@ public: virtual ~ICommonInterface() { } - virtual TString GetValue() const = 0; + virtual TString GetValue() const = 0; }; class TDirectOrder: public ICommonInterface { public: - TDirectOrder(const TString& provider, float factor, TArgument& argument) + TDirectOrder(const TString& provider, float factor, TArgument& argument) : Provider(provider) , Factor(factor) , Argument(argument) { } - TString GetValue() const override { + TString GetValue() const override { return Provider + ToString(Factor) + Argument.Name; } private: - const TString Provider; + const TString Provider; const float Factor; const TArgument Argument; }; class TInverseOrder: public ICommonInterface { public: - TInverseOrder(const TString& provider, float factor, TArgument& argument) + TInverseOrder(const TString& provider, float factor, TArgument& argument) : Provider(provider) , Factor(factor) , Argument(argument) { } - TString GetValue() const override { + TString GetValue() const override { return Argument.Name + ToString(Factor) + Provider; } private: - const TString Provider; + const TString Provider; const float Factor; const TArgument Argument; }; diff --git a/library/cpp/on_disk/chunks/chunked_helpers.cpp b/library/cpp/on_disk/chunks/chunked_helpers.cpp index b7adba2753..faf9164c80 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.cpp +++ b/library/cpp/on_disk/chunks/chunked_helpers.cpp @@ -29,7 +29,7 @@ TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob) Load(&input, Names); size_t index = 0; - for (TVector<TString>::const_iterator it = Names.begin(); it != Names.end(); ++it, ++index) { + for (TVector<TString>::const_iterator it = Names.begin(); it != Names.end(); ++it, ++index) { if (!it->empty()) NameToIndex[*it] = index; } @@ -42,14 +42,14 @@ TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave) { } -TNamedChunkedDataWriter::~TNamedChunkedDataWriter() { +TNamedChunkedDataWriter::~TNamedChunkedDataWriter() { } void TNamedChunkedDataWriter::NewBlock() { NewBlock(""); } -void TNamedChunkedDataWriter::NewBlock(const TString& name) { +void TNamedChunkedDataWriter::NewBlock(const TString& name) { if (!name.empty()) { if (NameToIndex.count(name) != 0) throw yexception() << "Block name is not unique"; diff --git a/library/cpp/on_disk/chunks/chunked_helpers.h b/library/cpp/on_disk/chunks/chunked_helpers.h index 5fa96afdca..207afe7ee1 100644 --- a/library/cpp/on_disk/chunks/chunked_helpers.h +++ b/library/cpp/on_disk/chunks/chunked_helpers.h @@ -54,7 +54,7 @@ public: template <typename T> class TYVectorWriter { private: - TVector<T> Vector; + TVector<T> Vector; public: TYVectorWriter() = default; @@ -233,12 +233,12 @@ template <typename TKey, typename TValue> class TPlainHashWriter : TPlainHashCommon { private: typedef TPackedPair<TKey, TValue> TKeyValuePair; - typedef TVector<TKeyValuePair> TData; + typedef TVector<TKeyValuePair> TData; TData Data; - typedef TVector<TData> TData2; + typedef TVector<TData> TData2; bool IsPlainEnought(ui16 bits) const { - TVector<size_t> counts(1LL << bits, 0); + TVector<size_t> counts(1LL << bits, 0); for (size_t i = 0; i < Data.size(); ++i) { size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)]; ++count; @@ -276,7 +276,7 @@ public: for (size_t i = 0; i < Data.size(); ++i) data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]); - typedef TVector<TInterval> TIntervals; + typedef TVector<TInterval> TIntervals; TIntervals intervals(nBuckets); ui32 offset = 0; for (ui32 i = 0; i < nBuckets; ++i) { @@ -583,7 +583,7 @@ public: template <class T, bool isPod> class TVectorTakingIntoAccountThePodTypeWriter : TNonCopyable { private: - typedef TVector<ui64> TOffsets; + typedef TVector<ui64> TOffsets; TOffsets Offsets; TBuffer Data; TBufferOutput DataStream; @@ -655,12 +655,12 @@ struct TGeneralVectorG<TItem, true> { }; template <> -struct TSaveLoadVectorNonPodElement<TString> { +struct TSaveLoadVectorNonPodElement<TString> { static inline void Save(IOutputStream* out, const TString& s) { out->Write(s.data(), s.size() + 1); } - static inline void Load(TMemoryInput* in, TString& s, size_t elementSize) { + static inline void Load(TMemoryInput* in, TString& s, size_t elementSize) { Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize); s.assign(in->Buf(), elementSize - 1); /// excluding 0 at the end } @@ -670,5 +670,5 @@ template <bool G> struct TStringsVectorG: public TGeneralVectorG<TString, G> { }; -using TStringsVector = TGeneralVector<TString>; -using TStringsVectorWriter = TGeneralVectorWriter<TString>; +using TStringsVector = TGeneralVector<TString>; +using TStringsVectorWriter = TGeneralVectorWriter<TString>; diff --git a/library/cpp/on_disk/chunks/chunks_ut.cpp b/library/cpp/on_disk/chunks/chunks_ut.cpp index f727647f7f..cba0ecd3ab 100644 --- a/library/cpp/on_disk/chunks/chunks_ut.cpp +++ b/library/cpp/on_disk/chunks/chunks_ut.cpp @@ -102,21 +102,21 @@ public: UNIT_ASSERT_EQUAL(reader.RealSize(), sizeof(ui64) + N * sizeof(ui32)); } } - { /// TString + { /// TString const size_t N = 4; TBufferStream stream; { - TGeneralVectorWriter<TString> writer; + TGeneralVectorWriter<TString> writer; for (size_t i = 0; i < N; ++i) writer.PushBack(ToString(i)); writer.Save(stream); } { TBlob temp = TBlob::FromStreamSingleThreaded(stream); - TGeneralVector<TString> reader(temp); + TGeneralVector<TString> reader(temp); UNIT_ASSERT_EQUAL(reader.GetSize(), N); for (size_t i = 0; i < N; ++i) { - TString value; + TString value; reader.Get(i, value); UNIT_ASSERT_EQUAL(value, ToString(i)); UNIT_ASSERT_EQUAL(reader.Get(i), ToString(i)); @@ -151,7 +151,7 @@ public: } { /// pointer const size_t N = 3; - TVector<int> data_holder(N); + TVector<int> data_holder(N); int* a = &(data_holder[0]); TBufferStream stream; { @@ -200,11 +200,11 @@ public: } void TestStrings() { - const TString FILENAME = "chunked_helpers_test.bin"; + const TString FILENAME = "chunked_helpers_test.bin"; TTempFileHandle file(FILENAME.c_str()); { - TFixedBufferFileOutput fOut(FILENAME); + TFixedBufferFileOutput fOut(FILENAME); TStringsVectorWriter stringsWriter; stringsWriter.PushBack(""); stringsWriter.PushBack("test"); @@ -230,11 +230,11 @@ public: } void TestNamedChunkedData() { - const TString filename = MakeTempName(nullptr, "named_chunked_data_test"); + const TString filename = MakeTempName(nullptr, "named_chunked_data_test"); TTempFile file(filename); { - TFixedBufferFileOutput fOut(filename); + TFixedBufferFileOutput fOut(filename); TNamedChunkedDataWriter writer(fOut); writer.NewBlock("alpha"); diff --git a/library/cpp/on_disk/chunks/reader.cpp b/library/cpp/on_disk/chunks/reader.cpp index 6e28cbf367..80235e8084 100644 --- a/library/cpp/on_disk/chunks/reader.cpp +++ b/library/cpp/on_disk/chunks/reader.cpp @@ -5,7 +5,7 @@ #include "reader.h" template <typename T> -static inline void ReadAux(const char* data, T* aux, T count, TVector<const char*>* result) { +static inline void ReadAux(const char* data, T* aux, T count, TVector<const char*>* result) { result->resize(count); for (size_t i = 0; i < count; ++i) { (*result)[i] = data + ReadUnaligned<T>(aux + i); diff --git a/library/cpp/on_disk/chunks/writer.cpp b/library/cpp/on_disk/chunks/writer.cpp index 6dc7397f09..8344045e14 100644 --- a/library/cpp/on_disk/chunks/writer.cpp +++ b/library/cpp/on_disk/chunks/writer.cpp @@ -2,7 +2,7 @@ #include "writer.h" -static inline void WriteAux(IOutputStream* out, const TVector<ui64>& data) { +static inline void WriteAux(IOutputStream* out, const TVector<ui64>& data) { ::SavePodArray(out, data.data(), data.size()); } @@ -14,7 +14,7 @@ TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave) { } -TChunkedDataWriter::~TChunkedDataWriter() { +TChunkedDataWriter::~TChunkedDataWriter() { } void TChunkedDataWriter::NewBlock() { diff --git a/library/cpp/openssl/init/init.cpp b/library/cpp/openssl/init/init.cpp index ae68ef08ea..b2af74c552 100644 --- a/library/cpp/openssl/init/init.cpp +++ b/library/cpp/openssl/init/init.cpp @@ -40,7 +40,7 @@ namespace { } } - TVector<TAutoPtr<TMutex>> Mutexes; + TVector<TAutoPtr<TMutex>> Mutexes; }; inline TInitSsl() { diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp index 0b4be38c0e..64912c9cf4 100644 --- a/library/cpp/openssl/io/stream.cpp +++ b/library/cpp/openssl/io/stream.cpp @@ -44,15 +44,15 @@ namespace { }; struct TSslDestroy { - static inline void Destroy(ssl_ctx_st* ctx) noexcept { + static inline void Destroy(ssl_ctx_st* ctx) noexcept { SSL_CTX_free(ctx); } - static inline void Destroy(ssl_st* ssl) noexcept { + static inline void Destroy(ssl_st* ssl) noexcept { SSL_free(ssl); } - static inline void Destroy(bio_st* bio) noexcept { + static inline void Destroy(bio_st* bio) noexcept { BIO_free(bio); } diff --git a/library/cpp/packedtypes/longs_ut.cpp b/library/cpp/packedtypes/longs_ut.cpp index 8b06c934d2..1cc1415f47 100644 --- a/library/cpp/packedtypes/longs_ut.cpp +++ b/library/cpp/packedtypes/longs_ut.cpp @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TLongsTest) { i16 x16 = 40; i64 x64 = 40; i64 y64; - TString s; + TString s; s += Sprintf("x16=0x%x\n", (int)x16); s += Sprintf("LO_8(x16)=0x%x HI_8(x16)=0x%x\n\n", (int)Lo8(x16), (int)Hi8(x16)); diff --git a/library/cpp/packedtypes/packed_ut.cpp b/library/cpp/packedtypes/packed_ut.cpp index 70a22cf9c3..baefec85ce 100644 --- a/library/cpp/packedtypes/packed_ut.cpp +++ b/library/cpp/packedtypes/packed_ut.cpp @@ -25,7 +25,7 @@ static T PseudoRandom(T max = Max<T>()) { } Y_UNIT_TEST_SUITE(TPackedTest) { - void TestPackUi32Sub(ui32 v, const TVector<char>& p) { + void TestPackUi32Sub(ui32 v, const TVector<char>& p) { TBufferOutput out; PackUI32(out, v); const TBuffer& buf = out.Buffer(); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { Y_UNIT_TEST(TestPackUi32) { ui32 v; - TVector<char> pv; + TVector<char> pv; v = 0; pv.resize(1); @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { TBuffer buffer(65536); char* writePtr = buffer.Data(); - TVector<ui32> correctNumbers; + TVector<ui32> correctNumbers; for (size_t i = 0; i < 1000; ++i) { ui32 randNum = NPrivate::PseudoRandom<ui32>(); correctNumbers.push_back(randNum); @@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TPackedTest) { TBuffer buffer(65536); char* writePtr = buffer.Data(); - TVector<ui64> correctNumbers; + TVector<ui64> correctNumbers; for (size_t i = 0; i < 1000; ++i) { ui64 randNum = NPrivate::PseudoRandom<ui64>(); correctNumbers.push_back(randNum); diff --git a/library/cpp/packers/packers.h b/library/cpp/packers/packers.h index 1bde1b59aa..80ecfab3b2 100644 --- a/library/cpp/packers/packers.h +++ b/library/cpp/packers/packers.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/set.h> #include <util/generic/list.h> @@ -249,47 +249,47 @@ namespace NPackers { }; //------------------------------------------- - // TStringPacker --- for TString/TUtf16String and TStringBuf. + // TStringPacker --- for TString/TUtf16String and TStringBuf. - template <class TStringType> + template <class TStringType> class TStringPacker { public: - void UnpackLeaf(const char* p, TStringType& t) const; - void PackLeaf(char* buffer, const TStringType& data, size_t size) const; - size_t MeasureLeaf(const TStringType& data) const; + void UnpackLeaf(const char* p, TStringType& t) const; + void PackLeaf(char* buffer, const TStringType& data, size_t size) const; + size_t MeasureLeaf(const TStringType& data) const; size_t SkipLeaf(const char* p) const; }; template <class TStringType> - inline void TStringPacker<TStringType>::UnpackLeaf(const char* buf, TStringType& t) const { + inline void TStringPacker<TStringType>::UnpackLeaf(const char* buf, TStringType& t) const { size_t len; TIntegralPacker<size_t>().UnpackLeaf(buf, len); size_t start = TIntegralPacker<size_t>().SkipLeaf(buf); - t = TStringType((const typename TStringType::char_type*)(buf + start), len); + t = TStringType((const typename TStringType::char_type*)(buf + start), len); } template <class TStringType> - inline void TStringPacker<TStringType>::PackLeaf(char* buf, const TStringType& str, size_t size) const { + inline void TStringPacker<TStringType>::PackLeaf(char* buf, const TStringType& str, size_t size) const { size_t len = str.size(); - size_t lenChar = len * sizeof(typename TStringType::char_type); + size_t lenChar = len * sizeof(typename TStringType::char_type); size_t start = size - lenChar; TIntegralPacker<size_t>().PackLeaf(buf, len, TIntegralPacker<size_t>().MeasureLeaf(len)); memcpy(buf + start, str.data(), lenChar); } template <class TStringType> - inline size_t TStringPacker<TStringType>::MeasureLeaf(const TStringType& str) const { + inline size_t TStringPacker<TStringType>::MeasureLeaf(const TStringType& str) const { size_t len = str.size(); - return TIntegralPacker<size_t>().MeasureLeaf(len) + len * sizeof(typename TStringType::char_type); + return TIntegralPacker<size_t>().MeasureLeaf(len) + len * sizeof(typename TStringType::char_type); } template <class TStringType> - inline size_t TStringPacker<TStringType>::SkipLeaf(const char* buf) const { + inline size_t TStringPacker<TStringType>::SkipLeaf(const char* buf) const { size_t result = TIntegralPacker<size_t>().SkipLeaf(buf); { size_t len; TIntegralPacker<size_t>().UnpackLeaf(buf, len); - result += len * sizeof(typename TStringType::char_type); + result += len * sizeof(typename TStringType::char_type); } return result; } @@ -304,7 +304,7 @@ namespace NPackers { // - has subclass C::const_iterator // - has methods begin() and end() (return C::const_iterator) // - has method insert(C::const_iterator, const C::value_type&) - // Examples: TVector, TList, TSet + // Examples: TVector, TList, TSet // Requirements to class EP: has methods as in any packer (UnpackLeaf, PackLeaf, MeasureLeaf, SkipLeaf) that // are applicable to C::value_type diff --git a/library/cpp/packers/ut/region_packer_ut.cpp b/library/cpp/packers/ut/region_packer_ut.cpp index 0cb08ccf65..b083320f61 100644 --- a/library/cpp/packers/ut/region_packer_ut.cpp +++ b/library/cpp/packers/ut/region_packer_ut.cpp @@ -4,7 +4,7 @@ template <typename TValue> void TestPacker() { TValue values[] = {1, 2, 3, 42}; - TString buffer; + TString buffer; TRegionPacker<TValue> p; diff --git a/library/cpp/pop_count/benchmark/main.cpp b/library/cpp/pop_count/benchmark/main.cpp index 41ea3c91cc..cc20c6f6c4 100644 --- a/library/cpp/pop_count/benchmark/main.cpp +++ b/library/cpp/pop_count/benchmark/main.cpp @@ -9,8 +9,8 @@ template <class F, class I> inline void DoRun(F&& f, I&& i) { const ui64 n = i.Iterations(); - for (ui64 j = 0; j < n; ++j) { - Y_DO_NOT_OPTIMIZE_AWAY(f(j * (ui64)123456 + (ui64)1)); + for (ui64 j = 0; j < n; ++j) { + Y_DO_NOT_OPTIMIZE_AWAY(f(j * (ui64)123456 + (ui64)1)); } } diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 640c10f5a5..9cd9007f15 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -34,7 +34,7 @@ break; \ } -static TString GetFieldName(const google::protobuf::FieldDescriptor& field, +static TString GetFieldName(const google::protobuf::FieldDescriptor& field, const NProtobufJson::TJson2ProtoConfig& config) { if (config.NameGenerator) { return config.NameGenerator(field); @@ -50,7 +50,7 @@ static TString GetFieldName(const google::protobuf::FieldDescriptor& field, return name; } - TString name = field.name(); + TString name = field.name(); switch (config.FieldNameMode) { case NProtobufJson::TJson2ProtoConfig::FieldNameOriginalCase: break; @@ -318,7 +318,7 @@ Json2RepeatedField(const NJson::TJsonValue& json, const NProtobufJson::TJson2ProtoConfig& config) { using namespace google::protobuf; - TString name = GetFieldName(field, config); + TString name = GetFieldName(field, config); if (!json.Has(name)) return; diff --git a/library/cpp/protobuf/json/proto2json_printer.h b/library/cpp/protobuf/json/proto2json_printer.h index 9dc5aa86c6..9057ac574c 100644 --- a/library/cpp/protobuf/json/proto2json_printer.h +++ b/library/cpp/protobuf/json/proto2json_printer.h @@ -7,7 +7,7 @@ #include <google/protobuf/message.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> namespace NProtobufJson { struct TProto2JsonConfig; diff --git a/library/cpp/protobuf/json/ut/inline_ut.cpp b/library/cpp/protobuf/json/ut/inline_ut.cpp index c29ad32e7d..2f2efacf45 100644 --- a/library/cpp/protobuf/json/ut/inline_ut.cpp +++ b/library/cpp/protobuf/json/ut/inline_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/protobuf/json/proto2json.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/string.h> +#include <util/generic/string.h> using namespace NProtobufJson; diff --git a/library/cpp/protobuf/json/ut/json.h b/library/cpp/protobuf/json/ut/json.h index c1f108e6e4..b36d848b58 100644 --- a/library/cpp/protobuf/json/ut/json.h +++ b/library/cpp/protobuf/json/ut/json.h @@ -7,7 +7,7 @@ #include <cstdarg> #include <util/generic/hash_set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/system/defaults.h> diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 0dfe57bc7a..ce9d28222a 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -13,7 +13,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/hash_set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ylimits.h> #include <util/stream/str.h> #include <util/string/cast.h> diff --git a/library/cpp/protobuf/json/ut/proto.h b/library/cpp/protobuf/json/ut/proto.h index 8183bfc8e1..53454cd950 100644 --- a/library/cpp/protobuf/json/ut/proto.h +++ b/library/cpp/protobuf/json/ut/proto.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/hash_set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/system/defaults.h> diff --git a/library/cpp/protobuf/json/ut/proto2json_ut.cpp b/library/cpp/protobuf/json/ut/proto2json_ut.cpp index 07e52d7f2f..ed5a414b20 100644 --- a/library/cpp/protobuf/json/ut/proto2json_ut.cpp +++ b/library/cpp/protobuf/json/ut/proto2json_ut.cpp @@ -12,7 +12,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/hash_set.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/ylimits.h> #include <util/stream/str.h> diff --git a/library/cpp/protobuf/json/ut/repeated_fields.incl b/library/cpp/protobuf/json/ut/repeated_fields.incl index e9548917d8..332482450f 100644 --- a/library/cpp/protobuf/json/ut/repeated_fields.incl +++ b/library/cpp/protobuf/json/ut/repeated_fields.incl @@ -12,10 +12,10 @@ DEFINE_REPEATED_FIELD(FI64, ui64, 0ull, 1ull, Max<ui64>()) DEFINE_REPEATED_FIELD(SFI32, i32, Min<i32>(), -1, 0, 1, Max<i32>()) DEFINE_REPEATED_FIELD(SFI64, i64, Min<i64>(), -1ll, 0ll, 1ll, Max<i64>()) DEFINE_REPEATED_FIELD(Bool, bool, false, true) -DEFINE_REPEATED_FIELD(String, TString, "", "Lorem ipsum", "123123") -DEFINE_REPEATED_FIELD(Bytes, TString, "", "מחשב", "\x1") +DEFINE_REPEATED_FIELD(String, TString, "", "Lorem ipsum", "123123") +DEFINE_REPEATED_FIELD(Bytes, TString, "", "מחשב", "\x1") DEFINE_REPEATED_FIELD(Enum, EEnum, E_1, E_2, E_3) DEFINE_REPEATED_FIELD(Float, float, 0.0f, 1.0f, 1.123f) DEFINE_REPEATED_FIELD(Double, double, 0.0, 1.0, 1.123456789012) -DEFINE_REPEATED_FIELD(OneString, TString, "", "Lorem ipsum dolor", "1231231") -DEFINE_REPEATED_FIELD(OneTwoString, TString, "", "Lorem ipsum dolor sit", "12312312") +DEFINE_REPEATED_FIELD(OneString, TString, "", "Lorem ipsum dolor", "1231231") +DEFINE_REPEATED_FIELD(OneTwoString, TString, "", "Lorem ipsum dolor sit", "12312312") diff --git a/library/cpp/protobuf/json/ut/string_transform_ut.cpp b/library/cpp/protobuf/json/ut/string_transform_ut.cpp index a31dabcb0f..f5a0011b77 100644 --- a/library/cpp/protobuf/json/ut/string_transform_ut.cpp +++ b/library/cpp/protobuf/json/ut/string_transform_ut.cpp @@ -6,7 +6,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); - TString s; + TString s; s = ""; transform.Transform(s); UNIT_ASSERT_EQUAL(s, ""); @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); - TString s; + TString s; s = "abacaba"; transform.Transform(s); UNIT_ASSERT_EQUAL(s, "abacaba"); @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); - TString s; + TString s; s = "тест"; transform.Transform(s); UNIT_ASSERT_EQUAL(s, "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); - TString s; + TString s; s = "aba\\ca\"ba"; transform.Transform(s); Cerr << "###" << s << Endl; @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); - TString s; + TString s; s = ""; transform.Transform(s); UNIT_ASSERT_EQUAL("", s); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); - TString s; + TString s; s = "abacaba"; transform.Transform(s); Cerr << "###" << s << Endl; @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); - TString s; + TString s; s = "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"; transform.Transform(s); UNIT_ASSERT_EQUAL("тест", s); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); - TString s; + TString s; s = "aba\\\\\\\\ca\\\\\\\"ba"; transform.Transform(s); UNIT_ASSERT_EQUAL("aba\\ca\"ba", s); @@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); - TString s; + TString s; s = "\\\\\\\\\\\\\\\\"; transform.Transform(s); UNIT_ASSERT_EQUAL("\\\\", s); diff --git a/library/cpp/protobuf/json/ut/test.proto b/library/cpp/protobuf/json/ut/test.proto index 0fa996fd41..32ff53cd0b 100644 --- a/library/cpp/protobuf/json/ut/test.proto +++ b/library/cpp/protobuf/json/ut/test.proto @@ -131,7 +131,7 @@ message TCompositeRepeated { repeated TFlatOptional Part = 1; }; -message TMapType { +message TMapType { map<string, string> Items = 1; }; diff --git a/library/cpp/protobuf/util/is_equal_ut.cpp b/library/cpp/protobuf/util/is_equal_ut.cpp index 3ca4c90dd5..b3388783c4 100644 --- a/library/cpp/protobuf/util/is_equal_ut.cpp +++ b/library/cpp/protobuf/util/is_equal_ut.cpp @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { a.SetName("aaa"); b.SetName("bbb"); - TString path; + TString path; bool equal = NProtoBuf::IsEqual(a, b, &path); UNIT_ASSERT(!equal); @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { a.MutableInner()->SetBrbrbr("aaa"); b.MutableInner()->SetBrbrbr("bbb"); - TString path; + TString path; bool equal = NProtoBuf::IsEqual(a, b, &path); UNIT_ASSERT(!equal); diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 6270ee0624..0a01549d79 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -7,7 +7,7 @@ #include <google/protobuf/messagext.h> #include <google/protobuf/text_format.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/stream/file.h> #include <util/stream/str.h> #include <util/string/cast.h> @@ -101,10 +101,10 @@ void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { } } -void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) { - /* TUnbufferedFileOutput is unbuffered, but TCopyingOutputStreamAdaptor adds +void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) { + /* TUnbufferedFileOutput is unbuffered, but TCopyingOutputStreamAdaptor adds * a buffer on top of it. */ - TUnbufferedFileOutput stream(fileName); + TUnbufferedFileOutput stream(fileName); SerializeToTextFormat(m, stream); } @@ -150,15 +150,15 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, } } -void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, +void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, const EParseFromTextFormatOptions options) { - /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds + /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds * a buffer on top of it. */ - TUnbufferedFileInput stream(fileName); + TUnbufferedFileInput stream(fileName); ParseFromTextFormat(stream, m, options); } -bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, +bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, const EParseFromTextFormatOptions options) { try { ParseFromTextFormat(fileName, m, options); @@ -192,9 +192,9 @@ void MergeFromTextFormat(IInputStream& in, NProtoBuf::Message& m, void MergeFromTextFormat(const TString& fileName, NProtoBuf::Message& m, const EParseFromTextFormatOptions options) { - /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds + /* TUnbufferedFileInput is unbuffered, but TCopyingInputStreamAdaptor adds * a buffer on top of it. */ - TUnbufferedFileInput stream(fileName); + TUnbufferedFileInput stream(fileName); MergeFromTextFormat(stream, m, options); } diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 493c84cb5f..3a5e16ad67 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -32,11 +32,11 @@ namespace NProtoBuf { /* Serialize message into string and apply base64 URL encoding. */ - TString SerializeToBase64String(const Message& m); - void SerializeToBase64String(const Message& m, TString& dataBase64); - bool TrySerializeToBase64String(const Message& m, TString& dataBase64); + TString SerializeToBase64String(const Message& m); + void SerializeToBase64String(const Message& m, TString& dataBase64); + bool TrySerializeToBase64String(const Message& m, TString& dataBase64); - const TString ShortUtf8DebugString(const Message& message); + const TString ShortUtf8DebugString(const Message& message); bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); @@ -45,7 +45,7 @@ namespace NProtoBuf { int operator&(NProtoBuf::Message& m, IBinSaver& f); // Write a textual representation of the given message to the given file. -void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); +void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); // Write a textual representation of the given message to the given output stream @@ -64,7 +64,7 @@ enum class EParseFromTextFormatOption : ui64 { Y_DECLARE_FLAGS(EParseFromTextFormatOptions, EParseFromTextFormatOption); // Parse a text-format protocol message from the given file into message object. -void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, +void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, const EParseFromTextFormatOptions options = {}); // NOTE: will read `in` till the end. void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, @@ -74,7 +74,7 @@ void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, * * @see `ParseFromTextFormat` */ -bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, +bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, const EParseFromTextFormatOptions options = {}); // NOTE: will read `in` till the end. bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, @@ -82,7 +82,7 @@ bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, // @see `ParseFromTextFormat` template <typename T> -static T ParseFromTextFormat(const TString& fileName, +static T ParseFromTextFormat(const TString& fileName, const EParseFromTextFormatOptions options = {}) { T message; ParseFromTextFormat(fileName, message, options); diff --git a/library/cpp/protobuf/util/pb_io_ut.cpp b/library/cpp/protobuf/util/pb_io_ut.cpp index 875d6dc602..de62b0b0a1 100644 --- a/library/cpp/protobuf/util/pb_io_ut.cpp +++ b/library/cpp/protobuf/util/pb_io_ut.cpp @@ -23,7 +23,7 @@ static NProtobufUtilUt::TTextEnumTest GetCorrectEnumMessage() { return m; } -static const TString CORRECT_MESSAGE = +static const TString CORRECT_MESSAGE = R"(Foo: 42 )"; static const TString CORRECT_ENUM_NAME_MESSAGE = @@ -33,7 +33,7 @@ static const TString CORRECT_ENUM_ID_MESSAGE = R"(Slot: 1 )"; -static const TString INCORRECT_MESSAGE = +static const TString INCORRECT_MESSAGE = R"(Bar: 1 )"; static const TString INCORRECT_ENUM_NAME_MESSAGE = @@ -43,11 +43,11 @@ static const TString INCORRECT_ENUM_ID_MESSAGE = R"(Slot: 3 )"; -static const TString CORRECT_BASE64_MESSAGE = "CCo,"; +static const TString CORRECT_BASE64_MESSAGE = "CCo,"; static const TString CORRECT_UNEVEN_BASE64_MESSAGE = "CCo"; -static const TString INCORRECT_BASE64_MESSAGE = "CC"; +static const TString INCORRECT_BASE64_MESSAGE = "CC"; Y_UNIT_TEST_SUITE(TTestProtoBufIO) { Y_UNIT_TEST(TestBase64) { @@ -81,8 +81,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); - TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); + TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); { NProtobufUtilUt::TTextTest message; @@ -138,8 +138,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { } { NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(correctFileName); }; UNIT_ASSERT_NO_EXCEPTION(f(m)); UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); @@ -150,8 +150,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { { NProtobufUtilUt::TTextTest m; TStringInput in{CORRECT_MESSAGE}; - const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { - mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in); + const auto f = [&in](NProtobufUtilUt::TTextTest& mm) { + mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in); }; UNIT_ASSERT_NO_EXCEPTION(f(m)); UNIT_ASSERT(NProtoBuf::IsEqual(GetCorrectMessage(), m)); @@ -161,10 +161,10 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT_EXCEPTION(ParseFromTextFormat<NProtobufUtilUt::TTextTest>(in), yexception); } { - const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; + const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; const auto original = GetCorrectMessage(); - UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); - const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); + UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); + const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); } { @@ -175,8 +175,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { } { NProtobufUtilUt::TTextTest m; - const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { - mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( + const auto f = [&correctFileName](NProtobufUtilUt::TTextTest& mm) { + mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( correctFileName, EParseFromTextFormatOption::AllowUnknownField); }; @@ -186,8 +186,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { { const NProtobufUtilUt::TTextTest empty; NProtobufUtilUt::TTextTest m; - const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { - mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( + const auto f = [&incorrectFileName](NProtobufUtilUt::TTextTest& mm) { + mm = ParseFromTextFormat<NProtobufUtilUt::TTextTest>( incorrectFileName, EParseFromTextFormatOption::AllowUnknownField); }; @@ -258,8 +258,8 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { const TFsPath correctFileName = TFsPath{tempDir()} / "correct.pb.txt"; const TFsPath incorrectFileName = TFsPath{tempDir()} / "incorrect.pb.txt"; - TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); - TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); + TFileOutput{correctFileName}.Write(CORRECT_MESSAGE); + TFileOutput{incorrectFileName}.Write(INCORRECT_MESSAGE); { NProtobufUtilUt::TTextTest message; @@ -341,7 +341,7 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { const TFsPath correctFileName2 = TFsPath{tempDir()} / "serialized.pb.txt"; const auto original = GetCorrectMessage(); UNIT_ASSERT_NO_EXCEPTION(SerializeToTextFormat(original, correctFileName2)); - const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); + const auto serializedStr = TUnbufferedFileInput{correctFileName2}.ReadAll(); UNIT_ASSERT_VALUES_EQUAL(serializedStr, CORRECT_MESSAGE); } { diff --git a/library/cpp/protobuf/util/simple_reflection_ut.cpp b/library/cpp/protobuf/util/simple_reflection_ut.cpp index 169d4703c9..28a1d3d360 100644 --- a/library/cpp/protobuf/util/simple_reflection_ut.cpp +++ b/library/cpp/protobuf/util/simple_reflection_ut.cpp @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { TMaybe<TConstField> field = TConstField::ByPath(msg, "OneStr"); UNIT_ASSERT(field); UNIT_ASSERT(field->HasValue()); - UNIT_ASSERT_VALUES_EQUAL("1", (field->Get<TString>())); + UNIT_ASSERT_VALUES_EQUAL("1", (field->Get<TString>())); } { @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { TMaybe<TMutableField> field = TMutableField::ByPath(msg, "OneStr"); UNIT_ASSERT(field); UNIT_ASSERT(!field->HasValue()); - field->Set(TString("zz")); + field->Set(TString("zz")); UNIT_ASSERT(field->HasValue()); UNIT_ASSERT_VALUES_EQUAL("zz", msg.GetOneStr()); } @@ -227,7 +227,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { TMaybe<TMutableField> field = TMutableField::ByPath(msg, "OneStr"); UNIT_ASSERT(field); UNIT_ASSERT(field->HasValue()); - field->Set(TString("dd")); + field->Set(TString("dd")); UNIT_ASSERT(field->HasValue()); UNIT_ASSERT_VALUES_EQUAL("dd", msg.GetOneStr()); } @@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(ProtobufSimpleReflection) { { TMaybe<TMutableField> field = TMutableField::ByPath(msg, "RepMsg/RepInt", true); TMaybe<TMutableField> fieldCopy = TMutableField::ByPath(msg, "RepMsg/RepInt", true); - Y_UNUSED(fieldCopy); + Y_UNUSED(fieldCopy); UNIT_ASSERT(field); UNIT_ASSERT(!field->HasValue()); UNIT_ASSERT_VALUES_EQUAL(1, msg.RepMsgSize()); diff --git a/library/cpp/protobuf/util/walk_ut.cpp b/library/cpp/protobuf/util/walk_ut.cpp index 2ea6071b17..134c0a49f7 100644 --- a/library/cpp/protobuf/util/walk_ut.cpp +++ b/library/cpp/protobuf/util/walk_ut.cpp @@ -37,8 +37,8 @@ Y_UNIT_TEST_SUITE(ProtobufWalk) { TMutableField f(msg, fd); if (f.IsString()) { for (size_t i = 0; i < f.Size(); ++i) - if (f.Get<TString>(i).StartsWith('1')) - f.Set(f.Get<TString>(i) + f.Get<TString>(i), i); + if (f.Get<TString>(i).StartsWith('1')) + f.Set(f.Get<TString>(i) + f.Get<TString>(i), i); } return true; } diff --git a/library/cpp/regex/hyperscan/hyperscan.cpp b/library/cpp/regex/hyperscan/hyperscan.cpp index ba321f9c29..98e402962d 100644 --- a/library/cpp/regex/hyperscan/hyperscan.cpp +++ b/library/cpp/regex/hyperscan/hyperscan.cpp @@ -249,7 +249,7 @@ namespace NHyperscan { return NPrivate::Matches(db, scratch, text, *Singleton<NPrivate::TImpl>()); } - TString Serialize(const TDatabase& db) { + TString Serialize(const TDatabase& db) { char* databaseBytes = nullptr; size_t databaseLength; hs_error_t status = Singleton<NPrivate::TImpl>()->SerializeDatabase( @@ -260,7 +260,7 @@ namespace NHyperscan { if (status != HS_SUCCESS) { ythrow yexception() << "Failed to serialize hyperscan database"; } - return TString(serialization.Get(), databaseLength); + return TString(serialization.Get(), databaseLength); } TDatabase Deserialize(const TStringBuf& serialization) { diff --git a/library/cpp/regex/hyperscan/hyperscan.h b/library/cpp/regex/hyperscan/hyperscan.h index 1c8f404389..b615abea1d 100644 --- a/library/cpp/regex/hyperscan/hyperscan.h +++ b/library/cpp/regex/hyperscan/hyperscan.h @@ -121,8 +121,8 @@ namespace NHyperscan { TDatabase Compile(const TStringBuf& regex, unsigned int flags, TCPUFeatures cpuFeatures); TDatabase CompileMulti( - const TVector<const char*>& regexs, - const TVector<unsigned int>& flags, + const TVector<const char*>& regexs, + const TVector<unsigned int>& flags, const TVector<unsigned int>& ids, const TVector<const hs_expr_ext_t*>* extendedParameters = nullptr); @@ -154,7 +154,7 @@ namespace NHyperscan { const TScratch& scratch, const TStringBuf& text); - TString Serialize(const TDatabase& db); + TString Serialize(const TDatabase& db); TDatabase Deserialize(const TStringBuf& serialization); } diff --git a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp index 9caa53f2e7..30b4024b33 100644 --- a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp +++ b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { UNIT_ASSERT(NHyperscan::Matches(db, scratch, "BAR")); UNIT_ASSERT(!NHyperscan::Matches(db, scratch, "FOO")); - TSet<unsigned int> foundIds; + TSet<unsigned int> foundIds; auto callback = [&](unsigned int id, unsigned long long /* from */, unsigned long long /* to */) { foundIds.insert(id); }; @@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { NHyperscan::TDatabase db = NHyperscan::Compile( "foo", HS_FLAG_DOTALL | HS_FLAG_SINGLEMATCH); - TString serialization = Serialize(db); + TString serialization = Serialize(db); db.Reset(); TDatabase db2 = Deserialize(serialization); NHyperscan::TScratch scratch = NHyperscan::MakeScratch(db2); diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index 575c09cee4..335c27f2eb 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -1,6 +1,6 @@ #include "regexp.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/ascii.h> #include <util/system/defaults.h> @@ -135,7 +135,7 @@ class TRegExBaseImpl: public TAtomicRefCount<TRegExBaseImpl> { protected: int CompileOptions; - TString RegExpr; + TString RegExpr; regex_t Preg; public: @@ -145,7 +145,7 @@ public: memset(&Preg, 0, sizeof(Preg)); } - TRegExBaseImpl(const TString& re, int cflags) + TRegExBaseImpl(const TString& re, int cflags) : CompileOptions(cflags) , RegExpr(re) { @@ -188,7 +188,7 @@ public: } private: - TString Error; + TString Error; }; bool TRegExBase::IsCompiled() const { @@ -201,14 +201,14 @@ TRegExBase::TRegExBase(const char* re, int cflags) { } } -TRegExBase::TRegExBase(const TString& re, int cflags) { +TRegExBase::TRegExBase(const TString& re, int cflags) { Compile(re, cflags); } TRegExBase::~TRegExBase() { } -void TRegExBase::Compile(const TString& re, int cflags) { +void TRegExBase::Compile(const TString& re, int cflags) { Impl = new TRegExBaseImpl(re, cflags); } @@ -224,7 +224,7 @@ int TRegExBase::GetCompileOptions() const { return Impl->CompileOptions; } -TString TRegExBase::GetRegExpr() const { +TString TRegExBase::GetRegExpr() const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; return Impl->RegExpr; @@ -235,7 +235,7 @@ TRegExMatch::TRegExMatch(const char* re, int cflags) { } -TRegExMatch::TRegExMatch(const TString& re, int cflags) +TRegExMatch::TRegExMatch(const TString& re, int cflags) : TRegExBase(re, cflags) { } @@ -251,17 +251,17 @@ TRegExSubst::TRegExSubst(const char* re, int cflags) memset(Brfs, 0, sizeof(TBackReferences) * NMATCHES); } -TString TRegExSubst::Replace(const char* str, int eflags) { - TString s; +TString TRegExSubst::Replace(const char* str, int eflags) { + TString s; if (BrfsCount) { if (Exec(str, PMatch, eflags) == 0) { int i; for (i = 0; i < BrfsCount; i++) { - s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); + s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); if (Brfs[i].Refer >= 0 && Brfs[i].Refer < NMATCHES) - s += TString(str, PMatch[Brfs[i].Refer].rm_so, int(PMatch[Brfs[i].Refer].rm_eo - PMatch[Brfs[i].Refer].rm_so)); + s += TString(str, PMatch[Brfs[i].Refer].rm_so, int(PMatch[Brfs[i].Refer].rm_eo - PMatch[Brfs[i].Refer].rm_so)); } - s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); + s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); } } else { s = Replacement; diff --git a/library/cpp/regex/pcre/regexp.h b/library/cpp/regex/pcre/regexp.h index bc610bd2f3..742fa20dac 100644 --- a/library/cpp/regex/pcre/regexp.h +++ b/library/cpp/regex/pcre/regexp.h @@ -3,7 +3,7 @@ #include <sys/types.h> #include <util/system/defaults.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/yexception.h> #include <contrib/libs/pcre/pcre.h> @@ -22,21 +22,21 @@ protected: public: TRegExBase(const char* regExpr = nullptr, int cflags = REG_EXTENDED); - TRegExBase(const TString& regExpr, int cflags = REG_EXTENDED); + TRegExBase(const TString& regExpr, int cflags = REG_EXTENDED); virtual ~TRegExBase(); int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches = NMATCHES) const; - void Compile(const TString& regExpr, int cflags = REG_EXTENDED); + void Compile(const TString& regExpr, int cflags = REG_EXTENDED); bool IsCompiled() const; int GetCompileOptions() const; - TString GetRegExpr() const; + TString GetRegExpr() const; }; class TRegExMatch: public TRegExBase { public: TRegExMatch(const char* regExpr = nullptr, int cflags = REG_NOSUB | REG_EXTENDED); - TRegExMatch(const TString& regExpr, int cflags = REG_NOSUB | REG_EXTENDED); + TRegExMatch(const TString& regExpr, int cflags = REG_NOSUB | REG_EXTENDED); bool Match(const char* str) const; }; @@ -58,6 +58,6 @@ private: public: TRegExSubst(const char* regExpr = nullptr, int cflags = REG_EXTENDED); - TString Replace(const char* str, int eflags = 0); + TString Replace(const char* str, int eflags = 0); int ParseReplacement(const char* replacement); }; diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 5184e801cc..4047ebffbd 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -56,7 +56,7 @@ private: inline void TestRe() { for (const auto& regTest : REGTEST_DATA) { memset(Matches, 0, sizeof(Matches)); - TString result; + TString result; TRegExBase re(regTest.Regexp, regTest.CompileOptions); if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { @@ -78,13 +78,13 @@ private: for (const auto& substTest : SUBSTTEST_DATA) { TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); subst.ParseReplacement(substTest.Replacement); - TString result = subst.Replace(substTest.Data, substTest.RunOptions); + TString result = subst.Replace(substTest.Data, substTest.RunOptions); UNIT_ASSERT_VALUES_EQUAL(result, substTest.Result); TRegExSubst substCopy = subst; subst.ParseReplacement(substTest.Replacement2); - TString newResult = subst.Replace(substTest.Data, substTest.RunOptions); + TString newResult = subst.Replace(substTest.Data, substTest.RunOptions); UNIT_ASSERT_VALUES_UNEQUAL(newResult.c_str(), result.c_str()); - TString copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); + TString copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); UNIT_ASSERT_VALUES_EQUAL(copyResult, result); substCopy = subst; copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); diff --git a/library/cpp/regex/pire/pcre2pire.cpp b/library/cpp/regex/pire/pcre2pire.cpp index f788beb85f..d989656e1c 100644 --- a/library/cpp/regex/pire/pcre2pire.cpp +++ b/library/cpp/regex/pire/pcre2pire.cpp @@ -3,7 +3,7 @@ #include <util/generic/yexception.h> TString Pcre2Pire(const TString& src) { - TVector<char> result; + TVector<char> result; result.reserve(src.size() + 1); enum EState { diff --git a/library/cpp/regex/pire/pcre2pire.h b/library/cpp/regex/pire/pcre2pire.h index 46e45b9193..054fea6f01 100644 --- a/library/cpp/regex/pire/pcre2pire.h +++ b/library/cpp/regex/pire/pcre2pire.h @@ -2,7 +2,7 @@ // Author: smikler@yandex-team.ru -#include <util/generic/string.h> +#include <util/generic/string.h> /* Converts pcre regular expression to pire compatible format: * - replaces "\\#" with "#" @@ -16,4 +16,4 @@ * NOTE: * - Not fully tested! */ -TString Pcre2Pire(const TString& src); +TString Pcre2Pire(const TString& src); diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 94bba4064b..f3b98bc91c 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -6,7 +6,7 @@ #include <library/cpp/charset/recyr.hh> #include <util/generic/maybe.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -15,22 +15,22 @@ namespace NRegExp { struct TFsmBase { struct TOptions { - inline TOptions& SetCaseInsensitive(bool v) noexcept { + inline TOptions& SetCaseInsensitive(bool v) noexcept { CaseInsensitive = v; return *this; } - inline TOptions& SetSurround(bool v) noexcept { + inline TOptions& SetSurround(bool v) noexcept { Surround = v; return *this; } - inline TOptions& SetCapture(size_t pos) noexcept { + inline TOptions& SetCapture(size_t pos) noexcept { CapturePos = pos; return *this; } - inline TOptions& SetCharset(ECharset charset) noexcept { + inline TOptions& SetCharset(ECharset charset) noexcept { Charset = charset; return *this; } @@ -118,7 +118,7 @@ namespace NRegExp { { } - inline const TScanner& GetScanner() const noexcept { + inline const TScanner& GetScanner() const noexcept { return Scanner; } @@ -202,7 +202,7 @@ namespace NRegExp { Fsm.GetScanner().Initialize(State); } - inline bool Final() const noexcept { + inline bool Final() const noexcept { return GetScanner().Final(GetState()); } @@ -217,11 +217,11 @@ namespace NRegExp { } } - inline const typename TFsm::TScanner& GetScanner() const noexcept { + inline const typename TFsm::TScanner& GetScanner() const noexcept { return Fsm.GetScanner(); } - inline const TState& GetState() const noexcept { + inline const TState& GetState() const noexcept { return State; } @@ -245,13 +245,13 @@ namespace NRegExp { return Match(s.data(), s.size(), addBegin, addEnd); } - inline const char* Find(const char* b, const char* e) noexcept { + inline const char* Find(const char* b, const char* e) noexcept { return NPire::ShortestPrefix(GetScanner(), b, e); } typedef std::pair<const size_t*, const size_t*> TMatchedRegexps; - inline TMatchedRegexps MatchedRegexps() const noexcept { + inline TMatchedRegexps MatchedRegexps() const noexcept { return GetScanner().AcceptedRegexps(GetState()); } }; @@ -263,7 +263,7 @@ namespace NRegExp { { } - inline bool Captured() const noexcept { + inline bool Captured() const noexcept { return GetState().Captured(); } @@ -277,7 +277,7 @@ namespace NRegExp { return Search(s.data(), s.size()); } - inline TStringBuf GetCaptured() const noexcept { + inline TStringBuf GetCaptured() const noexcept { return TStringBuf(Data.data() + GetState().Begin() - 1, Data.data() + GetState().End() - 1); } diff --git a/library/cpp/regex/pire/ut/ya.make b/library/cpp/regex/pire/ut/ya.make index 8776695f40..117ef9694f 100644 --- a/library/cpp/regex/pire/ut/ya.make +++ b/library/cpp/regex/pire/ut/ya.make @@ -1,4 +1,4 @@ -# this test in not linked into build tree with ReCURSE and is built by unittest/library +# this test in not linked into build tree with ReCURSE and is built by unittest/library UNITTEST() diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 66001c4769..cf9dbb1be7 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -20,7 +20,7 @@ namespace { typedef std::pair<TStringBuf, TStringBuf> TDescriptor; - struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { + struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { void Store(const TStringBuf key, const TStringBuf data) override { if (contains(key)) { const TStringBuf value = (*this)[key]->second; @@ -87,7 +87,7 @@ namespace { } } - size_t Count() const noexcept override { + size_t Count() const noexcept override { return D_.size(); } @@ -95,7 +95,7 @@ namespace { return D_.at(idx).first; } - typedef TDeque<TDescriptor> TDescriptors; + typedef TDeque<TDescriptor> TDescriptors; TDescriptors D_; }; } diff --git a/library/cpp/resource/registry.h b/library/cpp/resource/registry.h index fe67702cbc..3e7987be90 100644 --- a/library/cpp/resource/registry.h +++ b/library/cpp/resource/registry.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include "resource.h" @@ -19,7 +19,7 @@ namespace NResource { virtual void Store(const TStringBuf key, const TStringBuf data) = 0; virtual bool FindExact(const TStringBuf key, TString* out) const = 0; virtual void FindMatch(const TStringBuf subkey, IMatch& cb) const = 0; - virtual size_t Count() const noexcept = 0; + virtual size_t Count() const noexcept = 0; virtual TStringBuf KeyByIndex(size_t idx) const = 0; virtual ~IStore() { } diff --git a/library/cpp/resource/resource.cpp b/library/cpp/resource/resource.cpp index cc20f847a5..291b9d1215 100644 --- a/library/cpp/resource/resource.cpp +++ b/library/cpp/resource/resource.cpp @@ -31,7 +31,7 @@ void NResource::FindMatch(const TStringBuf subkey, TResources* out) { } TString NResource::Find(const TStringBuf key) { - TString ret; + TString ret; if (FindExact(key, &ret)) { return ret; @@ -40,7 +40,7 @@ TString NResource::Find(const TStringBuf key) { ythrow yexception() << "can not find resource with path " << key; } -size_t NResource::Count() noexcept { +size_t NResource::Count() noexcept { return CommonStore()->Count(); } @@ -48,8 +48,8 @@ TStringBuf NResource::KeyByIndex(size_t idx) { return CommonStore()->KeyByIndex(idx); } -TVector<TStringBuf> NResource::ListAllKeys() { - TVector<TStringBuf> res(Reserve(NResource::Count())); +TVector<TStringBuf> NResource::ListAllKeys() { + TVector<TStringBuf> res(Reserve(NResource::Count())); for (auto i : xrange(NResource::Count())) { res.push_back(NResource::KeyByIndex(i)); } diff --git a/library/cpp/resource/resource.h b/library/cpp/resource/resource.h index 42dd0f1891..201b319363 100644 --- a/library/cpp/resource/resource.h +++ b/library/cpp/resource/resource.h @@ -1,22 +1,22 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/vector.h> namespace NResource { struct TResource { TStringBuf Key; - TString Data; + TString Data; }; - typedef TVector<TResource> TResources; + typedef TVector<TResource> TResources; TString Find(const TStringBuf key); bool FindExact(const TStringBuf key, TString* out); //perform full scan for now void FindMatch(const TStringBuf subkey, TResources* out); - size_t Count() noexcept; + size_t Count() noexcept; TStringBuf KeyByIndex(size_t idx); - TVector<TStringBuf> ListAllKeys(); + TVector<TStringBuf> ListAllKeys(); } diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h index a11c4dd444..3d6e92e803 100644 --- a/library/cpp/scheme/domscheme_traits.h +++ b/library/cpp/scheme/domscheme_traits.h @@ -7,7 +7,7 @@ struct TSchemeTraits { using TValue = NSc::TValue; using TValueRef = TValue*; using TConstValueRef = const TValue*; - using TStringType = TStringBuf; + using TStringType = TStringBuf; // anyvalue defaults template <class T> @@ -213,8 +213,8 @@ struct TSchemeTraits { } // validation ops - static inline TVector<TString> GetKeys(TConstValueRef v) { - TVector<TString> res; + static inline TVector<TString> GetKeys(TConstValueRef v) { + TVector<TString> res; for (const auto& key : v->DictKeys(true)) { res.push_back(ToString(key)); } diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 3efd116d4f..cade561ed4 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -128,7 +128,7 @@ namespace NSc { return deflt; } - TString TValue::ForceString(const TString& deflt) const { + TString TValue::ForceString(const TString& deflt) const { const TScCore& core = Core(); if (core.IsString()) { return ToString(core.GetString(TStringBuf())); @@ -584,7 +584,7 @@ namespace NSc { LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(double, CompareFloat) LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(TStringBuf, CompareStr) - LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const TString&, CompareStr) + LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const TString&, CompareStr) LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL(const char* const, CompareStr) #undef LIBRARY_SCHEME_DECLARE_TVALUE_OPS_IMPL diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index 3d7c59f3c9..8d32fd88d5 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -176,7 +176,7 @@ namespace NSc { inline TValue& SetString(TStringBuf val = TStringBuf()); // returns self - TString ForceString(const TString& deflt = TString()) const; // Best-effort cast to TString (will do ToString for numeric types) + TString ForceString(const TString& deflt = TString()) const; // Best-effort cast to TString (will do ToString for numeric types) // todo: remove inline bool StringEmpty() const; @@ -301,11 +301,11 @@ namespace NSc { static bool FromJson(TValue&, TStringBuf, const TJsonOpts& = TJsonOpts()); // TODO: Переименовать ToJson в ToJsonUnsafe, а ToJsonSafe в ToJson - TString ToJson(const TJsonOpts& = TJsonOpts()) const; + TString ToJson(const TJsonOpts& = TJsonOpts()) const; const TValue& ToJson(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // returns self // ToJson(JO_SORT_KEYS | JO_SKIP_UNSAFE) - TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; + TString ToJsonSafe(const TJsonOpts& = TJsonOpts()) const; const TValue& ToJsonSafe(IOutputStream&, const TJsonOpts& = TJsonOpts()) const; // ToJson(JO_SORT_KEYS | JO_PRETTY | JO_SKIP_UNSAFE) @@ -354,7 +354,7 @@ namespace NSc { // TODO: add throwing variants // make sure to properly escape the tokens - static TString EscapeForPath(TStringBuf rawKey); // converts a raw dict key into a valid token for a selector path + static TString EscapeForPath(TStringBuf rawKey); // converts a raw dict key into a valid token for a selector path static bool PathValid(TStringBuf path); // returns true if the path is syntactically valid @@ -514,7 +514,7 @@ namespace NSc { // todo: allow insertions // todo: make TDict methods safe class TDict: public THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>, TNonCopyable { - using TParent = THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>; + using TParent = THashMap<TStringBuf, TValue, THash<TStringBuf>, TEqualTo<TStringBuf>, TPoolAllocator>; public: TDict(TMemoryPool* p) diff --git a/library/cpp/scheme/scheme_cast.h b/library/cpp/scheme/scheme_cast.h index 00839e8017..4ab215a0be 100644 --- a/library/cpp/scheme/scheme_cast.h +++ b/library/cpp/scheme/scheme_cast.h @@ -31,35 +31,35 @@ namespace NJsonConverters { // fwd declarations ////////////////////////////////////////////////////////////////////// - //TVector + //TVector template <typename T, typename A> - NSc::TValue ToTValue(const TVector<T, A>& x); + NSc::TValue ToTValue(const TVector<T, A>& x); template <typename T, typename A> - void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate); - //THashMap + //THashMap template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x); + NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x); template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate); + void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate); - //TMap + //TMap template <class K, class V, class Less, class A> - NSc::TValue ToTValue(const TMap<K, V, Less, A>& x); + NSc::TValue ToTValue(const TMap<K, V, Less, A>& x); template <class K, class V, class Less, class A> - void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate); - //THashSet + //THashSet template <class V, class H, class E, class A> - NSc::TValue ToTValue(const THashSet<V, H, E, A>& x); + NSc::TValue ToTValue(const THashSet<V, H, E, A>& x); template <class V, class H, class E, class A> - void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate); - //TSet + //TSet template <class K, class L, class A> - NSc::TValue ToTValue(const TSet<K, L, A>& x); + NSc::TValue ToTValue(const TSet<K, L, A>& x); template <class K, class L, class A> - void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate); + void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate); //std::pair template <class T1, class T2> @@ -83,7 +83,7 @@ namespace NJsonConverters { out = x; } - static TString ToString(const T& x) { + static TString ToString(const T& x) { return ::ToString(x); } @@ -102,7 +102,7 @@ namespace NJsonConverters { out.FromTValue(x, validate); } - static TString ToString(const T& x) { + static TString ToString(const T& x) { return x.ToJson(); } @@ -129,7 +129,7 @@ namespace NJsonConverters { } template <typename T> - TString ToString(const T& x) { + TString ToString(const T& x) { return TValueAndStrokaConv<T, std::is_base_of<IJsonSerializable, T>::value>::ToString(x); } @@ -204,16 +204,16 @@ namespace NJsonConverters { // TVector ////////////////////////////////////////////////////////////////////// template <typename T, typename A> - NSc::TValue ToTValue(const TVector<T, A>& x) { + NSc::TValue ToTValue(const TVector<T, A>& x) { NSc::TValue out; out.SetArray(); - for (typename TVector<T, A>::const_iterator it = x.begin(); it != x.end(); ++it) + for (typename TVector<T, A>::const_iterator it = x.begin(); it != x.end(); ++it) out.Push(NJsonConverters::ToTValue(*it)); return out; } template <typename T, typename A> - void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TVector<T, A>& out, const bool validate) { if (validate) Y_ENSURE(x.IsArray() || x.IsNull(), "not valid input scheme"); out.clear(); @@ -232,22 +232,22 @@ namespace NJsonConverters { // THashMap & TMap ////////////////////////////////////////////////////////////////////// template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x) { + NSc::TValue ToTValue(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& x) { return NPrivate::ToTValueDict(x); } template <class Key, class T, class HashFcn, class EqualKey, class Alloc> - void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, THashMap<Key, T, HashFcn, EqualKey, Alloc>& out, const bool validate) { NPrivate::FromTValueDict(x, out, validate); } template <class K, class V, class Less, class A> - NSc::TValue ToTValue(const TMap<K, V, Less, A>& x) { + NSc::TValue ToTValue(const TMap<K, V, Less, A>& x) { return NPrivate::ToTValueDict(x); } template <class K, class V, class Less, class A> - void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TMap<K, V, Less, A>& out, const bool validate) { NPrivate::FromTValueDict(x, out, validate); } @@ -255,22 +255,22 @@ namespace NJsonConverters { // THashSet & TSet ////////////////////////////////////////////////////////////////////// template <class V, class H, class E, class A> - NSc::TValue ToTValue(const THashSet<V, H, E, A>& x) { + NSc::TValue ToTValue(const THashSet<V, H, E, A>& x) { return NPrivate::ToTValueSet(x); } template <class V, class H, class E, class A> - void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, THashSet<V, H, E, A>& out, const bool validate) { NPrivate::FromTValueSet(x, out, validate); } template <class K, class L, class A> - NSc::TValue ToTValue(const TSet<K, L, A>& x) { + NSc::TValue ToTValue(const TSet<K, L, A>& x) { return NPrivate::ToTValueSet(x); } template <class K, class L, class A> - void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate) { + void FromTValue(const NSc::TValue& x, TSet<K, L, A>& out, const bool validate) { NPrivate::FromTValueSet(x, out, validate); } @@ -307,7 +307,7 @@ namespace NJsonConverters { // global user functions ////////////////////////////////////////////////////////////////////// template <typename T> - TString ToJson(const T& val, const bool sort = false) { + TString ToJson(const T& val, const bool sort = false) { return NJsonConverters::ToTValue(val).ToJson(sort); } diff --git a/library/cpp/scheme/scimpl.h b/library/cpp/scheme/scimpl.h index 4f68f16290..984f4076e5 100644 --- a/library/cpp/scheme/scimpl.h +++ b/library/cpp/scheme/scimpl.h @@ -849,7 +849,7 @@ namespace NSc { LIBRARY_SCHEME_DECLARE_TVALUE_OPS(double, CompareFloat) LIBRARY_SCHEME_DECLARE_TVALUE_OPS(TStringBuf, CompareStr) - LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const TString&, CompareStr) + LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const TString&, CompareStr) LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const char* const, CompareStr) #undef LIBRARY_SCHEME_DECLARE_TVALUE_OPS diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h index f3dd66b437..638488c6b6 100644 --- a/library/cpp/scheme/scimpl_defs.h +++ b/library/cpp/scheme/scimpl_defs.h @@ -10,7 +10,7 @@ #include <util/generic/hash.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <functional> #include <util/string/vector.h> @@ -43,7 +43,7 @@ namespace NSc { }; } - using TStringBufs = TVector<TStringBuf>; + using TStringBufs = TVector<TStringBuf>; class TSchemeException : public yexception { }; @@ -51,12 +51,12 @@ namespace NSc { class TSchemeParseException : public TSchemeException { public: size_t Offset = 0; - TString Reason; + TString Reason; public: TSchemeParseException() = default; - TSchemeParseException(size_t off, const TString& reason) + TSchemeParseException(size_t off, const TString& reason) : Offset(off) , Reason(reason) { diff --git a/library/cpp/scheme/scimpl_json_read.cpp b/library/cpp/scheme/scimpl_json_read.cpp index 8a29cc7739..12b7625200 100644 --- a/library/cpp/scheme/scimpl_json_read.cpp +++ b/library/cpp/scheme/scimpl_json_read.cpp @@ -7,7 +7,7 @@ namespace NSc { struct TJsonError { size_t Offset = 0; - TMaybe<TString> Reason; + TMaybe<TString> Reason; }; struct TJsonDeserializer : NJson::TJsonCallbacks { @@ -57,14 +57,14 @@ namespace NSc { } }; - typedef TVector<TContainer> TStackType; + typedef TVector<TContainer> TStackType; public: TValue& Root; TJsonError& Error; const TJsonOpts& Cfg; - TStackType Stack; + TStackType Stack; bool Virgin = true; public: @@ -213,7 +213,7 @@ namespace NSc { return res; } - TString reason = err.Reason.Empty() ? "NULL" : *err.Reason; + TString reason = err.Reason.Empty() ? "NULL" : *err.Reason; ythrow TSchemeParseException(err.Offset, reason) << "JSON error at offset " << err.Offset << " (" << reason << ")"; } diff --git a/library/cpp/scheme/scimpl_json_write.cpp b/library/cpp/scheme/scimpl_json_write.cpp index aadd7e6cd5..60026e8d09 100644 --- a/library/cpp/scheme/scimpl_json_write.cpp +++ b/library/cpp/scheme/scimpl_json_write.cpp @@ -154,8 +154,8 @@ namespace NSc { return *this; } - TString TValue::ToJson(const TJsonOpts& jopts) const { - TString s; + TString TValue::ToJson(const TJsonOpts& jopts) const { + TString s; { TStringOutput out(s); ToJson(out, jopts); @@ -175,7 +175,7 @@ namespace NSc { return MakeOptsSafeForSerializer(opts); } - TString TValue::ToJsonSafe(const TJsonOpts& jopts) const { + TString TValue::ToJsonSafe(const TJsonOpts& jopts) const { return ToJson(MakeOptsSafeForSerializer(jopts)); } diff --git a/library/cpp/scheme/scimpl_private.cpp b/library/cpp/scheme/scimpl_private.cpp index 024bf8cc3b..51323d3e3c 100644 --- a/library/cpp/scheme/scimpl_private.cpp +++ b/library/cpp/scheme/scimpl_private.cpp @@ -22,7 +22,7 @@ namespace NSc { }; template <typename TAction, typename TElement, typename TColl> - static inline void PutToVector(TVector<TElement>& vector, TColl& coll) { + static inline void PutToVector(TVector<TElement>& vector, TColl& coll) { size_t i = vector.size(); vector.resize(vector.size() + coll.size()); @@ -61,7 +61,7 @@ namespace NSc { Y_FAIL("REFERENCE LOOP DETECTED"); break; case EMode::Stderr: - Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ") + Cerr << "REFERENCE LOOP DETECTED: " << JoinStrings(Vector.begin(), Vector.end(), ", ") << " AND " << ToString((const void*)&self) << Endl; break; } diff --git a/library/cpp/scheme/scimpl_private.h b/library/cpp/scheme/scimpl_private.h index b92badabde..aadc56a58c 100644 --- a/library/cpp/scheme/scimpl_private.h +++ b/library/cpp/scheme/scimpl_private.h @@ -15,7 +15,7 @@ namespace NSc { class TContextGuard : TNonCopyable { using TElement = typename TContext::TElement; using TTarget = typename TContext::TTarget; - using TVectorType = TVector<TElement>; + using TVectorType = TVector<TElement>; public: TContextGuard(TContext& ctx, TTarget& target) @@ -35,7 +35,7 @@ namespace NSc { } } - const TVectorType& GetVector() const { + const TVectorType& GetVector() const { return Ctx.Vector; } @@ -68,7 +68,7 @@ namespace NSc { Vector.reserve(64); } - TVector<TElement> Vector; + TVector<TElement> Vector; }; class TKeySortContext: public TBasicContext<TStringBuf, const TDict> { diff --git a/library/cpp/scheme/scimpl_protobuf.cpp b/library/cpp/scheme/scimpl_protobuf.cpp index 0c99122c69..f640118a5a 100644 --- a/library/cpp/scheme/scimpl_protobuf.cpp +++ b/library/cpp/scheme/scimpl_protobuf.cpp @@ -13,12 +13,12 @@ namespace NSc { TValue TValue::From(const Message& msg, bool mapAsDict) { TValue v; const Reflection* r = msg.GetReflection(); - TVector<const FieldDescriptor*> fields; - TVector<const FieldDescriptor*>::iterator it; - int i1; + TVector<const FieldDescriptor*> fields; + TVector<const FieldDescriptor*>::iterator it; + int i1; r->ListFields(msg, &fields); - for (it = fields.begin(), i1 = 0; it != fields.end(); ++it, ++i1) { + for (it = fields.begin(), i1 = 0; it != fields.end(); ++it, ++i1) { const FieldDescriptor* field = *it; try { if (field->is_repeated()) { @@ -154,7 +154,7 @@ namespace NSc { } void TValue::ValueToField(const TValue& value, Message& msg, const FieldDescriptor* field, const TProtoOpts& opts) const { - const TString& name = field->name(); + const TString& name = field->name(); if (value.IsNull()) { if (field->is_required() && !field->has_default_value()) { ythrow TSchemeException() << "has no value for required field " << name; @@ -233,7 +233,7 @@ namespace NSc { } void TValue::ToRepeatedField(Message& msg, const FieldDescriptor* field, const TProtoOpts& opts) const { - const TString& name = field->name(); + const TString& name = field->name(); const TValue& fieldValue = Get(name); if (fieldValue.IsNull()) { diff --git a/library/cpp/scheme/scimpl_select.rl6 b/library/cpp/scheme/scimpl_select.rl6 index 11aa549b78..a7dbbfdf81 100644 --- a/library/cpp/scheme/scimpl_select.rl6 +++ b/library/cpp/scheme/scimpl_select.rl6 @@ -54,7 +54,7 @@ namespace NSc { template <typename TSelector> struct TSelectorCtx { TSelector Selector; - TString Buffer; + TString Buffer; const char* p0 = nullptr; const char* p = nullptr; @@ -252,7 +252,7 @@ namespace NSc { return ctx.SelectPath() || !ctx.Selector.HasError; } - TString TValue::EscapeForPath(TStringBuf rawKey) { + TString TValue::EscapeForPath(TStringBuf rawKey) { static const str_spn danger{"/[]"}; if (!rawKey || danger.brk(rawKey.begin(), rawKey.end()) != rawKey.end()) { return NEscJ::EscapeJ<true>(rawKey); diff --git a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp index 4f907157e9..7f9101eff4 100644 --- a/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_cast_ut.cpp @@ -9,11 +9,11 @@ using namespace NJsonConverters; -using TVI = TVector<int>; -using THI = THashMap<int, int>; -using TMI = TMap<int, int>; -using THSI = THashSet<int>; -using TSI = TSet<int>; +using TVI = TVector<int>; +using THI = THashMap<int, int>; +using TMI = TMap<int, int>; +using THSI = THashSet<int>; +using TSI = TSet<int>; using TPI = std::pair<int, int>; Y_UNIT_TEST_SUITE(TSchemeCastTest) { @@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h[i] = i * i; - const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; + const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); THI h2(FromJson<THI>(ToJson(h))); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h[i] = i * i; - const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; + const TString etalon = "{\"0\":0,\"1\":1,\"2\":4}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); TMI h2(FromJson<TMI>(ToJson(h))); @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h.insert(i * i); - const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; + const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); THSI h2(FromJson<THSI>(ToJson(h))); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { for (int i = 0; i < 3; ++i) h.insert(i * i); - const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; + const TString etalon = "{\"0\":null,\"1\":null,\"4\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(h, true)); TSI h2(FromJson<TSI>(ToJson(h))); @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestTPair) { TPI p(1, 1); - const TString etalon = "[1,1]"; + const TString etalon = "[1,1]"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(p, true)); TPI p2(FromJson<TPI>(ToJson(p))); @@ -116,7 +116,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestTCustom) { TCustom x(2, 3); - const TString etalon = "{\"a\":2,\"b\":3}"; + const TString etalon = "{\"a\":2,\"b\":3}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(x, true)); TCustom x2(FromJson<TCustom>(ToJson(x))); @@ -124,13 +124,13 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } Y_UNIT_TEST(TestVectorOfPairs) { - typedef TVector<TPI> TVPI; + typedef TVector<TPI> TVPI; TVPI v; for (int i = 0; i < 3; ++i) v.push_back(TPI(i, i * i)); - const TString etalon = "[[0,0],[1,1],[2,4]]"; + const TString etalon = "[[0,0],[1,1],[2,4]]"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(v, true)); TVPI v2(FromJson<TVPI>(ToJson(v))); @@ -138,11 +138,11 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { } Y_UNIT_TEST(TestSetOfCustom) { - typedef TSet<TCustom> TSC; + typedef TSet<TCustom> TSC; TSC s; s.insert(TCustom(2, 3)); - const TString etalon = "{\"{\\\"a\\\":2,\\\"b\\\":3}\":null}"; + const TString etalon = "{\"{\\\"a\\\":2,\\\"b\\\":3}\":null}"; UNIT_ASSERT_VALUES_EQUAL(etalon, ToJson(s, true)); TSC s2(FromJson<TSC>(ToJson(s))); @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TSchemeCastTest) { Y_UNIT_TEST(TestExceptions) { NSc::TValue v = 1; - const TString json = v.ToJson(); + const TString json = v.ToJson(); UNIT_ASSERT_EXCEPTION(FromJson<TVI>(json, true), yexception); UNIT_ASSERT_EXCEPTION(FromJson<THI>(json, true), yexception); UNIT_ASSERT_EXCEPTION(FromJson<TMI>(json, true), yexception); diff --git a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp index daeb2654f9..7b248299d6 100644 --- a/library/cpp/scheme/tests/ut/scheme_json_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_json_ut.cpp @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) { } Y_UNIT_TEST(TestSafeJson) { - TString ss; + TString ss; ss.reserve(256); for (int i = 0; i < 256; ++i) { @@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TSchemeJsonTest) { { NSc::TValue value; - TString articleName{"\xC2\xC2\xCF"}; + TString articleName{"\xC2\xC2\xCF"}; value["text"] = articleName; UNIT_ASSERT_VALUES_EQUAL(value.ToJson(), "{\"text\":\"\xC2\xC2\xCF\"}"); UNIT_ASSERT_VALUES_EQUAL(value.ToJsonSafe(), "{\"text\":null}"); diff --git a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp index 0d4d79d483..7b95f02d13 100644 --- a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp @@ -98,61 +98,61 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) { { NSc::TValue val; *val.TrySelectOrAdd("") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd("a") = 100; - const TString res = R"=({"a":100})="; + const TString res = R"=({"a":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(////)=") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=()=") = 100; - const TString res = R"=(100)="; + const TString res = R"=(100)="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("")=") = 100; - const TString res = R"=({"":100})="; + const TString res = R"=({"":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("[1]")=") = 100; - const TString res = R"=({"[1]":100})="; + const TString res = R"=({"[1]":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("\"\"")=") = 100; - const TString res = R"=({"\"\"":100})="; + const TString res = R"=({"\"\"":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=("/10/")=") = 100; - const TString res = R"=({"/10/":100})="; + const TString res = R"=({"/10/":100})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100; - const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; + const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } { NSc::TValue val; *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100; - const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; + const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})="; UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res); } } diff --git a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp index e711a0d092..db8d13b978 100644 --- a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TSchemeProtoTest) { NSc::TMessage proto; v.To(proto); - TString differentPath; + TString differentPath; UNIT_ASSERT_C(NProtoBuf::IsEqual(m, proto, &differentPath), differentPath); } } diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp index 1a5d07c31b..290ebd6c04 100644 --- a/library/cpp/scheme/tests/ut/scheme_ut.cpp +++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp @@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { Y_UNIT_TEST(TestAssignments) { for (int i = -2; i < 3; ++i) { - TString ii = ToString(i); + TString ii = ToString(i); int iless = i - 1; int imore = i + 1; DoCheckAssignmentNum<signed char>(i, iless, imore, ii, "schar"); @@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { // DoCheckAssignment<bool>(false, false, false, "false", "bool"); for (int i = 1; i < 3; ++i) { - TString ii = ToString(i); + TString ii = ToString(i); int iless = i - 1; int imore = i + 1; @@ -292,9 +292,9 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { DoCheckAssignmentNum<double>(i, iless, imore, ii, "double"); } - TString uuu = "uuu"; - TString uua = "uua"; - TString uuz = "uuz"; + TString uuu = "uuu"; + TString uua = "uua"; + TString uuz = "uuz"; DoCheckAssignment<char*>(uuu.begin(), uua.begin(), uuz.begin(), "\"uuu\"", "char*"); DoCheckAssignment<const char*>("www", "wwa", "wwz", "\"www\"", "const char*"); DoCheckAssignmentArr("xxx", "xxa", "xxz", "\"xxx\"", "const char[]"); @@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { #if defined(_MSC_VER) //TODO #else - DoCheckAssignment<TString>("ttt", "tta", "ttz", "\"ttt\"", "TString"); + DoCheckAssignment<TString>("ttt", "tta", "ttz", "\"ttt\"", "TString"); #endif NSc::TValue v; @@ -358,12 +358,12 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { v.AppendAll(d); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3,4,5,6])"); UNIT_ASSERT_VALUES_EQUAL(d.size(), 3u); - TVector<TStringBuf> s{"x", "y", "z"}; + TVector<TStringBuf> s{"x", "y", "z"}; v.AppendAll(s.begin(), s.end()); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"(["a","b","c","d",1,2,3,4,5,6,"x","y","z"])"); UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(s).ToJson(), R"(["x","y","z"])"); - UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(TVector<TStringBuf>()).ToJson(), R"([])"); + UNIT_ASSERT_VALUES_EQUAL(v.Clone().Clear().AppendAll(TVector<TStringBuf>()).ToJson(), R"([])"); v.AddAll({{"a", "b"}, {"c", "d"}}); UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), R"({"a":"b","c":"d"})"); @@ -421,10 +421,10 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("[ x, y]"); NSc::TValue vs = NSc::TValue::FromJson("foo"); NSc::TValue vn = NSc::TValue::FromJson("1"); - TString sd = "{\"a\":1,\"b\":\"c\"}"; - TString sa = "[\"x\",\"y\"]"; - TString ss = "\"foo\""; - TString sn = "1"; + TString sd = "{\"a\":1,\"b\":\"c\"}"; + TString sa = "[\"x\",\"y\"]"; + TString ss = "\"foo\""; + TString sn = "1"; UNIT_ASSERT_VALUES_EQUAL(sd, vd.ToJson(true)); UNIT_ASSERT_VALUES_EQUAL(sa, va.ToJson(true)); UNIT_ASSERT_VALUES_EQUAL(ss, vs.ToJson(true)); @@ -781,7 +781,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { Y_UNIT_TEST(TestCopyFrom) { { - TString sa = "[1,2]"; + TString sa = "[1,2]"; const NSc::TValue& va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; vb.CopyFrom(va); @@ -789,7 +789,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; vb.CopyFrom(va); @@ -797,7 +797,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); const NSc::TValue& vb = va; va.CopyFrom(vb); @@ -805,7 +805,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } { - TString sa = "[1,2]"; + TString sa = "[1,2]"; NSc::TValue va = NSc::TValue::FromJson(sa); NSc::TValue vb = va; va.CopyFrom(vb); @@ -816,7 +816,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); NSc::TValue vb = va.Get("y"); va.CopyFrom(vb); - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } @@ -824,14 +824,14 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); const NSc::TValue& vb = va.Get("y"); va.CopyFrom(vb); - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); } { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); NSc::TValue vb = va.Get("y"); va = vb; - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } @@ -839,7 +839,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) { NSc::TValue va = NSc::TValue::FromJson("{\"x\":\"ab\",\"y\":{\"p\":\"cd\",\"q\":\"ef\"}}"); const NSc::TValue& vb = va.Get("y"); va = vb; - TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; + TString sa = "{\"p\":\"cd\",\"q\":\"ef\"}"; UNIT_ASSERT_VALUES_EQUAL(va.ToJson(), sa); UNIT_ASSERT_VALUES_EQUAL(vb.ToJson(), sa); } diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.h b/library/cpp/scheme/ut_utils/scheme_ut_utils.h index eb3ea15b2a..a22583432b 100644 --- a/library/cpp/scheme/ut_utils/scheme_ut_utils.h +++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.h @@ -11,16 +11,16 @@ namespace NSc { namespace NUt { TValue AssertFromJson(TStringBuf json); - inline TString NormalizeJson(const NSc::TValue& sc) { + inline TString NormalizeJson(const NSc::TValue& sc) { return sc.ToJson(true); } - inline TString NormalizeJson(const NJson::TJsonValue& sc) { + inline TString NormalizeJson(const NJson::TJsonValue& sc) { return NJson::WriteJson(sc, false, true, false); } template <class TStr> - inline TString NormalizeJson(const TStr& val) { + inline TString NormalizeJson(const TStr& val) { return AssertFromJson(val).ToJson(true); } @@ -38,12 +38,12 @@ namespace NSc { #define UNIT_ASSERT_JSON_EQ_JSON(A, B) UNIT_ASSERT_JSON_EQ_JSON_C(A, B, "") - inline TString DumpJson(const TValue& json) { + inline TString DumpJson(const TValue& json) { return NJson::CompactifyJson(json.ToJson(true), true, true); } // deprecated - inline TString DumpJsonVS(const TValue& expected, const TValue& fact) { + inline TString DumpJsonVS(const TValue& expected, const TValue& fact) { return DumpJson(expected) + "(expected) != (fact)" + DumpJson(fact); } diff --git a/library/cpp/sliding_window/sliding_window_ut.cpp b/library/cpp/sliding_window/sliding_window_ut.cpp index 1e7343a8d3..bcba7d71de 100644 --- a/library/cpp/sliding_window/sliding_window_ut.cpp +++ b/library/cpp/sliding_window/sliding_window_ut.cpp @@ -7,7 +7,7 @@ using namespace NSlidingWindow; Y_UNIT_TEST_SUITE(TSlidingWindowTest) { Y_UNIT_TEST(TestSlidingWindowMax) { TSlidingWindow<TMaxOperation<unsigned>> w(TDuration::Minutes(5), 5); - TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); + TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; w.Update(5, start); // ~ ~ ~ ~ 5 UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 5); // ^ @@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { Y_UNIT_TEST(TestSlidingWindowMin) { TSlidingWindow<TMinOperation<unsigned>> w(TDuration::Minutes(5), 5); - TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); + TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; w.Update(5, start); // ~ ~ ~ ~ 5 UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 5); // ^ @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TSlidingWindowTest) { TSlidingWindow<TSumOperation<unsigned>> w(TDuration::Minutes(5), 5); UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 0); // current sum - TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); + TInstant start = TInstant::MicroSeconds(TDuration::Hours(1).MicroSeconds()); TInstant now = start; w.Update(5, start); // 0 0 0 0 5 UNIT_ASSERT_VALUES_EQUAL(w.GetValue(), 5); // ^ diff --git a/library/cpp/sse/ut/test.cpp b/library/cpp/sse/ut/test.cpp index 33c999d284..1aef06fa7a 100644 --- a/library/cpp/sse/ut/test.cpp +++ b/library/cpp/sse/ut/test.cpp @@ -71,29 +71,29 @@ using uint64x2_t = std::array<ui64, 2>; using float32x4_t = std::array<float, 4>; using float64x2_t = std::array<double, 2>; -template <typename TVectorType> +template <typename TVectorType> struct TQType { - static TVectorType As(__m128i param) { - TVectorType value; + static TVectorType As(__m128i param) { + TVectorType value; _mm_storeu_si128((__m128i*)&value, param); return value; } - static TVectorType As(__m128 param) { - TVectorType value; + static TVectorType As(__m128 param) { + TVectorType value; _mm_storeu_ps((float*)&value, param); return value; } - static TVectorType As(__m128d param) { - TVectorType value; + static TVectorType As(__m128d param) { + TVectorType value; _mm_storeu_pd((double*)&value, param); return value; } }; #endif -template <typename TVectorType> +template <typename TVectorType> struct TFuncLoad; -template <typename TVectorType> +template <typename TVectorType> struct TFuncStore; template <> @@ -394,12 +394,12 @@ public: template <typename TElem, unsigned elemCount, typename TFunc, typename TElemFunc, - typename TOp, typename TVectorType = __m128i> + typename TOp, typename TVectorType = __m128i> void Test_mm_dualop(); template <typename TElem, unsigned elemCount, typename TFunc, typename TElemFunc, - typename TOp, typename TVectorType = __m128i> + typename TOp, typename TVectorType = __m128i> void Test_mm_dualcmp(); void Test_mm_or_si128(); @@ -421,7 +421,7 @@ public: void Test_mm_cmplt_epi32(); template <typename TElem, int elemCount, - typename TFunc, typename TOp, typename TVectorType> + typename TFunc, typename TOp, typename TVectorType> void Test_mm_setter_epiXX(); void Test_mm_set1_epi8(); void Test_mm_set1_epi16(); @@ -1068,7 +1068,7 @@ void TSSEEmulTest::Test_mm_unpackhi_epi64() { template <typename TElem, unsigned elemCount, typename TFunc, typename TElemFunc, - typename TOp, typename TVectorType> + typename TOp, typename TVectorType> void TSSEEmulTest::Test_mm_dualop() { char data1[16] = { '\xAA', '\x00', '\xFF', '\xCC', '\x11', '\x22', '\xBB', '\xAA', @@ -1079,14 +1079,14 @@ void TSSEEmulTest::Test_mm_dualop() { TElem* dataw1 = reinterpret_cast<TElem*>(&data1); TElem* dataw2 = reinterpret_cast<TElem*>(&data2); - TVectorType value1 = TFuncLoad<TVectorType>(&data1); - TVectorType value2 = TFuncLoad<TVectorType>(&data2); + TVectorType value1 = TFuncLoad<TVectorType>(&data1); + TVectorType value2 = TFuncLoad<TVectorType>(&data2); TElem procData[elemCount]; for (unsigned i = 0; i < elemCount; ++i) { procData[i] = TElemFunc::Call(dataw1[i], dataw2[i]); } - TVectorType result = TFunc(value1, value2); + TVectorType result = TFunc(value1, value2); for (unsigned i = 0; i < elemCount; ++i) { UNIT_ASSERT_EQUAL(procData[i], TQType<TOp>::As(result)[i]); @@ -1097,7 +1097,7 @@ void TSSEEmulTest::Test_mm_dualop() { but different data1 and data2 */ template <typename TElem, unsigned elemCount, typename TFunc, typename TElemFunc, - typename TOp, typename TVectorType> + typename TOp, typename TVectorType> void TSSEEmulTest::Test_mm_dualcmp() { char data1[16] = { '\xAA', '\x00', '\xFF', '\xCC', '\x11', '\x66', '\x77', '\xAA', @@ -1108,14 +1108,14 @@ void TSSEEmulTest::Test_mm_dualcmp() { TElem* dataw1 = reinterpret_cast<TElem*>(&data1); TElem* dataw2 = reinterpret_cast<TElem*>(&data2); - TVectorType value1 = TFuncLoad<TVectorType>(&data1); - TVectorType value2 = TFuncLoad<TVectorType>(&data2); + TVectorType value1 = TFuncLoad<TVectorType>(&data1); + TVectorType value2 = TFuncLoad<TVectorType>(&data2); TElem procData[elemCount]; for (unsigned i = 0; i < elemCount; ++i) { procData[i] = TElemFunc::Call(dataw1[i], dataw2[i]); } - TVectorType result = TFunc(value1, value2); + TVectorType result = TFunc(value1, value2); for (unsigned i = 0; i < elemCount; ++i) { /* memcmp is for compare to invalid floats in results */ @@ -1255,7 +1255,7 @@ void TSSEEmulTest::Test_mm_cmplt_epi32() { } template <typename TElem, int elemCount, - typename TFunc, typename TOp, typename TVectorType> + typename TFunc, typename TOp, typename TVectorType> void TSSEEmulTest::Test_mm_setter_epiXX() { char data[64] = { '\xAA', '\x00', '\xFF', '\xCC', '\x11', '\x22', '\xBB', '\xAA', @@ -1269,7 +1269,7 @@ void TSSEEmulTest::Test_mm_setter_epiXX() { TElem* dataw = reinterpret_cast<TElem*>(&data); for (unsigned dataItem = 0; dataItem < elemCount * 4; ++dataItem) { - TVectorType value = TFunc(dataw[dataItem]); + TVectorType value = TFunc(dataw[dataItem]); for (unsigned i = 0; i < elemCount; ++i) UNIT_ASSERT_EQUAL(dataw[dataItem], TQType<TOp>::As(value)[i]); diff --git a/library/cpp/streams/bzip2/bzip2.cpp b/library/cpp/streams/bzip2/bzip2.cpp index bccc5c6807..9121244e83 100644 --- a/library/cpp/streams/bzip2/bzip2.cpp +++ b/library/cpp/streams/bzip2/bzip2.cpp @@ -14,7 +14,7 @@ public: Init(); } - inline ~TImpl() { + inline ~TImpl() { Clear(); } @@ -24,7 +24,7 @@ public: } } - inline void Clear() noexcept { + inline void Clear() noexcept { BZ2_bzDecompressEnd(&BzStream_); } @@ -79,7 +79,7 @@ TBZipDecompress::TBZipDecompress(IInputStream* input, size_t bufLen) { } -TBZipDecompress::~TBZipDecompress() { +TBZipDecompress::~TBZipDecompress() { } size_t TBZipDecompress::DoRead(void* buf, size_t size) { @@ -101,7 +101,7 @@ public: BzStream_.avail_out = TmpBufLen(); } - inline ~TImpl() { + inline ~TImpl() { BZ2_bzCompressEnd(&BzStream_); } @@ -156,11 +156,11 @@ public: } private: - inline char* TmpBuf() noexcept { + inline char* TmpBuf() noexcept { return (char*)AdditionalData(); } - inline size_t TmpBufLen() const noexcept { + inline size_t TmpBufLen() const noexcept { return AdditionalDataLength(); } @@ -174,7 +174,7 @@ TBZipCompress::TBZipCompress(IOutputStream* out, size_t compressionLevel, size_t { } -TBZipCompress::~TBZipCompress() { +TBZipCompress::~TBZipCompress() { try { Finish(); } catch (...) { diff --git a/library/cpp/streams/bzip2/bzip2.h b/library/cpp/streams/bzip2/bzip2.h index 2322277ef6..07c8837997 100644 --- a/library/cpp/streams/bzip2/bzip2.h +++ b/library/cpp/streams/bzip2/bzip2.h @@ -25,7 +25,7 @@ class TBZipCompressError: public TBZipException { class TBZipDecompress: public IInputStream { public: TBZipDecompress(IInputStream* input, size_t bufLen = BZIP_BUF_LEN); - ~TBZipDecompress() override; + ~TBZipDecompress() override; private: size_t DoRead(void* buf, size_t size) override; @@ -38,7 +38,7 @@ private: class TBZipCompress: public IOutputStream { public: TBZipCompress(IOutputStream* out, size_t compressionLevel = BZIP_COMPRESSION_LEVEL, size_t bufLen = BZIP_BUF_LEN); - ~TBZipCompress() override; + ~TBZipCompress() override; private: void DoWrite(const void* buf, size_t size) override; diff --git a/library/cpp/streams/bzip2/bzip2_ut.cpp b/library/cpp/streams/bzip2/bzip2_ut.cpp index 69a98f296c..4de72e8ad5 100644 --- a/library/cpp/streams/bzip2/bzip2_ut.cpp +++ b/library/cpp/streams/bzip2/bzip2_ut.cpp @@ -8,10 +8,10 @@ #define ZDATA "./zdata" Y_UNIT_TEST_SUITE(TBZipTest) { - static const TString data = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; + static const TString data = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s"; Y_UNIT_TEST(TestCompress) { - TUnbufferedFileOutput o(ZDATA); + TUnbufferedFileOutput o(ZDATA); TBZipCompress c(&o); c.Write(data.data(), data.size()); @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TBZipTest) { TTempFile tmp(ZDATA); { - TUnbufferedFileInput i(ZDATA); + TUnbufferedFileInput i(ZDATA); TBZipDecompress d(&i); UNIT_ASSERT_EQUAL(d.ReadLine(), data); diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp index b65bb3ed96..0ddeb2a6c2 100644 --- a/library/cpp/streams/lz/lz.cpp +++ b/library/cpp/streams/lz/lz.cpp @@ -15,11 +15,11 @@ #include <contrib/libs/quicklz/quicklz.h> #include <contrib/libs/minilzo/minilzo.h> -static inline ui8 HostToLittle(ui8 t) noexcept { +static inline ui8 HostToLittle(ui8 t) noexcept { return t; } -static inline ui8 LittleToHost(ui8 t) noexcept { +static inline ui8 LittleToHost(ui8 t) noexcept { return t; } @@ -53,7 +53,7 @@ public: this->Save(BlockSize()); } - inline ~TCompressorBase() { + inline ~TCompressorBase() { } inline void Write(const char* buf, size_t len) { @@ -88,11 +88,11 @@ public: } private: - inline void* Block() const noexcept { + inline void* Block() const noexcept { return this->AdditionalData(); } - inline ui16 BlockSize() const noexcept { + inline ui16 BlockSize() const noexcept { return BlockSize_; } @@ -200,7 +200,7 @@ public: this->InitFromStream(Slave_); } - inline ~TDecompressorBaseImpl() { + inline ~TDecompressorBaseImpl() { } inline size_t Read(void* buf, size_t len) { @@ -284,7 +284,7 @@ public: { } - inline ~TDecompressorBase() { + inline ~TDecompressorBase() { } }; @@ -373,16 +373,16 @@ public: Singleton<TInit>(); } - inline ~TMiniLzo() { + inline ~TMiniLzo() { } - static inline size_t Hint(size_t len) noexcept { + static inline size_t Hint(size_t len) noexcept { // see SEARCH-2043 and, e.g. examples at // http://stackoverflow.com/questions/4235019/how-to-get-lzo-to-work-with-a-file-stream return len + (len / 16) + 64 + 3; } - static inline bool SaveIncompressibleChunks() noexcept { + static inline bool SaveIncompressibleChunks() noexcept { return false; } }; @@ -392,7 +392,7 @@ const char TMiniLzo::signature[] = "YLZO"; template <size_t N> class TFixedArray { public: - inline TFixedArray() noexcept { + inline TFixedArray() noexcept { memset(WorkMem_, 0, sizeof(WorkMem_)); } @@ -434,7 +434,7 @@ class TFastLZ { public: static const char signature[]; - static inline size_t Hint(size_t len) noexcept { + static inline size_t Hint(size_t len) noexcept { return Max<size_t>((size_t)(len * 1.06), 100); } @@ -449,7 +449,7 @@ public: inline void InitFromStream(IInputStream*) const noexcept { } - static inline bool SaveIncompressibleChunks() noexcept { + static inline bool SaveIncompressibleChunks() noexcept { return false; } }; @@ -466,7 +466,7 @@ class TLZ4 { public: static const char signature[]; - static inline size_t Hint(size_t len) noexcept { + static inline size_t Hint(size_t len) noexcept { return Max<size_t>((size_t)(len * 1.06), 100); } @@ -484,7 +484,7 @@ public: inline void InitFromStream(IInputStream*) const noexcept { } - static inline bool SaveIncompressibleChunks() noexcept { + static inline bool SaveIncompressibleChunks() noexcept { return false; } }; @@ -501,7 +501,7 @@ class TSnappy { public: static const char signature[]; - static inline size_t Hint(size_t len) noexcept { + static inline size_t Hint(size_t len) noexcept { return Max<size_t>(snappy::MaxCompressedLength(len), 100); } @@ -521,7 +521,7 @@ public: inline void InitFromStream(IInputStream*) const noexcept { } - static inline bool SaveIncompressibleChunks() noexcept { + static inline bool SaveIncompressibleChunks() noexcept { return false; } }; @@ -538,7 +538,7 @@ class TQuickLZBase { public: static const char signature[]; - static inline size_t Hint(size_t len) noexcept { + static inline size_t Hint(size_t len) noexcept { return len + 500; } @@ -560,7 +560,7 @@ public: memset(Mem_.Get(), 0, size); } - inline bool SaveIncompressibleChunks() const noexcept { + inline bool SaveIncompressibleChunks() const noexcept { // we must save incompressible chunks "as is" // after compressor run in streaming mode return Table_->Setting(3); @@ -621,14 +621,14 @@ DEF_DECOMPRESSOR(TLzqDecompress, TQuickLZDecompress) namespace { template <class T> struct TInputHolder { - static inline T Set(T t) noexcept { + static inline T Set(T t) noexcept { return t; } }; template <class T> struct TInputHolder<TAutoPtr<T>> { - inline T* Set(TAutoPtr<T> v) noexcept { + inline T* Set(TAutoPtr<T> v) noexcept { V_ = v; return V_.Get(); diff --git a/library/cpp/streams/lz/lz.h b/library/cpp/streams/lz/lz.h index 3a2eaad88b..b2850cc290 100644 --- a/library/cpp/streams/lz/lz.h +++ b/library/cpp/streams/lz/lz.h @@ -33,7 +33,7 @@ struct TDecompressorError: public yexception { class TLz4Compress: public IOutputStream { public: TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); - ~TLz4Compress() override; + ~TLz4Compress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -53,7 +53,7 @@ private: class TLz4Decompress: public IInputStream { public: TLz4Decompress(IInputStream* slave); - ~TLz4Decompress() override; + ~TLz4Decompress() override; private: size_t DoRead(void* buf, size_t len) override; @@ -71,7 +71,7 @@ private: class TSnappyCompress: public IOutputStream { public: TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); - ~TSnappyCompress() override; + ~TSnappyCompress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -91,7 +91,7 @@ private: class TSnappyDecompress: public IInputStream { public: TSnappyDecompress(IInputStream* slave); - ~TSnappyDecompress() override; + ~TSnappyDecompress() override; private: size_t DoRead(void* buf, size_t len) override; @@ -107,7 +107,7 @@ private: class TLzoCompress: public IOutputStream { public: TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); - ~TLzoCompress() override; + ~TLzoCompress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -125,7 +125,7 @@ private: class TLzoDecompress: public IInputStream { public: TLzoDecompress(IInputStream* slave); - ~TLzoDecompress() override; + ~TLzoDecompress() override; private: size_t DoRead(void* buf, size_t len) override; @@ -141,7 +141,7 @@ private: class TLzfCompress: public IOutputStream { public: TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15); - ~TLzfCompress() override; + ~TLzfCompress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -159,7 +159,7 @@ private: class TLzfDecompress: public IInputStream { public: TLzfDecompress(IInputStream* slave); - ~TLzfDecompress() override; + ~TLzfDecompress() override; private: size_t DoRead(void* buf, size_t len) override; @@ -193,7 +193,7 @@ public: EVersion ver = V_1_31, unsigned level = 0, EMode mode = M_0); - ~TLzqCompress() override; + ~TLzqCompress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -211,7 +211,7 @@ private: class TLzqDecompress: public IInputStream { public: TLzqDecompress(IInputStream* slave); - ~TLzqDecompress() override; + ~TLzqDecompress() override; private: size_t DoRead(void* buf, size_t len) override; diff --git a/library/cpp/streams/lz/lz_ut.cpp b/library/cpp/streams/lz/lz_ut.cpp index 6876f070fc..04c53f5cb5 100644 --- a/library/cpp/streams/lz/lz_ut.cpp +++ b/library/cpp/streams/lz/lz_ut.cpp @@ -11,15 +11,15 @@ #define LDATA "./ldata" #define LDATA_RANDOM "./ldata.random" -static const TString data = "aa aaa aa aaa aa aaa bb bbb bb bbb bb bbb"; +static const TString data = "aa aaa aa aaa aa aaa bb bbb bb bbb bb bbb"; namespace { /** * Produces well-formed random crap **/ - TString RandomString(size_t size) { - TString entropy(NResource::Find("/random.data")); - TString result; + TString RandomString(size_t size) { + TString entropy(NResource::Find("/random.data")); + TString result; size_t seed = 1; size_t j = 0; for (size_t i = 0; i < size; ++i) { @@ -38,8 +38,8 @@ namespace { return result; } - TVector<TString> InitRandomData() { - static const TVector<size_t> sizes = { + TVector<TString> InitRandomData() { + static const TVector<size_t> sizes = { 0, 1, 127, @@ -47,7 +47,7 @@ namespace { 32767, }; - TVector<TString> result; + TVector<TString> result; for (auto size : sizes) { result.push_back(RandomString(size)); } @@ -55,18 +55,18 @@ namespace { return result; } - TString TestFileName(const TString& d, size_t bufferSize) { + TString TestFileName(const TString& d, size_t bufferSize) { return LDATA_RANDOM + TString(".") + ToString(d.size()) + TString(".") + ToString(bufferSize); } - struct TRandomData: public TVector<TString> { + struct TRandomData: public TVector<TString> { inline TRandomData() { InitRandomData().swap(*this); } }; } -static const TVector<size_t> bufferSizes = { +static const TVector<size_t> bufferSizes = { 127, 1024, 32768, @@ -84,10 +84,10 @@ namespace { template <class C> static inline void TestGoodDataCompress() { - TFixedBufferFileOutput o(LDATA); + TFixedBufferFileOutput o(LDATA); C c(&o, 1024); - TString d = data; + TString d = data; for (size_t i = 0; i < 10; ++i) { c.Write(d.data(), d.size()); @@ -100,9 +100,9 @@ static inline void TestGoodDataCompress() { } template <class C> -static inline void TestIncompressibleDataCompress(const TString& d, size_t bufferSize) { - TString testFileName = TestFileName(d, bufferSize); - TFixedBufferFileOutput o(testFileName); +static inline void TestIncompressibleDataCompress(const TString& d, size_t bufferSize) { + TString testFileName = TestFileName(d, bufferSize); + TFixedBufferFileOutput o(testFileName); C c(&o, bufferSize); c.Write(d.data(), d.size()); c.Finish(); @@ -124,12 +124,12 @@ static inline void TestGoodDataDecompress() { TTempFile tmpFile(LDATA); { - TFileInput i1(LDATA); - D ld(&i1); + TFileInput i1(LDATA); + D ld(&i1); - TString d = data; + TString d = data; - for (size_t i2 = 0; i2 < 10; ++i2) { + for (size_t i2 = 0; i2 < 10; ++i2) { UNIT_ASSERT_EQUAL(ld.ReadLine(), d); d = d + d; @@ -138,12 +138,12 @@ static inline void TestGoodDataDecompress() { } template <class D> -static inline void TestIncompressibleDataDecompress(const TString& d, size_t bufferSize) { - TString testFileName = TestFileName(d, bufferSize); +static inline void TestIncompressibleDataDecompress(const TString& d, size_t bufferSize) { + TString testFileName = TestFileName(d, bufferSize); TTempFile tmpFile(testFileName); { - TFileInput i(testFileName); + TFileInput i(testFileName); D ld(&i); UNIT_ASSERT_EQUAL(ld.ReadAll(), d); diff --git a/library/cpp/streams/lzma/lzma.cpp b/library/cpp/streams/lzma/lzma.cpp index f1942fa546..34c4e50c84 100644 --- a/library/cpp/streams/lzma/lzma.cpp +++ b/library/cpp/streams/lzma/lzma.cpp @@ -31,7 +31,7 @@ namespace { return ret->AdditionalData(); } - inline void Deallocate(void* ptr) noexcept { + inline void Deallocate(void* ptr) noexcept { if (ptr) { delete TAllocation::ObjectFromData(ptr); } @@ -65,7 +65,7 @@ namespace { { } - ~TInput() override { + ~TInput() override { } size_t DoRead(void* ptr, size_t len) override { @@ -83,7 +83,7 @@ namespace { { } - ~TOutput() override { + ~TOutput() override { } void DoWrite(const void* ptr, size_t len) override { @@ -105,7 +105,7 @@ namespace { { } - virtual ~TInverseFilter() { + virtual ~TInverseFilter() { if (!UncaughtException()) { try { Finish(); @@ -277,7 +277,7 @@ namespace { TMemoryGc Gc_; }; - inline ISzAlloc* Alloc() noexcept { + inline ISzAlloc* Alloc() noexcept { return &Alloc_; } @@ -317,7 +317,7 @@ namespace { Check(LzmaEnc_WriteProperties(H_, PropsBuf_, &bufLen)); } - inline ~TLzmaCompressBase() { + inline ~TLzmaCompressBase() { LzmaEnc_Destroy(H_, Alloc(), Alloc()); } @@ -354,7 +354,7 @@ public: { LzmaDec_Construct(&H_); } - inline virtual ~TImpl() { + inline virtual ~TImpl() { LzmaDec_Free(&H_, Alloc()); } @@ -483,7 +483,7 @@ TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) { } -TLzmaCompress::~TLzmaCompress() { +TLzmaCompress::~TLzmaCompress() { } void TLzmaCompress::DoWrite(const void* buf, size_t len) { @@ -512,7 +512,7 @@ TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) { } -TLzmaDecompress::~TLzmaDecompress() { +TLzmaDecompress::~TLzmaDecompress() { } size_t TLzmaDecompress::DoRead(void* buf, size_t len) { diff --git a/library/cpp/streams/lzma/lzma.h b/library/cpp/streams/lzma/lzma.h index ca1e06e9ef..daf9dd66b9 100644 --- a/library/cpp/streams/lzma/lzma.h +++ b/library/cpp/streams/lzma/lzma.h @@ -9,7 +9,7 @@ class TLzmaCompress: public IOutputStream { public: TLzmaCompress(IOutputStream* slave, size_t level = 7); - ~TLzmaCompress() override; + ~TLzmaCompress() override; private: void DoWrite(const void* buf, size_t len) override; @@ -24,7 +24,7 @@ class TLzmaDecompress: public IInputStream { public: TLzmaDecompress(IInputStream* slave); TLzmaDecompress(IZeroCopyInput* input); - ~TLzmaDecompress() override; + ~TLzmaDecompress() override; private: size_t DoRead(void* buf, size_t len) override; diff --git a/library/cpp/streams/lzma/lzma_ut.cpp b/library/cpp/streams/lzma/lzma_ut.cpp index 847e98d1ca..907de209b5 100644 --- a/library/cpp/streams/lzma/lzma_ut.cpp +++ b/library/cpp/streams/lzma/lzma_ut.cpp @@ -8,7 +8,7 @@ class TStrokaByOneByte: public IZeroCopyInput { public: - TStrokaByOneByte(const TString& s) + TStrokaByOneByte(const TString& s) : Data(s) , Pos(s.data()) { @@ -26,7 +26,7 @@ private: } } - TString Data; + TString Data; const char* Pos; }; @@ -37,15 +37,15 @@ class TLzmaTest: public TTestBase { UNIT_TEST_SUITE_END(); private: - inline TString GenData() { - TString data; + inline TString GenData() { + TString data; TReallyFastRng32 rnd(RandomNumber<ui64>()); for (size_t i = 0; i < 50000; ++i) { const char ch = rnd.Uniform(256); const size_t len = 1 + rnd.Uniform(10); - data += TString(len, ch); + data += TString(len, ch); } return data; @@ -54,7 +54,7 @@ private: inline void Test2() { class TExcOutput: public IOutputStream { public: - ~TExcOutput() override { + ~TExcOutput() override { } void DoWrite(const void*, size_t) override { @@ -62,7 +62,7 @@ private: } }; - TString data(GenData()); + TString data(GenData()); TMemoryInput mi(data.data(), data.size()); TExcOutput out; @@ -76,9 +76,9 @@ private: } inline void Test1() { - TString data(GenData()); - TString data1; - TString res; + TString data(GenData()); + TString data1; + TString res; { TMemoryInput mi(data.data(), data.size()); diff --git a/library/cpp/string_utils/base64/base64.cpp b/library/cpp/string_utils/base64/base64.cpp index 05c201f0de..d240f1c112 100644 --- a/library/cpp/string_utils/base64/base64.cpp +++ b/library/cpp/string_utils/base64/base64.cpp @@ -245,13 +245,13 @@ size_t Base64Decode(void* dst, const char* b, const char* e) { return outLen; } -TString Base64DecodeUneven(const TStringBuf s) { +TString Base64DecodeUneven(const TStringBuf s) { if (s.length() % 4 == 0) { return Base64Decode(s); } // padding to 4 - return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '=')); + return Base64Decode(TString(s) + TString(4 - (s.length() % 4), '=')); } char* Base64Encode(char* outstr, const unsigned char* instr, size_t len) { diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h index f778a6425a..6c6d2d9f08 100644 --- a/library/cpp/string_utils/base64/base64.h +++ b/library/cpp/string_utils/base64/base64.h @@ -27,14 +27,14 @@ inline TStringBuf Base64Decode(const TStringBuf src, void* dst) { return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end())); } -inline void Base64Decode(const TStringBuf src, TString& dst) { +inline void Base64Decode(const TStringBuf src, TString& dst) { dst.ReserveAndResize(Base64DecodeBufSize(src.size())); dst.resize(Base64Decode(src, dst.begin()).size()); } //WARNING: can process not whole input silently, use Base64StrictDecode instead of this function -inline TString Base64Decode(const TStringBuf s) { - TString ret; +inline TString Base64Decode(const TStringBuf s) { + TString ret; Base64Decode(s, ret); return ret; } @@ -71,7 +71,7 @@ inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) { /// @param src a base64 encoded string. /// @param dst a decoded string. /// -inline void Base64StrictDecode(const TStringBuf src, TString& dst) { +inline void Base64StrictDecode(const TStringBuf src, TString& dst) { dst.ReserveAndResize(Base64DecodeBufSize(src.size())); dst.resize(Base64StrictDecode(src, dst.begin()).size()); } @@ -81,15 +81,15 @@ inline void Base64StrictDecode(const TStringBuf src, TString& dst) { /// /// @returns a decoded string. /// -inline TString Base64StrictDecode(const TStringBuf src) { - TString ret; +inline TString Base64StrictDecode(const TStringBuf src) { + TString ret; Base64StrictDecode(src, ret); return ret; } /// @} /// Works with strings which length is not divisible by 4. -TString Base64DecodeUneven(const TStringBuf s); +TString Base64DecodeUneven(const TStringBuf s); //encode constexpr size_t Base64EncodeBufSize(const size_t len) noexcept { @@ -107,24 +107,24 @@ inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) { return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size())); } -inline void Base64Encode(const TStringBuf src, TString& dst) { +inline void Base64Encode(const TStringBuf src, TString& dst) { dst.ReserveAndResize(Base64EncodeBufSize(src.size())); dst.resize(Base64Encode(src, dst.begin()).size()); } -inline void Base64EncodeUrl(const TStringBuf src, TString& dst) { +inline void Base64EncodeUrl(const TStringBuf src, TString& dst) { dst.ReserveAndResize(Base64EncodeBufSize(src.size())); dst.resize(Base64EncodeUrl(src, dst.begin()).size()); } -inline TString Base64Encode(const TStringBuf s) { - TString ret; +inline TString Base64Encode(const TStringBuf s) { + TString ret; Base64Encode(s, ret); return ret; } -inline TString Base64EncodeUrl(const TStringBuf s) { - TString ret; +inline TString Base64EncodeUrl(const TStringBuf s) { + TString ret; Base64EncodeUrl(s, ret); return ret; } diff --git a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp index c3ed068a37..ae665091e7 100644 --- a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp +++ b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp @@ -2,45 +2,45 @@ #include <library/cpp/string_utils/base64/base64.h> -Y_UNIT_TEST_SUITE(TBase64DecodeUneven) { - Y_UNIT_TEST(Base64DecodeUneven) { - const TString wikipedia_slogan = - "Man is distinguished, not only by his reason, " - "but by this singular passion from other animals, which is a lust of the " - "mind, that by a perseverance of delight in the continued and " - "indefatigable generation of knowledge, exceeds the short " - "vehemence of any carnal pleasure."; - const TString encoded = - "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" - "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" - "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" - "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" - "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; +Y_UNIT_TEST_SUITE(TBase64DecodeUneven) { + Y_UNIT_TEST(Base64DecodeUneven) { + const TString wikipedia_slogan = + "Man is distinguished, not only by his reason, " + "but by this singular passion from other animals, which is a lust of the " + "mind, that by a perseverance of delight in the continued and " + "indefatigable generation of knowledge, exceeds the short " + "vehemence of any carnal pleasure."; + const TString encoded = + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" + "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" + "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" + "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" + "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="; - UNIT_ASSERT_VALUES_EQUAL(encoded, Base64Encode(wikipedia_slogan)); - UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded)); + UNIT_ASSERT_VALUES_EQUAL(encoded, Base64Encode(wikipedia_slogan)); + UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded)); - const TString encoded_url1 = - "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" - "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" - "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" - "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" - "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4,"; - const TString encoded_url2 = - "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" - "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" - "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" - "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" - "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4"; - UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url1)); - UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url2)); + const TString encoded_url1 = + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" + "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" + "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" + "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" + "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4,"; + const TString encoded_url2 = + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0" + "aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1" + "c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0" + "aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl" + "LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4"; + UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url1)); + UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded_url2)); - const TString lp = "Linkin Park"; - UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64Encode(lp))); - UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64EncodeUrl(lp))); + const TString lp = "Linkin Park"; + UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64Encode(lp))); + UNIT_ASSERT_VALUES_EQUAL(lp, Base64DecodeUneven(Base64EncodeUrl(lp))); - const TString dp = "ADP GmbH\nAnalyse Design & Programmierung\nGesellschaft mit beschränkter Haftung"; - UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64Encode(dp))); - UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64EncodeUrl(dp))); + const TString dp = "ADP GmbH\nAnalyse Design & Programmierung\nGesellschaft mit beschränkter Haftung"; + UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64Encode(dp))); + UNIT_ASSERT_VALUES_EQUAL(dp, Base64DecodeUneven(Base64EncodeUrl(dp))); } } diff --git a/library/cpp/string_utils/base64/base64_ut.cpp b/library/cpp/string_utils/base64/base64_ut.cpp index bcc1e65879..4ba3cc6eb6 100644 --- a/library/cpp/string_utils/base64/base64_ut.cpp +++ b/library/cpp/string_utils/base64/base64_ut.cpp @@ -94,8 +94,8 @@ namespace NB64Etalon { MAX_IMPL }; - using TEncodeF = void (*)(const TStringBuf&, TString&); - using TDecodeF = void (*)(const TStringBuf&, TString&); + using TEncodeF = void (*)(const TStringBuf&, TString&); + using TDecodeF = void (*)(const TStringBuf&, TString&); struct TImpl { TEncodeF Encode = nullptr; @@ -163,8 +163,8 @@ void Out<NB64Etalon::TImpls::EImpl>(IOutputStream& o, typename TTypeTraits<NB64E } } -static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { - TString a, b; +static void TestEncodeDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { + TString a, b; Base64Encode(plain, a); UNIT_ASSERT_VALUES_EQUAL(a, encoded); @@ -179,8 +179,8 @@ static void TestEncodeDecodeIntoString(const TString& plain, const TString& enco UNIT_ASSERT_VALUES_EQUAL(b, plain); } -static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { - TString a, b; +static void TestEncodeStrictDecodeIntoString(const TString& plain, const TString& encoded, const TString& encodedUrl) { + TString a, b; Base64Encode(plain, a); UNIT_ASSERT_VALUES_EQUAL(a, encoded); @@ -205,11 +205,11 @@ Y_UNIT_TEST_SUITE(TBase64) { Y_UNIT_TEST(TestIntoString) { { - TString str; + TString str; for (size_t i = 0; i < 256; ++i) str += char(i); - const TString base64 = + const TString base64 = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJy" "gpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9Q" "UVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eH" @@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(TBase64) { "oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIyc" "rLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy" "8/T19vf4+fr7/P3+/w=="; - const TString base64Url = + const TString base64Url = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJy" "gpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9Q" "UVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eH" @@ -231,10 +231,10 @@ Y_UNIT_TEST_SUITE(TBase64) { } { - const TString str = "http://yandex.ru:1234/request?param=value&lll=fff#fragment"; + const TString str = "http://yandex.ru:1234/request?param=value&lll=fff#fragment"; - const TString base64 = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q/cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA=="; - const TString base64Url = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q_cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA,,"; + const TString base64 = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q/cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA=="; + const TString base64Url = "aHR0cDovL3lhbmRleC5ydToxMjM0L3JlcXVlc3Q_cGFyYW09dmFsdWUmbGxsPWZmZiNmcmFnbWVudA,,"; TestEncodeDecodeIntoString(str, base64, base64Url); TestEncodeStrictDecodeIntoString(str, base64, base64Url); @@ -286,94 +286,94 @@ Y_UNIT_TEST_SUITE(TBase64) { } Y_UNIT_TEST(TestDecodeRandom) { - TString input; + TString input; constexpr size_t testSize = 240000; for (size_t i = 0; i < testSize; ++i) { input.push_back(rand() % 256); } - TString output; - TString encoded = Base64Encode(input); + TString output; + TString encoded = Base64Encode(input); UNIT_ASSERT_VALUES_EQUAL(Base64Decode(encoded), input); UNIT_ASSERT_VALUES_EQUAL(Base64StrictDecode(encoded), input); } Y_UNIT_TEST(TestAllPossibleOctets) { const TString x("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7F"sv); - const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestTwoPaddingCharacters) { const TString x("a"); - const TString xEnc = "YQ=="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "YQ=="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestOnePaddingCharacter) { const TString x("aa"); - const TString xEnc = "YWE="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "YWE="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestNoPaddingCharacters) { const TString x("aaa"); - const TString xEnc = "YWFh"; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "YWFh"; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestTrailingZero) { const TString x("foo\0"sv); - const TString xEnc = "Zm9vAA=="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "Zm9vAA=="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestTwoTrailingZeroes) { const TString x("foo\0\0"sv); - const TString xEnc = "Zm9vAAA="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "Zm9vAAA="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestZero) { const TString x("\0"sv); - const TString xEnc = "AA=="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "AA=="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestSymbolsAfterZero) { const TString x("\0a"sv); - const TString xEnc = "AGE="; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = "AGE="; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } Y_UNIT_TEST(TestEmptyString) { const TString x = ""; - const TString xEnc = ""; - const TString y = Base64Decode(xEnc); - const TString yEnc = Base64Encode(x); + const TString xEnc = ""; + const TString y = Base64Decode(xEnc); + const TString yEnc = Base64Encode(x); UNIT_ASSERT_VALUES_EQUAL(x, y); UNIT_ASSERT_VALUES_EQUAL(xEnc, yEnc); } @@ -382,11 +382,11 @@ Y_UNIT_TEST_SUITE(TBase64) { constexpr size_t TEST_CASES_COUNT = 1000; constexpr size_t MAX_DATA_SIZE = 1000; TFastRng<ui32> prng{42}; - TVector<TString> xs{TEST_CASES_COUNT}; - TString xEnc; - TString xDec; - TString yEnc; - TString yDec; + TVector<TString> xs{TEST_CASES_COUNT}; + TString xEnc; + TString xDec; + TString yEnc; + TString yDec; for (auto& x : xs) { const size_t size = prng() % MAX_DATA_SIZE; @@ -426,8 +426,8 @@ Y_UNIT_TEST_SUITE(TBase64) { constexpr size_t TEST_CASES_COUNT = 1000; constexpr size_t MAX_DATA_SIZE = 1000; TFastRng<ui32> prng{42}; - TString x; - TVector<char> buf; + TString x; + TVector<char> buf; for (size_t i = 0; i < TEST_CASES_COUNT; ++i) { const size_t size = prng() % MAX_DATA_SIZE; x.clear(); diff --git a/library/cpp/string_utils/base64/bench/main.cpp b/library/cpp/string_utils/base64/bench/main.cpp index 10e09bc1c7..2b371cd3f1 100644 --- a/library/cpp/string_utils/base64/bench/main.cpp +++ b/library/cpp/string_utils/base64/bench/main.cpp @@ -4,7 +4,7 @@ #include <util/generic/buffer.h> #include <util/generic/singleton.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/generic/xrange.h> #include <util/generic/yexception.h> @@ -12,9 +12,9 @@ #include <array> -static TString GenerateRandomData(const size_t minSize, const size_t maxSize) { +static TString GenerateRandomData(const size_t minSize, const size_t maxSize) { Y_ENSURE(minSize <= maxSize, "wow"); - TString r; + TString r; for (size_t i = 0; i < minSize; ++i) { r.push_back(RandomNumber<char>()); } @@ -32,8 +32,8 @@ static TString GenerateRandomData(const size_t minSize, const size_t maxSize) { } template <size_t N> -static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) { - std::array<TString, N> r; +static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, const size_t maxSize) { + std::array<TString, N> r; for (size_t i = 0; i < N; ++i) { r[i] = GenerateRandomData(minSize, maxSize); } @@ -42,8 +42,8 @@ static std::array<TString, N> GenerateRandomDataVector(const size_t minSize, con } template <size_t N> -static std::array<TString, N> Encode(const std::array<TString, N>& d) { - std::array<TString, N> r; +static std::array<TString, N> Encode(const std::array<TString, N>& d) { + std::array<TString, N> r; for (size_t i = 0, iEnd = d.size(); i < iEnd; ++i) { r[i] = Base64Encode(d[i]); } @@ -67,8 +67,8 @@ namespace { } static constexpr size_t Size = N; - const std::array<TString, N> Data; - const std::array<TString, N> DataEncoded; + const std::array<TString, N> Data; + const std::array<TString, N> DataEncoded; std::array<TBuffer, N> PlaceToEncode; std::array<TBuffer, N> PlaceToDecode; }; diff --git a/library/cpp/string_utils/base64/ut/ya.make b/library/cpp/string_utils/base64/ut/ya.make index 9b61241f0e..ec02357f0a 100644 --- a/library/cpp/string_utils/base64/ut/ya.make +++ b/library/cpp/string_utils/base64/ut/ya.make @@ -7,7 +7,7 @@ UNITTEST_FOR(library/cpp/string_utils/base64) SRCS( base64_ut.cpp - base64_decode_uneven_ut.cpp + base64_decode_uneven_ut.cpp ) PEERDIR( diff --git a/library/cpp/string_utils/indent_text/indent_text.cpp b/library/cpp/string_utils/indent_text/indent_text.cpp index 09a4f6bca8..8b878aef65 100644 --- a/library/cpp/string_utils/indent_text/indent_text.cpp +++ b/library/cpp/string_utils/indent_text/indent_text.cpp @@ -2,9 +2,9 @@ #include <util/stream/str.h> -TString IndentText(TStringBuf text, TStringBuf indent) { +TString IndentText(TStringBuf text, TStringBuf indent) { if (text.empty()) - return TString(); + return TString(); TStringStream ss; ss.Reserve(text.size() + 20); diff --git a/library/cpp/string_utils/indent_text/indent_text.h b/library/cpp/string_utils/indent_text/indent_text.h index 7117d6c0ee..f5ececcf80 100644 --- a/library/cpp/string_utils/indent_text/indent_text.h +++ b/library/cpp/string_utils/indent_text/indent_text.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> TString IndentText(TStringBuf text, TStringBuf indent = TStringBuf(" ")); diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h index 8a240bfed8..9208276b70 100644 --- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h +++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h @@ -39,7 +39,7 @@ namespace NLevenshtein { } } - using TEditChain = TVector<EEditMoveType>; + using TEditChain = TVector<EEditMoveType>; template <typename TArgType> struct TWeightOneUnaryGetter { @@ -139,7 +139,7 @@ namespace NLevenshtein { } } - template <class TStringType> + template <class TStringType> size_t Distance(const TStringType& str1, const TStringType& str2) { TEditChain editChain; GetEditChain(str1, str2, editChain); @@ -170,8 +170,8 @@ namespace NLevenshtein { } }; - template <class TStringType> - void GetStringReplacements(const TStringType& str1, const TStringType& str2, TVector<TReplacement>& res) { + template <class TStringType> + void GetStringReplacements(const TStringType& str1, const TStringType& str2, TVector<TReplacement>& res) { TEditChain editChain; GetEditChain(str1, str2, editChain); editChain.push_back(EMT_SPECIAL); 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 8fff4f56b2..ebf0b55e4f 100644 --- a/library/cpp/string_utils/parse_size/parse_size_ut.cpp +++ b/library/cpp/string_utils/parse_size/parse_size_ut.cpp @@ -56,7 +56,7 @@ private: } void TestToString() { - UNIT_ASSERT_VALUES_EQUAL(ToString(FromKiloBytes(1)), TString("1024")); + UNIT_ASSERT_VALUES_EQUAL(ToString(FromKiloBytes(1)), TString("1024")); } }; diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp index e523350b80..9350765b01 100644 --- a/library/cpp/string_utils/quote/quote.cpp +++ b/library/cpp/string_utils/quote/quote.cpp @@ -1,8 +1,8 @@ #include "quote.h" #include <util/memory/tempbuf.h> -#include <util/string/ascii.h> -#include <util/string/cstriter.h> +#include <util/string/ascii.h> +#include <util/string/cstriter.h> #include <cctype> @@ -14,14 +14,14 @@ ++x; \ } while (0) -#define GETSBXC \ - do { \ - c *= 16; \ - c += (x[0] >= 'A' ? ((x[0] & 0xdf) - 'A') + 10 : (x[0] - '0')); \ - x.Skip(1); \ - } while (0) - - +#define GETSBXC \ + do { \ + c *= 16; \ + c += (x[0] >= 'A' ? ((x[0] & 0xdf) - 'A') + 10 : (x[0] - '0')); \ + x.Skip(1); \ + } while (0) + + namespace { class TFromHexZeroTerm { public: @@ -40,8 +40,8 @@ namespace { return '%'; ui8 c = 0; - GETSBXC; - GETSBXC; + GETSBXC; + GETSBXC; return c; } }; @@ -68,7 +68,7 @@ static inline char d2x(unsigned x) { return (char)((x < 10) ? ('0' + x) : ('A' + x - 10)); } -static inline const char* FixZero(const char* s) noexcept { +static inline const char* FixZero(const char* s) noexcept { return s ? s : ""; } @@ -155,15 +155,15 @@ char* CGIEscape(char* to, const char* from, size_t len) { return Escape(to, from, from + len); } -void CGIEscape(TString& url) { +void CGIEscape(TString& url) { TTempBuf tempBuf(CgiEscapeBufLen(url.size())); char* to = tempBuf.Data(); url.AssignNoAlias(to, CGIEscape(to, url.data(), url.size())); } -TString CGIEscapeRet(const TStringBuf url) { - TString to; +TString CGIEscapeRet(const TStringBuf url) { + TString to; to.ReserveAndResize(CgiEscapeBufLen(url.size())); to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data()); return to; @@ -207,7 +207,7 @@ char* Quote(char* to, const TStringBuf s, const char* safe) { return Quote(to, s.data(), s.data() + s.size(), safe); } -void Quote(TString& url, const char* safe) { +void Quote(TString& url, const char* safe) { TTempBuf tempBuf(CgiEscapeBufLen(url.size())); char* to = tempBuf.Data(); @@ -222,7 +222,7 @@ char* CGIUnescape(char* to, const char* from, size_t len) { return Unescape(to, from, from + len, TFromHexLenLimited(from + len)); } -void CGIUnescape(TString& url) { +void CGIUnescape(TString& url) { if (url.empty()) { return; } @@ -235,8 +235,8 @@ void CGIUnescape(TString& url) { } } -TString CGIUnescapeRet(const TStringBuf from) { - TString to; +TString CGIUnescapeRet(const TStringBuf from) { + TString to; to.ReserveAndResize(CgiUnescapeBufLen(from.size())); to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data()); return to; @@ -245,7 +245,7 @@ TString CGIUnescapeRet(const TStringBuf from) { char* UrlUnescape(char* to, TStringBuf from) { while (!from.empty()) { char ch = from[0]; - from.Skip(1); + from.Skip(1); if ('%' == ch && 2 <= from.length()) ch = TFromHexZeroTerm::x2c(from); *to++ = ch; @@ -256,7 +256,7 @@ char* UrlUnescape(char* to, TStringBuf from) { return to; } -void UrlUnescape(TString& url) { +void UrlUnescape(TString& url) { if (url.empty()) { return; } @@ -269,8 +269,8 @@ void UrlUnescape(TString& url) { } } -TString UrlUnescapeRet(const TStringBuf from) { - TString to; +TString UrlUnescapeRet(const TStringBuf from) { + TString to; to.ReserveAndResize(CgiUnescapeBufLen(from.size())); to.resize(UrlUnescape(to.begin(), from) - to.data()); return to; diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h index 3b7221154e..605a5cd858 100644 --- a/library/cpp/string_utils/quote/quote.h +++ b/library/cpp/string_utils/quote/quote.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> //CGIEscape*: // ' ' converted to '+', @@ -13,8 +13,8 @@ char* CGIEscape(char* to, const char* from, size_t len); inline char* CGIEscape(char* to, const TStringBuf from) { return CGIEscape(to, from.data(), from.size()); } -void CGIEscape(TString& url); -TString CGIEscapeRet(const TStringBuf url); +void CGIEscape(TString& url); +TString CGIEscapeRet(const TStringBuf url); TString& AppendCgiEscaped(const TStringBuf value, TString& to); inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { @@ -30,8 +30,8 @@ inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { // If pointer returned, then this is pointer to the end of the result string. char* CGIUnescape(char* to, const char* from); char* CGIUnescape(char* to, const char* from, size_t len); -void CGIUnescape(TString& url); -TString CGIUnescapeRet(const TStringBuf from); +void CGIUnescape(TString& url); +TString CGIUnescapeRet(const TStringBuf from); inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIUnescape(to, from.data(), from.size())); @@ -44,13 +44,13 @@ inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) { // Is like CGIEscape, also skips encoding of user-supplied 'safe' characters. char* Quote(char* to, const char* from, const char* safe = "/"); char* Quote(char* to, const TStringBuf s, const char* safe = "/"); -void Quote(TString& url, const char* safe = "/"); +void Quote(TString& url, const char* safe = "/"); //UrlEscape: // Can't be used for cgi parameters ('&' character is not escaped)! // escapes only '%' not followed by two hex-digits or if forceEscape set to ture, // and chars outside [32, 126] range. -// Can't handle '\0'-chars in TString. +// Can't handle '\0'-chars in TString. char* UrlEscape(char* to, const char* from, bool forceEscape = false); void UrlEscape(TString& url, bool forceEscape = false); TString UrlEscapeRet(const TStringBuf from, bool forceEscape = false); @@ -59,8 +59,8 @@ TString UrlEscapeRet(const TStringBuf from, bool forceEscape = false); // '+' is NOT converted to space! // %xx converted to bytes, other characters are copied unchanged. char* UrlUnescape(char* to, TStringBuf from); -void UrlUnescape(TString& url); -TString UrlUnescapeRet(const TStringBuf from); +void UrlUnescape(TString& url); +TString UrlUnescapeRet(const TStringBuf from); //*BufLen: how much characters you should allocate for 'char* to' buffers. constexpr size_t CgiEscapeBufLen(const size_t len) noexcept { diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp index 6c552b279e..46015c8046 100644 --- a/library/cpp/string_utils/quote/quote_ut.cpp +++ b/library/cpp/string_utils/quote/quote_ut.cpp @@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { char r[] = {'1', '2', '3', '4'}; char buf[sizeof(r) * 3 + 2]; - TString ret(buf, CGIEscape(buf, r, sizeof(r))); + TString ret(buf, CGIEscape(buf, r, sizeof(r))); UNIT_ASSERT_EQUAL(ret, "1234"); } @@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { } Y_UNIT_TEST(StrokaOutParameterInplace) { - TString s; + TString s; s = "hello%3dworld"; CGIUnescape(s); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { } Y_UNIT_TEST(StrokaOutParameterNotInplace) { - TString s, sCopy; + TString s, sCopy; s = "hello%3dworld"; sCopy = s; @@ -232,7 +232,7 @@ Y_UNIT_TEST_SUITE(TUrlEscapeTest) { Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { Y_UNIT_TEST(StrokaOutParameterInplace) { - TString s; + TString s; s = "hello%3dworld"; UrlUnescape(s); @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) { } Y_UNIT_TEST(StrokaOutParameterNotInplace) { - TString s, sCopy; + TString s, sCopy; s = "hello%3dworld"; sCopy = s; @@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { char r[100]; Quote(r, "/path;tail/path,tail/"); UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", r); - TString s("/path;tail/path,tail/"); + TString s("/path;tail/path,tail/"); Quote(s); UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", s.c_str()); } @@ -306,7 +306,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) { char r[100]; Quote(r, "/path;tail/path,tail/", ";,"); UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", r); - TString s("/path;tail/path,tail/"); + TString s("/path;tail/path,tail/"); Quote(s, ";,"); UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", s.c_str()); } diff --git a/library/cpp/string_utils/quote/ut/ya.make b/library/cpp/string_utils/quote/ut/ya.make index eca955144f..50a6c0d85b 100644 --- a/library/cpp/string_utils/quote/ut/ya.make +++ b/library/cpp/string_utils/quote/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/string_utils/quote) - -OWNER(vladon) - -SRCS( - quote_ut.cpp -) - -END() + +OWNER(vladon) + +SRCS( + quote_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/quote/ya.make b/library/cpp/string_utils/quote/ya.make index 55bb3cf939..d48130fe24 100644 --- a/library/cpp/string_utils/quote/ya.make +++ b/library/cpp/string_utils/quote/ya.make @@ -1,10 +1,10 @@ -LIBRARY() - -OWNER(g:util) - -SRCS( - quote.cpp - quote.h -) - -END() +LIBRARY() + +OWNER(g:util) + +SRCS( + quote.cpp + quote.h +) + +END() diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h index d7ea7c1259..7c45f50c9b 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h @@ -165,7 +165,7 @@ namespace NEscJ { } template <bool quote, bool tounicode> - inline void EscapeJ(TStringBuf in, TString& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, TString& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { TTempBuf b(SuggestBuffer(in.size()) + 2); if (quote) @@ -180,8 +180,8 @@ namespace NEscJ { } template <bool quote, bool tounicode> - inline TString EscapeJ(TStringBuf in, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { - TString s; + inline TString EscapeJ(TStringBuf in, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + TString s; EscapeJ<quote, tounicode>(in, s, safe, unsafe); return s; } @@ -197,12 +197,12 @@ namespace NEscJ { } template <bool quote> - inline void EscapeJ(TStringBuf in, TString& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline void EscapeJ(TStringBuf in, TString& out, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { EscapeJ<quote, false>(in, out, safe, unsafe); } template <bool quote> - inline TString EscapeJ(TStringBuf in, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { + inline TString EscapeJ(TStringBuf in, TStringBuf safe = TStringBuf(), TStringBuf unsafe = TStringBuf()) { return EscapeJ<quote, false>(in, safe, unsafe); } } diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp index 768555ea3a..a54c5a0108 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp @@ -31,15 +31,15 @@ Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { TString expected(CommonTestData[i].data(), CommonTestData[i].size()); TString source(CommonTestData[i + 1].data(), CommonTestData[i + 1].size()); - TString actual(EscapeJ<false>(source)); - TString actual2(UnescapeC(expected)); + TString actual(EscapeJ<false>(source)); + TString actual2(UnescapeC(expected)); UNIT_ASSERT_VALUES_EQUAL(expected, actual); UNIT_ASSERT_VALUES_EQUAL(source, actual2); } UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\xAB", EscapeJ<false>("http://ya.ru/\x17\n\xab")); - TString s = EscapeJ<false, true>("http://ya.ru/\x17\n\xab\xff"); + TString s = EscapeJ<false, true>("http://ya.ru/\x17\n\xab\xff"); UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\u0017\\n\xAB\\xFF", s); UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\n\xAB", EscapeJ<false>("http://ya.ru/\x17\n\xab", "\n")); UNIT_ASSERT_VALUES_EQUAL("http:\\x2F\\x2Fya.ru\\x2F\\x17\n\xAB'", EscapeJ<false>("http://ya.ru/\x17\n\xab'", "\n'", "/")); diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d69..3bdf137598 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -1,11 +1,11 @@ #include "url.h" -#include <util/string/cast.h> -#include <util/string/util.h> -#include <util/string/cstriter.h> -#include <util/string/ascii.h> -#include <util/string/strip.h> - +#include <util/string/cast.h> +#include <util/string/util.h> +#include <util/string/cstriter.h> +#include <util/string/ascii.h> +#include <util/string/strip.h> + #include <util/charset/unidata.h> // for ToLower #include <util/system/defaults.h> #include <util/generic/algorithm.h> @@ -267,7 +267,7 @@ TStringBuf GetParentDomain(const TStringBuf host, size_t level) noexcept { size_t pos = host.size(); for (size_t i = 0; i < level; ++i) { pos = host.rfind('.', pos); - if (pos == TString::npos) + if (pos == TString::npos) return host; } return host.SubStr(pos + 1); @@ -310,7 +310,7 @@ TStringBuf CutMPrefix(const TStringBuf url) noexcept { return url; } -static inline bool IsSchemeChar(char c) noexcept { +static inline bool IsSchemeChar(char c) noexcept { return IsAsciiAlnum(c); //what about '+' ?.. } @@ -322,7 +322,7 @@ static bool HasPrefix(const TStringBuf url) noexcept { return AllOf(scheme, IsSchemeChar); } -TString AddSchemePrefix(const TString& url) { +TString AddSchemePrefix(const TString& url) { return AddSchemePrefix(url, TStringBuf("http")); } diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h index 84137ccc57..f3ff2491f4 100644 --- a/library/cpp/string_utils/url/url.h +++ b/library/cpp/string_utils/url/url.h @@ -34,7 +34,7 @@ size_t GetHttpPrefixSize(const TStringBuf url, bool ignorehttps = false) noexcep Y_PURE_FUNCTION size_t GetHttpPrefixSize(const TWtringBuf url, bool ignorehttps = false) noexcept; -/** BEWARE of TStringBuf! You can not use operator ~ or c_str() like in TString +/** BEWARE of TStringBuf! You can not use operator ~ or c_str() like in TString !!!!!!!!!!!! */ Y_PURE_FUNCTION size_t GetSchemePrefixSize(const TStringBuf url) noexcept; @@ -61,7 +61,7 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept; TString AddSchemePrefix(const TString& url, const TStringBuf scheme); //! Same as `AddSchemePrefix(url, "http")`. -TString AddSchemePrefix(const TString& url); +TString AddSchemePrefix(const TString& url); Y_PURE_FUNCTION TStringBuf GetHost(const TStringBuf url) noexcept; diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 1588013893..5c7c4ae6e3 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -1,7 +1,7 @@ #include "url.h" -#include <util/string/cast.h> - +#include <util/string/cast.h> + #include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TUtilUrlTest) { diff --git a/library/cpp/string_utils/url/ut/ya.make b/library/cpp/string_utils/url/ut/ya.make index 0efa30e4d2..6e60701aaa 100644 --- a/library/cpp/string_utils/url/ut/ya.make +++ b/library/cpp/string_utils/url/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/string_utils/url) - -OWNER(g:util) - -SRCS( - url_ut.cpp -) - -END() + +OWNER(g:util) + +SRCS( + url_ut.cpp +) + +END() diff --git a/library/cpp/string_utils/url/ya.make b/library/cpp/string_utils/url/ya.make index b08d69ec83..179dbc062b 100644 --- a/library/cpp/string_utils/url/ya.make +++ b/library/cpp/string_utils/url/ya.make @@ -1,10 +1,10 @@ -LIBRARY() - -OWNER(g:util) - -SRCS( - url.cpp - url.h -) - -END() +LIBRARY() + +OWNER(g:util) + +SRCS( + url.cpp + url.h +) + +END() diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp index 08d8708005..70b9bcaf36 100644 --- a/library/cpp/testing/benchmark/bench.cpp +++ b/library/cpp/testing/benchmark/bench.cpp @@ -100,7 +100,7 @@ namespace { } struct THiPerfTimer: public THPTimer { - static inline TString FmtTime(double t) { + static inline TString FmtTime(double t) { return DoFmtTime(t); } }; @@ -110,7 +110,7 @@ namespace { return (TInstant::Now() - N).MicroSeconds() / 1000000.0; } - static inline TString FmtTime(double t) { + static inline TString FmtTime(double t) { return DoFmtTime(t); } @@ -122,12 +122,12 @@ namespace { return GetCycleCount() - N; } - static inline TString FmtTime(double t) { + static inline TString FmtTime(double t) { if (t < 0.5) { t = 0.0; } - TString hr; + TString hr; if (t > 10 * 1000) { hr = " (" + ToString(HumanReadableSize(t, ESizeFormat::SF_QUANTITY)) + ")"; } @@ -162,7 +162,7 @@ namespace { }; using TSample = std::pair<size_t, double>; - using TSamples = TVector<TSample>; + using TSamples = TVector<TSample>; struct TLinFunc { double A; @@ -203,7 +203,7 @@ namespace { }; using TSampleWithError = std::pair<const TSample*, double>; - TVector<TSampleWithError> v; + TVector<TSampleWithError> v; v.reserve(s.size()); @@ -384,7 +384,7 @@ namespace { private: TAdaptiveLock ResultsLock_; - TVector<TResult> Results_; + TVector<TResult> Results_; }; class TOrderedReporter: public IReporter { @@ -544,7 +544,7 @@ namespace { bool ListTests = false; double TimeBudget = -1.0; - TVector<THolder<RE2>> Filters; + TVector<THolder<RE2>> Filters; size_t Threads = 0; EOutFormat OutFormat; }; @@ -553,7 +553,7 @@ namespace { int NBench::Main(int argc, char** argv) { const TProgOpts opts(argc, argv); - TVector<ITestRunner*> tests; + TVector<ITestRunner*> tests; for (auto&& it : Tests()) { if (opts.MatchFilters(it.Name())) { diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index ddd8b05ffc..16c467894f 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -7,7 +7,7 @@ #include <util/generic/bt_exception.h> Y_CPU_BENCHMARK(F, iface) { - TVector<size_t> x; + TVector<size_t> x; x.reserve(iface.Iterations()); @@ -23,7 +23,7 @@ Y_CPU_BENCHMARK(EmptyF, iface) { Y_CPU_BENCHMARK(AlmostEmptyF, iface) { (void)iface; - TVector<size_t> x; + TVector<size_t> x; x.resize(1); } diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp index fa3a47fe16..edd9ab4e88 100644 --- a/library/cpp/testing/common/env.cpp +++ b/library/cpp/testing/common/env.cpp @@ -40,7 +40,7 @@ TString BinaryPath(TStringBuf path) { return (TFsPath(BuildRoot()) / path).Fix(); } -TString GetArcadiaTestsData() { +TString GetArcadiaTestsData() { TString atdRoot = NPrivate::GetTestEnv().ArcadiaTestsDataDir; if (atdRoot) { return atdRoot; @@ -49,7 +49,7 @@ TString GetArcadiaTestsData() { TString path = NPrivate::GetCwd(); const char pathsep = GetDirectorySeparator(); while (!path.empty()) { - TString dataDir = path + "/arcadia_tests_data"; + TString dataDir = path + "/arcadia_tests_data"; if (IsDir(dataDir)) { return dataDir; } @@ -64,7 +64,7 @@ TString GetArcadiaTestsData() { return {}; } -TString GetWorkPath() { +TString GetWorkPath() { TString workPath = NPrivate::GetTestEnv().WorkPath; if (workPath) { return workPath; diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h index 7b89aa1bed..f2878c2d26 100644 --- a/library/cpp/testing/common/env.h +++ b/library/cpp/testing/common/env.h @@ -3,7 +3,7 @@ #include <unordered_map> #include <util/folder/path.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/system/src_location.h> diff --git a/library/cpp/testing/gmock_in_unittest/events.cpp b/library/cpp/testing/gmock_in_unittest/events.cpp index dbd65b727d..9169cc3abb 100644 --- a/library/cpp/testing/gmock_in_unittest/events.cpp +++ b/library/cpp/testing/gmock_in_unittest/events.cpp @@ -3,13 +3,13 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/builder.h> void TGMockTestEventListener::OnTestPartResult(const testing::TestPartResult& result) { if (result.failed()) { - const TString message = result.message(); - const TString summary = result.summary(); + const TString message = result.message(); + const TString summary = result.summary(); TStringBuilder msg; if (result.file_name()) msg << result.file_name() << TStringBuf(":"); diff --git a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp index 97f19050e4..7174802c9f 100644 --- a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp +++ b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/string.h> +#include <util/generic/string.h> // Set this variable to true if you want to see failures ///////////////////////////////////////////////////////// @@ -16,7 +16,7 @@ public: virtual void Func1() = 0; - virtual int Func2(const TString&) const = 0; + virtual int Func2(const TString&) const = 0; }; class TTestMock: public ITestIface { @@ -50,11 +50,11 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) { Y_UNIT_TEST(TReturnValuesTest) { TTestMock mock; - EXPECT_CALL(mock, Func2(TString("1"))) + EXPECT_CALL(mock, Func2(TString("1"))) .WillOnce(Return(1)) .WillRepeatedly(Return(42)); - EXPECT_CALL(mock, Func2(TString("hello"))) + EXPECT_CALL(mock, Func2(TString("hello"))) .WillOnce(Return(-1)); UNIT_ASSERT_VALUES_EQUAL(mock.Func2("hello"), -1); diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index c5712ae9d2..0f4b3dae9d 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,7 +1,7 @@ #include <util/generic/string.h> #include <util/string/type.h> -bool CheckExceptionMessage(const char* msg, TString& err) { +bool CheckExceptionMessage(const char* msg, TString& err) { static const char* badMsg[] = { // Операция успешно завершена [cp1251] "\xce\xef\xe5\xf0\xe0\xf6\xe8\xff\x20\xf3\xf1\xef\xe5\xf8\xed\xee\x20\xe7\xe0\xe2\xe5\xf0\xf8\xe5\xed\xe0", @@ -22,7 +22,7 @@ bool CheckExceptionMessage(const char* msg, TString& err) { for (auto& i : badMsg) { if (strstr(msg, i) != nullptr) { - err = "Invalid error message: " + TString(msg); + err = "Invalid error message: " + TString(msg); return false; } } diff --git a/library/cpp/testing/unittest/gtest.cpp b/library/cpp/testing/unittest/gtest.cpp index ebad1ea4d6..6aded3e085 100644 --- a/library/cpp/testing/unittest/gtest.cpp +++ b/library/cpp/testing/unittest/gtest.cpp @@ -8,7 +8,7 @@ using namespace NUnitTest; using namespace NUnitTest::NPrivate; -IGTestFactory::~IGTestFactory() { +IGTestFactory::~IGTestFactory() { } namespace { @@ -18,12 +18,12 @@ namespace { { } - TString TypeId() const override { + TString TypeId() const override { return TypeName(*this) + "-" + MyName; } - TString Name() const noexcept override { - return TString(MyName); + TString Name() const noexcept override { + return TString(MyName); } const TStringBuf MyName; @@ -35,10 +35,10 @@ namespace { { } - ~TGTestFactory() override { + ~TGTestFactory() override { } - TString Name() const noexcept override { + TString Name() const noexcept override { return Test.Name(); } @@ -55,7 +55,7 @@ namespace { } IGTestFactory* NUnitTest::NPrivate::ByName(const char* name) { - static TMap<TStringBuf, TAutoPtr<TGTestFactory>> tests; + static TMap<TStringBuf, TAutoPtr<TGTestFactory>> tests; auto& ret = tests[name]; diff --git a/library/cpp/testing/unittest/gtest.h b/library/cpp/testing/unittest/gtest.h index b6768b1bf0..15e71cc495 100644 --- a/library/cpp/testing/unittest/gtest.h +++ b/library/cpp/testing/unittest/gtest.h @@ -13,7 +13,7 @@ namespace NUnitTest { namespace NPrivate { struct IGTestFactory: public ITestBaseFactory { - ~IGTestFactory() override; + ~IGTestFactory() override; virtual void AddTest(const char* name, void (*body)(TTestContext&), bool forceFork) = 0; }; @@ -30,7 +30,7 @@ namespace NTesting { virtual void TearDown() { } - inline TTest* _This() noexcept { + inline TTest* _This() noexcept { return this; } }; diff --git a/library/cpp/testing/unittest/plugin.cpp b/library/cpp/testing/unittest/plugin.cpp index 543112f7ac..194de77254 100644 --- a/library/cpp/testing/unittest/plugin.cpp +++ b/library/cpp/testing/unittest/plugin.cpp @@ -30,7 +30,7 @@ namespace NUnitTest { } private: - TVector<TSimpleSharedPtr<IPlugin>> Plugins; + TVector<TSimpleSharedPtr<IPlugin>> Plugins; }; } // anonymous namespace diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 3679b768ed..9b75850e97 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -15,9 +15,9 @@ bool NUnitTest::ShouldColorizeDiff = true; bool NUnitTest::ContinueOnFail = false; -TString NUnitTest::RandomString(size_t len, ui32 seed) { +TString NUnitTest::RandomString(size_t len, ui32 seed) { TReallyFastRng32 rand(seed); - TString ret; + TString ret; ret.reserve(len); @@ -34,7 +34,7 @@ Y_POD_STATIC_THREAD(NUnitTest::TTestBase*) currentTest; ::NUnitTest::TRaiseErrorHandler RaiseErrorHandler; -void ::NUnitTest::NPrivate::RaiseError(const char* what, const TString& msg, bool fatalFailure) { +void ::NUnitTest::NPrivate::RaiseError(const char* what, const TString& msg, bool fatalFailure) { Y_VERIFY(UnittestThread, "%s in non-unittest thread with message:\n%s", what, msg.data()); Y_VERIFY(GetCurrentTest()); @@ -119,7 +119,7 @@ struct TTraceDiffFormatter { } TString Common(TArrayRef<const char> str) const { - return TString(str.begin(), str.end()); + return TString(str.begin(), str.end()); } TString Left(TArrayRef<const char> str) const { @@ -135,17 +135,17 @@ struct TTraceDiffFormatter { } }; -TString NUnitTest::GetFormatTag(const char* name) { +TString NUnitTest::GetFormatTag(const char* name) { return Sprintf("[[%s]]", name); } -TString NUnitTest::GetResetTag() { - return TString("[[rst]]"); +TString NUnitTest::GetResetTag() { + return TString("[[rst]]"); } -TString NUnitTest::ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims, bool reverse) { +TString NUnitTest::ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims, bool reverse) { TStringStream res; - TVector<NDiff::TChunk<char>> chunks; + TVector<NDiff::TChunk<char>> chunks; NDiff::InlineDiff(chunks, s1, s2, delims); if (NUnitTest::ShouldColorizeDiff) { NDiff::PrintChunks(res, TDiffColorizer(reverse), chunks); @@ -160,7 +160,7 @@ static TString MakeTestName(const NUnitTest::ITestSuiteProcessor::TTest& test) { return TStringBuilder() << test.unit->name << "::" << test.name; } -static size_t CountTests(const TMap<TString, size_t>& testErrors, bool succeeded) { +static size_t CountTests(const TMap<TString, size_t>& testErrors, bool succeeded) { size_t cnt = 0; for (const auto& t : testErrors) { if (succeeded && t.second == 0) { @@ -465,7 +465,7 @@ unsigned NUnitTest::TTestFactory::Execute() { Items_.QuickSort(TCmp()); Processor_->Start(); - TSet<TString> types; + TSet<TString> types; size_t cnt = 0; for (TIntrusiveList<ITestBaseFactory>::TIterator factory = Items_.Begin(); factory != Items_.End(); ++factory) { diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a0092..a02b5ffe90 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -27,13 +27,13 @@ #include <cstdio> #include <functional> -extern bool CheckExceptionMessage(const char*, TString&); +extern bool CheckExceptionMessage(const char*, TString&); namespace NUnitTest { class TTestBase; namespace NPrivate { - void RaiseError(const char* what, const TString& msg, bool fatalFailure); + void RaiseError(const char* what, const TString& msg, bool fatalFailure); void SetUnittestThread(bool); void SetCurrentTest(TTestBase*); TTestBase* GetCurrentTest(); @@ -41,9 +41,9 @@ namespace NUnitTest { extern bool ShouldColorizeDiff; extern bool ContinueOnFail; - TString ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims = TString(), bool reverse = false); - TString GetFormatTag(const char* name); - TString GetResetTag(); + TString ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims = TString(), bool reverse = false); + TString GetFormatTag(const char* name); + TString GetResetTag(); // Raise error handler // Used for testing library/cpp/testing/unittest macroses @@ -73,7 +73,7 @@ namespace NUnitTest { { } - using TMetrics = THashMap<TString, double>; + using TMetrics = THashMap<TString, double>; TMetrics Metrics; ITestSuiteProcessor* Processor; @@ -82,7 +82,7 @@ namespace NUnitTest { class ITestSuiteProcessor { public: struct TUnit { - const TString name; + const TString name; }; struct TTest { @@ -93,7 +93,7 @@ namespace NUnitTest { struct TError { const TTest* test; const char* msg; - TString BackTrace; + TString BackTrace; TTestContext* Context; }; @@ -163,8 +163,8 @@ namespace NUnitTest { void AddTestFinish(const TTest& test); private: - TMap<TString, size_t> TestErrors_; - TMap<TString, size_t> CurTestErrors_; + TMap<TString, size_t> TestErrors_; + TMap<TString, size_t> CurTestErrors_; }; class TTestBase; @@ -177,7 +177,7 @@ namespace NUnitTest { virtual ~ITestBaseFactory(); // name of test suite - virtual TString Name() const noexcept = 0; + virtual TString Name() const noexcept = 0; virtual TTestBase* ConstructTest() = 0; private: @@ -195,7 +195,7 @@ namespace NUnitTest { virtual TString TypeId() const; - virtual TString Name() const noexcept = 0; + virtual TString Name() const noexcept = 0; virtual void Execute() = 0; virtual void SetUp(); @@ -431,7 +431,7 @@ public: \ const TString _b(B); \ if (_a != _b) { \ auto&& failMsg = Sprintf("%s != %s %s", ToString(_a).data(), ToString(_b).data(), (::TStringBuilder() << C).data()); \ - UNIT_FAIL_IMPL("strings equal assertion failed", failMsg); \ + UNIT_FAIL_IMPL("strings equal assertion failed", failMsg); \ } \ } while (false) @@ -686,7 +686,7 @@ public: \ // helper method to avoid double evaluation of A and B expressions in UNIT_ASSERT_VALUES_EQUAL_C template <typename T, typename U> - static inline bool CompareAndMakeStrings(const T& a, const U& b, TString& as, TString& asInd, TString& bs, TString& bsInd, bool& usePlainDiff, bool want) { + static inline bool CompareAndMakeStrings(const T& a, const U& b, TString& as, TString& asInd, TString& bs, TString& bsInd, bool& usePlainDiff, bool want) { const bool have = CompareEqual(a, b); usePlainDiff = std::is_integral<T>::value && std::is_integral<U>::value; @@ -714,10 +714,10 @@ public: \ if (!::NUnitTest::NPrivate::CompareAndMakeStrings(A, B, _as, _asInd, _bs, _bsInd, _usePlainDiff, EQflag)) { \ auto&& failMsg = Sprintf("(%s %s %s) failed: (%s %s %s) %s", #A, EQstr, #B, _as.data(), NEQstr, _bs.data(), (::TStringBuilder() << C).data()); \ if (EQflag && !_usePlainDiff) { \ - failMsg += ", with diff:\n"; \ - failMsg += ::NUnitTest::ColoredDiff(_asInd, _bsInd); \ + failMsg += ", with diff:\n"; \ + failMsg += ::NUnitTest::ColoredDiff(_asInd, _bsInd); \ } \ - UNIT_FAIL_IMPL("assertion failed", failMsg); \ + UNIT_FAIL_IMPL("assertion failed", failMsg); \ } \ } while (false) @@ -1024,7 +1024,7 @@ public: \ #define Y_UNIT_TEST_FRIEND(N, T) \ friend NTestSuite##N::TTestCase##T \ - TString RandomString(size_t len, ui32 seed = 0); + TString RandomString(size_t len, ui32 seed = 0); } using ::NUnitTest::TTestBase; diff --git a/library/cpp/testing/unittest/tests_data.h b/library/cpp/testing/unittest/tests_data.h index 6536bc1ae6..14ea88eb7c 100644 --- a/library/cpp/testing/unittest/tests_data.h +++ b/library/cpp/testing/unittest/tests_data.h @@ -4,7 +4,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/network/sock.h> class TInet6StreamSocket; diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 305bc6b40f..b2e9d67690 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -14,7 +14,7 @@ #include <util/generic/hash.h> #include <util/generic/hash_set.h> #include <util/generic/scope.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/yexception.h> #include <util/network/init.h> @@ -58,16 +58,16 @@ public: inline TTraceWriterProcessor(const char* traceFilePath, EOpenMode mode) : PrevTime(TInstant::Now()) { - TraceFile = new TUnbufferedFileOutput(TFile(traceFilePath, mode | WrOnly | Seq)); + TraceFile = new TUnbufferedFileOutput(TFile(traceFilePath, mode | WrOnly | Seq)); } private: - TAutoPtr<TUnbufferedFileOutput> TraceFile; - TString TraceFilePath; + TAutoPtr<TUnbufferedFileOutput> TraceFile; + TString TraceFilePath; TInstant PrevTime; - TVector<TString> ErrorMessages; + TVector<TString> ErrorMessages; - inline void Trace(const TString eventName, const NJson::TJsonValue eventValue) { + inline void Trace(const TString eventName, const NJson::TJsonValue eventValue) { NJsonWriter::TBuf json(NJsonWriter::HEM_UNSAFE); json.BeginObject(); @@ -81,7 +81,7 @@ private: *TraceFile << "\n"; } - inline void TraceSubtestFinished(const char* className, const char* subtestName, const char* status, const TString comment, const TTestContext* context) { + inline void TraceSubtestFinished(const char* className, const char* subtestName, const char* status, const TString comment, const TTestContext* context) { const TInstant now = TInstant::Now(); NJson::TJsonValue event; event.InsertValue("class", className); @@ -97,7 +97,7 @@ private: Trace("subtest-finished", event); PrevTime = now; - TString marker = Join("", "\n###subtest-finished:", className, "::", subtestName, "\n"); + TString marker = Join("", "\n###subtest-finished:", className, "::", subtestName, "\n"); Cout << marker; Cout.Flush(); Cerr << comment; @@ -105,7 +105,7 @@ private: Cerr.Flush(); } - virtual TString BuildComment(const char* message, const char* backTrace) { + virtual TString BuildComment(const char* message, const char* backTrace) { return NUnitTest::GetFormatTag("bad") + TString(message).substr(0, MAX_COMMENT_MESSAGE_LENGTH) + NUnitTest::GetResetTag() + @@ -120,7 +120,7 @@ private: event.InsertValue("class", test->unit->name); event.InsertValue("subtest", test->name); Trace("subtest-started", event); - TString marker = Join("", "\n###subtest-started:", test->unit->name, "::", test->name, "\n"); + TString marker = Join("", "\n###subtest-started:", test->unit->name, "::", test->name, "\n"); Cout << marker; Cout.Flush(); Cerr << marker; @@ -149,7 +149,7 @@ private: TraceSubtestFinished(descr->test->unit->name.data(), descr->test->name, "good", "", descr->Context); } else { TStringBuilder msgs; - for (const TString& m : ErrorMessages) { + for (const TString& m : ErrorMessages) { if (msgs) { msgs << TStringBuf("\n"); } @@ -166,7 +166,7 @@ private: class TColoredProcessor: public ITestSuiteProcessor, public NColorizer::TColors { public: - inline TColoredProcessor(const TString& appName) + inline TColoredProcessor(const TString& appName) : PrintBeforeSuite_(true) , PrintBeforeTest_(true) , PrintAfterTest_(true) @@ -186,30 +186,30 @@ public: { } - ~TColoredProcessor() override { + ~TColoredProcessor() override { } inline void Disable(const char* name) { - size_t colon = TString(name).find("::"); - if (colon == TString::npos) { + size_t colon = TString(name).find("::"); + if (colon == TString::npos) { DisabledSuites_.insert(name); } else { - TString suite = TString(name).substr(0, colon); + TString suite = TString(name).substr(0, colon); DisabledTests_.insert(name); } } inline void Enable(const char* name) { - size_t colon = TString(name).rfind("::"); - if (colon == TString::npos) { + size_t colon = TString(name).rfind("::"); + if (colon == TString::npos) { EnabledSuites_.insert(name); - EnabledTests_.insert(TString() + name + "::*"); + EnabledTests_.insert(TString() + name + "::*"); } else { - TString suite = TString(name).substr(0, colon); + TString suite = TString(name).substr(0, colon); EnabledSuites_.insert(suite); EnabledSuites_.insert(name); EnabledTests_.insert(name); - EnabledTests_.insert(TString() + name + "::*"); + EnabledTests_.insert(TString() + name + "::*"); } } @@ -425,7 +425,7 @@ private: } } - bool CheckAccess(TString name, size_t num) override { + bool CheckAccess(TString name, size_t num) override { if (num < Start) { return false; } @@ -445,8 +445,8 @@ private: return EnabledSuites_.find(name.data()) != EnabledSuites_.end(); } - bool CheckAccessTest(TString suite, const char* test) override { - TString name = suite + "::" + test; + bool CheckAccessTest(TString suite, const char* test) override { + TString name = suite + "::" + test; if (DisabledTests_.find(name) != DisabledTests_.end()) { return false; } @@ -455,7 +455,7 @@ private: return true; } - if (EnabledTests_.find(TString() + suite + "::*") != EnabledTests_.end()) { + if (EnabledTests_.find(TString() + suite + "::*") != EnabledTests_.end()) { return true; } @@ -467,7 +467,7 @@ private: return f(); } - TList<TString> args(1, "--is-forked-internal"); + TList<TString> args(1, "--is-forked-internal"); args.push_back(Sprintf("+%s::%s", suite.data(), name)); // stdin is ignored - unittest should not need them... @@ -475,12 +475,12 @@ private: TShellCommandOptions().SetUseShell(false).SetCloseAllFdsOnExec(true).SetAsync(false).SetLatency(1)); cmd.Run(); - const TString& err = cmd.GetError(); + const TString& err = cmd.GetError(); const size_t msgIndex = err.find(ForkCorrectExitMsg); // everything is printed by parent process except test's result output ("good" or "fail") // which is printed by child. If there was no output - parent process prints default message. - ForkExitedCorrectly = msgIndex != TString::npos; + ForkExitedCorrectly = msgIndex != TString::npos; // TODO: stderr output is always printed after stdout Cout.Write(cmd.GetOutput()); @@ -517,16 +517,16 @@ private: bool PrintAfterSuite_; bool PrintTimes_; bool PrintSummary_; - THashSet<TString> DisabledSuites_; - THashSet<TString> EnabledSuites_; - THashSet<TString> DisabledTests_; - THashSet<TString> EnabledTests_; + THashSet<TString> DisabledSuites_; + THashSet<TString> EnabledSuites_; + THashSet<TString> DisabledTests_; + THashSet<TString> EnabledTests_; TInstant PrevTime_; bool ShowFails; - TVector<TString> Fails; + TVector<TString> Fails; size_t Start; size_t End; - TString AppName; + TString AppName; bool ForkTests; bool IsForked; bool Loop; @@ -545,10 +545,10 @@ public: { } - ~TEnumeratingProcessor() override { + ~TEnumeratingProcessor() override { } - bool CheckAccess(TString name, size_t /*num*/) override { + bool CheckAccess(TString name, size_t /*num*/) override { if (Verbose_) { return true; } else { @@ -557,7 +557,7 @@ public: } } - bool CheckAccessTest(TString suite, const char* name) override { + bool CheckAccessTest(TString suite, const char* name) override { Stream_ << suite << "::" << name << "\n"; return false; } @@ -732,7 +732,7 @@ int NUnitTest::RunMain(int argc, char** argv) { TString param(argv[i]); size_t assign = param.find('='); Singleton<::NPrivate::TTestEnv>()->AddTestParam(param.substr(0, assign), param.substr(assign + 1)); - } else if (TString(name).StartsWith("--")) { + } else if (TString(name).StartsWith("--")) { return DoUsage(argv[0]), 1; } else if (*name == '-') { processor.Disable(name + 1); diff --git a/library/cpp/threading/future/perf/main.cpp b/library/cpp/threading/future/perf/main.cpp index 5a0690af47..17a2965498 100644 --- a/library/cpp/threading/future/perf/main.cpp +++ b/library/cpp/threading/future/perf/main.cpp @@ -1,7 +1,7 @@ #include <library/cpp/testing/benchmark/bench.h> #include <library/cpp/threading/future/future.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/xrange.h> using namespace NThreading; @@ -38,7 +38,7 @@ Y_CPU_BENCHMARK(AllocPromiseUI64, iface) { } Y_CPU_BENCHMARK(AllocPromiseStroka, iface) { - TestAllocPromise<TString>(iface); + TestAllocPromise<TString>(iface); } Y_CPU_BENCHMARK(SetPromiseUI64, iface) { @@ -46,5 +46,5 @@ Y_CPU_BENCHMARK(SetPromiseUI64, iface) { } Y_CPU_BENCHMARK(SetPromiseStroka, iface) { - TestSetPromise<TString>(iface, "test test test"); + TestSetPromise<TString>(iface, "test test test"); } diff --git a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp index 7417636864..f842d98ca2 100644 --- a/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp +++ b/library/cpp/threading/poor_man_openmp/thread_helper_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/yexception.h> Y_UNIT_TEST_SUITE(TestMP) { @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TestMP) { } }; - TString s; + TString s; try { NYmp::ParallelForStaticAutoChunk(0, 10, f); diff --git a/library/cpp/threading/queue/basic_ut.cpp b/library/cpp/threading/queue/basic_ut.cpp index 5f56f8583e..f6b8d0f810 100644 --- a/library/cpp/threading/queue/basic_ut.cpp +++ b/library/cpp/threading/queue/basic_ut.cpp @@ -4,10 +4,10 @@ #include "ut_helpers.h" -template <typename TQueueType> +template <typename TQueueType> class TQueueTestsInSingleThread: public TTestBase { private: - using TSelf = TQueueTestsInSingleThread<TQueueType>; + using TSelf = TQueueTestsInSingleThread<TQueueType>; using TLink = TIntrusiveLink; UNIT_TEST_SUITE_DEMANGLE(TSelf); @@ -18,7 +18,7 @@ private: public: void OnePushOnePop() { - TQueueType queue; + TQueueType queue; auto popped = queue.Pop(); UNIT_ASSERT_VALUES_EQUAL(popped, nullptr); @@ -33,7 +33,7 @@ public: }; void OnePushOnePop_Repeat1M() { - TQueueType queue; + TQueueType queue; TLink msg; auto popped = queue.Pop(); @@ -54,7 +54,7 @@ public: class TCycleThread: public ISimpleThread { public: void* ThreadProc() override { - TQueueType queue; + TQueueType queue; TLink msg; auto popped = queue.Pop(); UNIT_ASSERT_VALUES_EQUAL(popped, nullptr); @@ -71,7 +71,7 @@ public: } }; - TVector<TAutoPtr<TCycleThread>> cyclers; + TVector<TAutoPtr<TCycleThread>> cyclers; for (size_t i = 0; i < NUMBER_OF_THREADS; ++i) { cyclers.emplace_back(new TCycleThread); diff --git a/library/cpp/threading/queue/mpsc_read_as_filled.h b/library/cpp/threading/queue/mpsc_read_as_filled.h index be33ba5a58..de8f596833 100644 --- a/library/cpp/threading/queue/mpsc_read_as_filled.h +++ b/library/cpp/threading/queue/mpsc_read_as_filled.h @@ -544,7 +544,7 @@ namespace NThreading { using TBunchBase = TEmpty; template <typename TElem, typename... TRest> - using TContainer = TDeque<TElem, TRest...>; + using TContainer = TDeque<TElem, TRest...>; static constexpr bool DeleteItems = true; }; diff --git a/library/cpp/threading/queue/queue_ut.cpp b/library/cpp/threading/queue/queue_ut.cpp index 80eca147da..299025adcc 100644 --- a/library/cpp/threading/queue/queue_ut.cpp +++ b/library/cpp/threading/queue/queue_ut.cpp @@ -5,10 +5,10 @@ typedef void* TMsgLink; -template <typename TQueueType> +template <typename TQueueType> class TQueueTestProcs: public TTestBase { private: - UNIT_TEST_SUITE_DEMANGLE(TQueueTestProcs<TQueueType>); + UNIT_TEST_SUITE_DEMANGLE(TQueueTestProcs<TQueueType>); UNIT_TEST(Threads2_Push1M_Threads1_Pop2M) UNIT_TEST(Threads4_Push1M_Threads1_Pop4M) UNIT_TEST(Threads8_RndPush100K_Threads8_Queues) @@ -21,7 +21,7 @@ private: public: void Push1M_Pop1M() { - TQueueType queue; + TQueueType queue; TMsgLink msg = &queue; auto pmsg = queue.Pop(); @@ -41,17 +41,17 @@ public: } void Threads2_Push1M_Threads1_Pop2M() { - TQueueType queue; + TQueueType queue; class TPusherThread: public ISimpleThread { public: - TPusherThread(TQueueType& theQueue, char* start) - : Queue(theQueue) + TPusherThread(TQueueType& theQueue, char* start) + : Queue(theQueue) , Arg(start) { } - TQueueType& Queue; + TQueueType& Queue; char* Arg; void* ThreadProc() override { @@ -79,17 +79,17 @@ public: } void Threads4_Push1M_Threads1_Pop4M() { - TQueueType queue; + TQueueType queue; class TPusherThread: public ISimpleThread { public: - TPusherThread(TQueueType& theQueue, char* start) - : Queue(theQueue) + TPusherThread(TQueueType& theQueue, char* start) + : Queue(theQueue) , Arg(start) { } - TQueueType& Queue; + TQueueType& Queue; char* Arg; void* ThreadProc() override { @@ -122,17 +122,17 @@ public: template <size_t NUMBER_OF_PUSHERS, size_t NUMBER_OF_QUEUES> void ManyRndPush100K_ManyQueues() { - TQueueType queue[NUMBER_OF_QUEUES]; + TQueueType queue[NUMBER_OF_QUEUES]; class TPusherThread: public ISimpleThread { public: - TPusherThread(TQueueType* queues, char* start) + TPusherThread(TQueueType* queues, char* start) : Queues(queues) , Arg(start) { } - TQueueType* Queues; + TQueueType* Queues; char* Arg; void* ThreadProc() override { @@ -157,13 +157,13 @@ public: class TPopperThread: public ISimpleThread { public: - TPopperThread(TQueueType* theQueue, char* base) - : Queue(theQueue) + TPopperThread(TQueueType* theQueue, char* base) + : Queue(theQueue) , Base(base) { } - TQueueType* Queue; + TQueueType* Queue; char* Base; void* ThreadProc() override { @@ -197,8 +197,8 @@ public: } }; - TVector<TAutoPtr<TPopperThread>> poppers; - TVector<TAutoPtr<TPusherThread>> pushers; + TVector<TAutoPtr<TPopperThread>> poppers; + TVector<TAutoPtr<TPusherThread>> pushers; for (size_t i = 0; i < NUMBER_OF_QUEUES; ++i) { poppers.emplace_back(new TPopperThread(&queue[i], (char*)&queue)); diff --git a/library/cpp/threading/queue/unordered_ut.cpp b/library/cpp/threading/queue/unordered_ut.cpp index a43b7f520e..494cffcbe5 100644 --- a/library/cpp/threading/queue/unordered_ut.cpp +++ b/library/cpp/threading/queue/unordered_ut.cpp @@ -6,19 +6,19 @@ #include "ut_helpers.h" -template <typename TQueueType> +template <typename TQueueType> class TTestUnorderedQueue: public TTestBase { private: using TLink = TIntrusiveLink; - UNIT_TEST_SUITE_DEMANGLE(TTestUnorderedQueue<TQueueType>); + UNIT_TEST_SUITE_DEMANGLE(TTestUnorderedQueue<TQueueType>); UNIT_TEST(Push1M_Pop1M_Unordered) UNIT_TEST_SUITE_END(); public: void Push1M_Pop1M_Unordered() { constexpr int REPEAT = 1000000; - TQueueType queue; + TQueueType queue; TLink msg[REPEAT]; auto pmsg = queue.Pop(); @@ -28,7 +28,7 @@ public: queue.Push(&msg[i]); } - TVector<TLink*> popped; + TVector<TLink*> popped; popped.reserve(REPEAT); for (int i = 0; i < REPEAT; ++i) { popped.push_back((TLink*)queue.Pop()); @@ -44,17 +44,17 @@ public: } }; -template <typename TQueueType> +template <typename TQueueType> class TTestWeakQueue: public TTestBase { private: - UNIT_TEST_SUITE_DEMANGLE(TTestWeakQueue<TQueueType>); + UNIT_TEST_SUITE_DEMANGLE(TTestWeakQueue<TQueueType>); UNIT_TEST(Threads8_Rnd_Exchange) UNIT_TEST_SUITE_END(); public: template <ui16 COUNT = 48, ui32 MSG_COUNT = 10000> void ManyThreadsRndExchange() { - TQueueType queues[COUNT]; + TQueueType queues[COUNT]; class TWorker: public ISimpleThread { public: @@ -68,9 +68,9 @@ public: { } - TQueueType* Queues; + TQueueType* Queues; ui16 MineQueue; - TVector<uintptr_t> Received; + TVector<uintptr_t> Received; TAtomic* PushDone; void* ThreadProc() override { @@ -120,7 +120,7 @@ public: } }; - TVector<TAutoPtr<TWorker>> workers; + TVector<TAutoPtr<TWorker>> workers; TAtomic pushDone = 0; for (ui32 i = 0; i < COUNT; ++i) { @@ -128,7 +128,7 @@ public: workers.back()->Start(); } - TVector<uintptr_t> all; + TVector<uintptr_t> all; for (ui32 i = 0; i < COUNT; ++i) { workers[i]->Join(); all.insert(all.begin(), diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp index 174dde4bf7..4e2239c2d7 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp @@ -18,8 +18,8 @@ public: { } - TString DebugState = "?"; - TString DebugId = ""; + TString DebugState = "?"; + TString DebugId = ""; private: void* ThreadProc() noexcept override { Scheduler_.WorkerFunc(this); @@ -150,7 +150,7 @@ bool TTaskScheduler::Add(IRepeatedTaskRef task, TDuration period) { const bool debugOutput = false; -void TTaskScheduler::ChangeDebugState(TWorkerThread* thread, const TString& state) { +void TTaskScheduler::ChangeDebugState(TWorkerThread* thread, const TString& state) { if (!debugOutput) { Y_UNUSED(thread); Y_UNUSED(state); diff --git a/library/cpp/threading/task_scheduler/task_scheduler.h b/library/cpp/threading/task_scheduler/task_scheduler.h index df4da941a8..e2381c2b38 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.h +++ b/library/cpp/threading/task_scheduler/task_scheduler.h @@ -40,10 +40,10 @@ private: TWorkerThread* WaitingWorker = nullptr; }; - using TQueueType = TMultiMap<TInstant, TTaskHolder>; - using TQueueIterator = TQueueType::iterator; + using TQueueType = TMultiMap<TInstant, TTaskHolder>; + using TQueueIterator = TQueueType::iterator; private: - void ChangeDebugState(TWorkerThread* thread, const TString& state); + void ChangeDebugState(TWorkerThread* thread, const TString& state); void ChooseFromQueue(TQueueIterator& toWait); bool Wait(TWorkerThread* thread, TQueueIterator& toWait); @@ -52,12 +52,12 @@ private: bool IsStopped_ = false; TAtomic TaskCounter_ = 0; - TQueueType Queue_; + TQueueType Queue_; TCondVar CondVar_; TMutex Lock_; - TVector<TAutoPtr<TWorkerThread>> Workers_; + TVector<TAutoPtr<TWorkerThread>> Workers_; const size_t MaxTaskCount_; }; diff --git a/library/cpp/timezone_conversion/convert.cpp b/library/cpp/timezone_conversion/convert.cpp index 490bb4e270..4a690b6191 100644 --- a/library/cpp/timezone_conversion/convert.cpp +++ b/library/cpp/timezone_conversion/convert.cpp @@ -53,7 +53,7 @@ namespace NDatetime { } /* - TTimeZone GetTimeZone(const TString& name) { + TTimeZone GetTimeZone(const TString& name) { TTimeZone result; if (!cctz::load_time_zone(name, &result)) { ythrow yexception() << "Failed to load time zone " << name << ", " << result.name(); diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 4f5f57881c..bce2759dc1 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -127,7 +127,7 @@ namespace NUnicode { }; typedef std::pair<wchar32, TCombining> TSymbol; - typedef TVector<TSymbol> TBuffer; + typedef TVector<TSymbol> TBuffer; template <bool doCompose> class TCompositor; diff --git a/library/cpp/unicode/normalization/ut/normalization_ut.cpp b/library/cpp/unicode/normalization/ut/normalization_ut.cpp index 54d4940a26..dbccd0810d 100644 --- a/library/cpp/unicode/normalization/ut/normalization_ut.cpp +++ b/library/cpp/unicode/normalization/ut/normalization_ut.cpp @@ -8,8 +8,8 @@ Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { template <NUnicode::ENormalization NormType> void TestInit() { NUnicode::TNormalizer<NormType> normalizer; - TString s("упячка detected"); - TUtf16String w; + TString s("упячка detected"); + TUtf16String w; UTF8ToWide(s, w); normalizer.Normalize(w); } diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index 800d1f19fe..4a8993a95b 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -39,7 +39,7 @@ static inline void AppendUtf32ToWide(const ui32* in, size_t len, TUtf16String& o } } -TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { +TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { TVector<ui32> in32; AppendWideToUtf32(in16, in32); size_t outlen = in32.size(); @@ -57,7 +57,7 @@ TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { return out; } -TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out16) { +TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out16) { size_t outlen = in.size(); TVector<ui32> out32(outlen); @@ -79,7 +79,7 @@ namespace { }; } -TString HostNameToPunycode(const TWtringBuf& unicodeHost) { +TString HostNameToPunycode(const TWtringBuf& unicodeHost) { TVector<ui32> in32; AppendWideToUtf32(unicodeHost, in32); in32.push_back(0); @@ -91,7 +91,7 @@ TString HostNameToPunycode(const TWtringBuf& unicodeHost) { return out.Data; } -TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { +TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { if (!IsStringASCII(punycodeHost.begin(), punycodeHost.end())) ythrow TPunycodeError() << "Non-ASCII punycode input"; @@ -105,12 +105,12 @@ TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { int rc = idna_to_unicode_4z4z(in32.begin(), &out.Data, 0); CheckIdnaResult(rc); - TUtf16String decoded; + TUtf16String decoded; AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); return decoded; } -TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { +TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { try { return HostNameToPunycode(unicodeHost); } catch (const TPunycodeError&) { @@ -118,7 +118,7 @@ TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { } } -TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost) { +TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost) { try { return PunycodeToHostName(punycodeHost); } catch (const TPunycodeError&) { diff --git a/library/cpp/unicode/punycode/punycode.h b/library/cpp/unicode/punycode/punycode.h index af4acc25c1..868e473253 100644 --- a/library/cpp/unicode/punycode/punycode.h +++ b/library/cpp/unicode/punycode/punycode.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/yexception.h> @@ -9,17 +9,17 @@ // Raw strings encoder/decoder: does not prepend with ACE prefix ("xn--"), // does not limit input length. Throws TPunycodeError on any internal error. // Returned strbuf points to @out data. -TStringBuf WideToPunycode(const TWtringBuf& in, TString& out); -TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out); +TStringBuf WideToPunycode(const TWtringBuf& in, TString& out); +TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out); -inline TString WideToPunycode(const TWtringBuf& in) { - TString out; +inline TString WideToPunycode(const TWtringBuf& in) { + TString out; WideToPunycode(in, out); return out; } -inline TUtf16String PunycodeToWide(const TStringBuf& in) { - TUtf16String out; +inline TUtf16String PunycodeToWide(const TStringBuf& in) { + TUtf16String out; PunycodeToWide(in, out); return out; } @@ -29,12 +29,12 @@ inline TUtf16String PunycodeToWide(const TStringBuf& in) { // Labels containing non-ASCII characters are prefixed with ACE prefix ("xn--"). // Limits maximal encoded domain label length to IDNA_LABEL_MAX_LENGTH (255 by default). // Throws TPunycodeError on failure. -TString HostNameToPunycode(const TWtringBuf& unicodeHost); -TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost); +TString HostNameToPunycode(const TWtringBuf& unicodeHost); +TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost); // Robust versions: on failure return original input, converted to/from UTF8 -TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost); -TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost); +TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost); +TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost); // True if @host looks like punycode domain label sequence, // containing at least one ACE-prefixed label. diff --git a/library/cpp/unicode/punycode/punycode_ut.cpp b/library/cpp/unicode/punycode/punycode_ut.cpp index 97271cf0d8..bb192169d7 100644 --- a/library/cpp/unicode/punycode/punycode_ut.cpp +++ b/library/cpp/unicode/punycode/punycode_ut.cpp @@ -11,10 +11,10 @@ namespace { } Y_UNIT_TEST_SUITE(TPunycodeTest) { - static bool TestRaw(const TString& utf8, const TString& punycode) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestRaw(const TString& utf8, const TString& punycode) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; return HasSameBuffer(WideToPunycode(unicode, buf1), buf1) && buf1 == punycode && HasSameBuffer(PunycodeToWide(punycode, buf2), buf2) && buf2 == unicode && WideToPunycode(unicode) == punycode && PunycodeToWide(punycode) == unicode; } @@ -48,25 +48,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { UNIT_ASSERT_EXCEPTION(PunycodeToWide("-"), TPunycodeError); { - TString longIn; + TString longIn; for (size_t i = 0; i < 1024; ++i) longIn += "Qй"; - TString longOut = "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ-lo11fbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; + TString longOut = "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ-lo11fbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; UNIT_ASSERT(TestRaw(longIn, longOut)); } } - static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; //Cerr << "Testing " << utf8 << Endl; return HostNameToPunycode(unicode) == punycode && HostNameToPunycode(UTF8ToWide(punycode)) == punycode // repeated encoding should give same result && PunycodeToHostName(punycode) == unicode && CanBePunycodeHostName(punycode) == canBePunycode; } - static bool TestForced(const TString& bad) { + static bool TestForced(const TString& bad) { return ForceHostNameToPunycode(UTF8ToWide(bad)) == bad && ForcePunycodeToHostName(bad) == UTF8ToWide(bad); } @@ -89,25 +89,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { { // non-ascii - TString bad = "президент.рф"; + TString bad = "президент.рф"; UNIT_ASSERT_EXCEPTION(PunycodeToHostName("президент.рф"), TPunycodeError); UNIT_ASSERT(ForcePunycodeToHostName(bad) == UTF8ToWide(bad)); } { // too long domain label - TString bad(500, 'a'); + TString bad(500, 'a'); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); // but can decode it } { // already has ACE prefix - TString bad("xn--яндекс.xn--рф"); + TString bad("xn--яндекс.xn--рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } { // empty non-root domain is not allowed (?) - TString bad(".яндекс.рф"); + TString bad(".яндекс.рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } diff --git a/library/cpp/uri/other.h b/library/cpp/uri/other.h index 7aec22e77b..c2f5ec794e 100644 --- a/library/cpp/uri/other.h +++ b/library/cpp/uri/other.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> // Some functions for inverted url representation // No scheme cut-off, no 80th port normalization @@ -14,7 +14,7 @@ void UnTrspChars(const char* s, char* d); void InvertDomain(char* begin, char* end); -inline TString& InvertDomain(TString& url) { +inline TString& InvertDomain(TString& url) { InvertDomain(url.begin(), url.begin() + url.size()); return url; } @@ -25,7 +25,7 @@ inline void InvertUrl(char* url) { InvertUrl(url, url + strlen(url)); } -inline TString& InvertUrl(TString& url) { +inline TString& InvertUrl(TString& url) { InvertUrl(url.begin(), url.begin() + url.size()); return url; } @@ -36,7 +36,7 @@ inline void RevertUrl(char* url) { RevertUrl(url, url + strlen(url)); } -inline TString& RevertUrl(TString& url) { +inline TString& RevertUrl(TString& url) { RevertUrl(url.begin(), url.begin() + url.size()); return url; } diff --git a/library/cpp/uri/uri.h b/library/cpp/uri/uri.h index 3b6c19fe4a..c8d0828572 100644 --- a/library/cpp/uri/uri.h +++ b/library/cpp/uri/uri.h @@ -7,7 +7,7 @@ #include <util/generic/buffer.h> #include <util/generic/ptr.h> #include <util/generic/singleton.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/memory/alloc.h> #include <util/stream/mem.h> #include <util/stream/output.h> diff --git a/library/cpp/uri/uri_ut.h b/library/cpp/uri/uri_ut.h index f8ac6e4092..2089edf7bf 100644 --- a/library/cpp/uri/uri_ut.h +++ b/library/cpp/uri/uri_ut.h @@ -22,7 +22,7 @@ namespace NUri { } #define URL_MSG(url1, url2, cmp) \ - (TString("[") + url1.PrintS() + ("] " cmp " [") + url2.PrintS() + "]") + (TString("[") + url1.PrintS() + ("] " cmp " [") + url2.PrintS() + "]") #define URL_EQ(url1, url2) \ UNIT_ASSERT_EQUAL_C(url, url2, URL_MSG(url1, url2, "!=")) #define URL_NEQ(url1, url2) \ diff --git a/library/cpp/uri/ut/ya.make b/library/cpp/uri/ut/ya.make index b2b2c1291a..51a7ebf1b2 100644 --- a/library/cpp/uri/ut/ya.make +++ b/library/cpp/uri/ut/ya.make @@ -4,7 +4,7 @@ OWNER(leo) NO_OPTIMIZE() -NO_WSHADOW() +NO_WSHADOW() PEERDIR( library/cpp/html/entity diff --git a/library/cpp/xml/document/README b/library/cpp/xml/document/README index b2649523d8..164d3a1c9c 100644 --- a/library/cpp/xml/document/README +++ b/library/cpp/xml/document/README @@ -16,9 +16,9 @@ The standard way to use it is as follows: using namespace NXml; TConstNode& node = nodes[i]; // query node - TString name = node.Name(); - TString lang = node.Attr<TString>("lang"); - TString text = node.Value<TString>(); + TString name = node.Name(); + TString lang = node.Attr<TString>("lang"); + TString text = node.Value<TString>(); TConstNode child = node.GetFirstChild(""); // edit node TNode node = child.ConstCast(); @@ -34,9 +34,9 @@ The standard way to use it is as follows: // copy node's subtree from one document to another place.AddChild(xml.Root()); // save (render) single element - TString modifiedNode = place.ToString(); + TString modifiedNode = place.ToString(); // save whole document with optional encoding - TString modifiedDoc = xml2.ToString("ISO-8559-1"); + TString modifiedDoc = xml2.ToString("ISO-8559-1"); See xml-document_ut.cpp for more examples. diff --git a/library/cpp/xml/document/node-attr.h b/library/cpp/xml/document/node-attr.h index 6e74403943..6321fcb267 100644 --- a/library/cpp/xml/document/node-attr.h +++ b/library/cpp/xml/document/node-attr.h @@ -28,7 +28,7 @@ namespace NXml { template <> inline void TNode::AttrInternal(TCharPtr& value, TString& res, TStringBuf /*errContext*/) const { - TString tmp(CAST2CHAR(value.Get())); + TString tmp(CAST2CHAR(value.Get())); res.swap(tmp); } diff --git a/library/cpp/xml/document/xml-document-decl.h b/library/cpp/xml/document/xml-document-decl.h index bfda1fb7e6..b481d8164c 100644 --- a/library/cpp/xml/document/xml-document-decl.h +++ b/library/cpp/xml/document/xml-document-decl.h @@ -2,7 +2,7 @@ #include <library/cpp/string_utils/ztstrbuf/ztstrbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> #include <util/stream/output.h> #include <util/stream/str.h> @@ -32,7 +32,7 @@ namespace NXml { * @param src: source type: File | String | RootName * throws if file not found or cannot be parsed */ - TDocument(const TString& source, Source type = File); + TDocument(const TString& source, Source type = File); public: TDocument(const TDocument& that) = delete; @@ -71,7 +71,7 @@ namespace NXml { } private: - void ParseFile(const TString& file); + void ParseFile(const TString& file); void ParseString(TZtStringBuf xml); TDocument(TDocHolder doc) @@ -83,10 +83,10 @@ namespace NXml { }; struct TNamespaceForXPath { - TString Prefix; - TString Url; + TString Prefix; + TString Url; }; - typedef TVector<TNamespaceForXPath> TNamespacesForXPath; + typedef TVector<TNamespaceForXPath> TNamespacesForXPath; class TConstNodes { private: @@ -411,12 +411,12 @@ namespace NXml { /** * get node name */ - TString Name() const; + TString Name() const; /** * get node xpath */ - TString Path() const; + TString Path() const; /** * get node xml representation @@ -662,7 +662,7 @@ namespace NXml { /** * get node name */ - TString Name() const { + TString Name() const { return ActualNode.Name(); } diff --git a/library/cpp/xml/document/xml-document.cpp b/library/cpp/xml/document/xml-document.cpp index 18a554d732..17e7f78424 100644 --- a/library/cpp/xml/document/xml-document.cpp +++ b/library/cpp/xml/document/xml-document.cpp @@ -270,7 +270,7 @@ namespace NXml { return TNode(); } - TString TNode::Name() const { + TString TNode::Name() const { if (IsNull()) THROW(XmlException, "Node is null"); diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp index 9f537b75c4..c56d211059 100644 --- a/library/cpp/xml/document/xml-document_ut.cpp +++ b/library/cpp/xml/document/xml-document_ut.cpp @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(b.Attr<bool>("correct"), true); NXml::TConstNode text = root.Node("text"); - UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); + UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); } Y_UNIT_TEST(SerializeString) { NXml::TDocument xml("frob", NXml::TDocument::RootName); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { authors.AddChild("zarf").SetValue("Andrew Plotkin"); authors.AddChild("emshort", "Emily Short"); - TString data = xml.ToString("utf-8"); + TString data = xml.ToString("utf-8"); UNIT_ASSERT_EQUAL(data, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<frob xyzzy=\"Frobozz\" kulness=\"0.3\" timelimit=\"3\">\n" " <authors>\n" @@ -57,9 +57,9 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "</frob>\n"); // check default utf8 output with ru { - NXml::TDocument xml2("frob", NXml::TDocument::RootName); - xml2.Root().SetAttr("xyzzy", "привет =)"); - UNIT_ASSERT_VALUES_EQUAL(xml2.ToString(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + NXml::TDocument xml2("frob", NXml::TDocument::RootName); + xml2.Root().SetAttr("xyzzy", "привет =)"); + UNIT_ASSERT_VALUES_EQUAL(xml2.ToString(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<frob xyzzy=\"привет =)\"/>\n"); } } @@ -83,13 +83,13 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { UNIT_ASSERT_EQUAL(b.Attr<bool>("correct"), true); TConstNode text = root.Node("h:text", false, nss); - UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); + UNIT_ASSERT_EQUAL(text.Value<TString>(), "Некоторый текст"); // For performance you can create xpath context once using nss and pass it. TXPathContextPtr ctxt = root.CreateXPathContext(nss); UNIT_ASSERT(root.Node("text", true, *ctxt).IsNull()); UNIT_ASSERT_EXCEPTION(root.Node("text", false, *ctxt), yexception); - UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст"); + UNIT_ASSERT_EQUAL(root.Node("h:text", false, *ctxt).Value<TString>(), "Некоторый текст"); } Y_UNIT_TEST(XmlNodes) { using namespace NXml; @@ -97,34 +97,34 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<root>qq<a><b>asdfg</b></a>ww<c></c></root>", NXml::TDocument::String); TNode root = xml.Root(); - UNIT_ASSERT_EQUAL(root.Value<TString>(), "qqasdfgww"); + UNIT_ASSERT_EQUAL(root.Value<TString>(), "qqasdfgww"); TConstNode node = root.FirstChild(); UNIT_ASSERT_EQUAL(node.IsText(), true); - UNIT_ASSERT_EQUAL(node.Value<TString>(), "qq"); + UNIT_ASSERT_EQUAL(node.Value<TString>(), "qq"); node = node.NextSibling(); UNIT_ASSERT_EQUAL(node.IsText(), false); UNIT_ASSERT_EQUAL(node.Name(), "a"); - UNIT_ASSERT_EQUAL(node.Value<TString>(), "asdfg"); + UNIT_ASSERT_EQUAL(node.Value<TString>(), "asdfg"); node = node.NextSibling(); UNIT_ASSERT_EQUAL(node.IsText(), true); - UNIT_ASSERT_EQUAL(node.Value<TString>(), "ww"); + UNIT_ASSERT_EQUAL(node.Value<TString>(), "ww"); node = node.NextSibling(); UNIT_ASSERT_EQUAL(node.IsText(), false); UNIT_ASSERT_EQUAL(node.Name(), "c"); - UNIT_ASSERT_EQUAL(node.Value<TString>(), ""); + UNIT_ASSERT_EQUAL(node.Value<TString>(), ""); node = node.NextSibling(); UNIT_ASSERT_EQUAL(node.IsNull(), true); TStringStream iterLog; for (const auto& node2 : root.Nodes("/root/*")) { - iterLog << node2.Name() << ';'; + iterLog << node2.Name() << ';'; } UNIT_ASSERT_STRINGS_EQUAL(iterLog.Str(), "a;c;"); // get only element nodes, ignore text nodes with empty "name" param - node = root.FirstChild(TString()); + node = root.FirstChild(TString()); UNIT_ASSERT_EQUAL(node.IsText(), false); UNIT_ASSERT_EQUAL(node.Name(), "a"); - node = node.NextSibling(TString()); + node = node.NextSibling(TString()); UNIT_ASSERT_EQUAL(node.IsText(), false); UNIT_ASSERT_EQUAL(node.Name(), "c"); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { node = root.NextSibling("unknownnode"); UNIT_ASSERT_EQUAL(node.IsNull(), true); UNIT_ASSERT_EXCEPTION(node.Name(), yexception); - UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception); + UNIT_ASSERT_EXCEPTION(node.Value<TString>(), yexception); UNIT_ASSERT_EXCEPTION(node.IsText(), yexception); } Y_UNIT_TEST(DefVal) { @@ -173,14 +173,14 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { "<a>second</a></root>", NXml::TDocument::String); UNIT_ASSERT_EXCEPTION(xml.Root().Node("/root/a/@x"), yexception); - UNIT_ASSERT_STRINGS_EQUAL(xml.Root().Node("/root/a").Value<TString>(), "first"); + UNIT_ASSERT_STRINGS_EQUAL(xml.Root().Node("/root/a").Value<TString>(), "first"); } Y_UNIT_TEST(CopyNode) { using namespace NXml; // default-construct empty node TNode empty; // put to container - TMap<int, TNode> nmap; + TMap<int, TNode> nmap; nmap[2]; // do copy @@ -255,11 +255,11 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) { // We can use root node context for xpath evaluation in any node TConstNode c1 = b.Node("c", false, *rootCtxt); - UNIT_ASSERT_EQUAL(c1.Value<TString>(), "Hello, world!"); + UNIT_ASSERT_EQUAL(c1.Value<TString>(), "Hello, world!"); TXPathContextPtr bCtxt = b.CreateXPathContext(); TConstNode c2 = b.Node("c", false, *bCtxt); - UNIT_ASSERT_EQUAL(c2.Value<TString>(), "Hello, world!"); + UNIT_ASSERT_EQUAL(c2.Value<TString>(), "Hello, world!"); // Mixing contexts from different documents is forbidden TDocument otherXml("<root></root>", TDocument::String); diff --git a/library/cpp/xml/document/xml-textreader.cpp b/library/cpp/xml/document/xml-textreader.cpp index b946f1fbf2..f7d64670c8 100644 --- a/library/cpp/xml/document/xml-textreader.cpp +++ b/library/cpp/xml/document/xml-textreader.cpp @@ -27,15 +27,15 @@ namespace NXml { return BoolResult(xmlTextReaderRead(Impl.Get())); } - TString TTextReader::ReadInnerXml() const { + TString TTextReader::ReadInnerXml() const { return TempStringOrEmptyResult(xmlTextReaderReadInnerXml(Impl.Get())); } - TString TTextReader::ReadOuterXml() const { + TString TTextReader::ReadOuterXml() const { return TempStringOrEmptyResult(xmlTextReaderReadOuterXml(Impl.Get())); } - TString TTextReader::ReadString() const { + TString TTextReader::ReadString() const { return TempStringOrEmptyResult(xmlTextReaderReadString(Impl.Get())); } @@ -109,7 +109,7 @@ namespace NXml { } } - TString TTextReader::GetAttribute(int number) const { + TString TTextReader::GetAttribute(int number) const { return TempStringResult(xmlTextReaderGetAttributeNo(Impl.Get(), number)); } @@ -166,7 +166,7 @@ namespace NXml { } // Callback for xmlReaderForIO() to read more data. - // It is almost "noexcept" (std::bad_alloc may happen when saving exception message to new TString). + // It is almost "noexcept" (std::bad_alloc may happen when saving exception message to new TString). // Waiting for std::exception_ptr and std::rethrow_exception from C++11 in Arcadia to make it really "noexcept". int TTextReader::ReadFromInputStreamCallback(void* context, char* buffer, int len) { Y_ASSERT(len >= 0); @@ -251,7 +251,7 @@ namespace NXml { return; } - const TString message = ErrorBuffer.Str(); + const TString message = ErrorBuffer.Str(); ErrorBuffer.clear(); IsError = false; @@ -298,16 +298,16 @@ namespace NXml { return (value != nullptr) ? TStringBuf(CAST2CHAR(value)) : TStringBuf(); } - TString TTextReader::TempStringResult(TCharPtr value) const { + TString TTextReader::TempStringResult(TCharPtr value) const { if (Y_UNLIKELY(value == nullptr)) { ThrowException(); } - return TString(CAST2CHAR(value.Get())); + return TString(CAST2CHAR(value.Get())); } - TString TTextReader::TempStringOrEmptyResult(TCharPtr value) const { + TString TTextReader::TempStringOrEmptyResult(TCharPtr value) const { CheckForExceptions(); - return (value != nullptr) ? TString(CAST2CHAR(value.Get())) : TString(); + return (value != nullptr) ? TString(CAST2CHAR(value.Get())) : TString(); } struct TTextReader::TDeleter { diff --git a/library/cpp/xml/document/xml-textreader.h b/library/cpp/xml/document/xml-textreader.h index ab4c329d26..f0cba3182c 100644 --- a/library/cpp/xml/document/xml-textreader.h +++ b/library/cpp/xml/document/xml-textreader.h @@ -10,7 +10,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <functional> #include <util/stream/input.h> #include <util/stream/str.h> @@ -91,21 +91,21 @@ namespace NXml { * @return A string containing the XML content, or an empty string * if the current node is neither an element nor attribute, or has no child nodes */ - TString ReadInnerXml() const; + TString ReadInnerXml() const; /** * Reads the current node and its contents, including child nodes and markup. * @return A string containing the XML content, or an empty string * if the current node is neither an element nor attribute */ - TString ReadOuterXml() const; + TString ReadOuterXml() const; /** * Reads the contents of an element or a text node as a string. * @return A string containing the contents of the Element or Text node, * or an empty string if the reader is positioned on any other type of node */ - TString ReadString() const; + TString ReadString() const; /** * Parses an attribute value into one or more Text and EntityReference nodes. @@ -216,7 +216,7 @@ namespace NXml { * Provides the value of the attribute with the specified index relative to the containing element. * @param number the zero-based index of the attribute relative to the containing element */ - TString GetAttribute(int number) const; + TString GetAttribute(int number) const; /** * Provides the value of the attribute with the specified qualified name. @@ -309,8 +309,8 @@ namespace NXml { char CharResult(int value) const; TStringBuf ConstStringResult(const xmlChar* value) const; TStringBuf ConstStringOrEmptyResult(const xmlChar* value) const; - TString TempStringResult(TCharPtr value) const; - TString TempStringOrEmptyResult(TCharPtr value) const; + TString TempStringResult(TCharPtr value) const; + TString TempStringOrEmptyResult(TCharPtr value) const; private: IInputStream& Stream; diff --git a/library/cpp/xml/document/xml-textreader_ut.cpp b/library/cpp/xml/document/xml-textreader_ut.cpp index 6232dfe47e..32558b95e6 100644 --- a/library/cpp/xml/document/xml-textreader_ut.cpp +++ b/library/cpp/xml/document/xml-textreader_ut.cpp @@ -10,10 +10,10 @@ namespace { /** * Simple wrapper around the xmlTextReader wrapper */ - void ParseXml(const TString& xmlData, + void ParseXml(const TString& xmlData, std::function<void(NXml::TConstNode)> nodeHandlerFunc, - const TString& localName, - const TString& namespaceUri = TString()) { + const TString& localName, + const TString& namespaceUri = TString()) { TStringInput in(xmlData); NXml::TTextReader reader(in); @@ -31,7 +31,7 @@ namespace { Y_UNIT_TEST_SUITE(TestXmlTextReader) { Y_UNIT_TEST(BasicExample) { - const TString xml = "<?xml version=\"1.0\"?>\n" + const TString xml = "<?xml version=\"1.0\"?>\n" "<example toto=\"1\">\n" " <examplechild id=\"1\">\n" " <child_of_child/>\n" @@ -49,21 +49,21 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { struct TItem { int Depth; ENT Type; - TString Name; - TString Attrs; - TString Value; + TString Name; + TString Attrs; + TString Value; }; - TVector<TItem> found; - TVector<TString> msgs; + TVector<TItem> found; + TVector<TString> msgs; while (reader.Read()) { // dump attributes as "k1: v1, k2: v2, ..." - TVector<TString> kv; + TVector<TString> kv; if (reader.HasAttributes()) { reader.MoveToFirstAttribute(); do { - kv.push_back(TString::Join(reader.GetName(), ": ", reader.GetValue())); + kv.push_back(TString::Join(reader.GetName(), ": ", reader.GetValue())); } while (reader.MoveToNextAttribute()); reader.MoveToElement(); } @@ -71,13 +71,13 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { found.push_back(TItem{ reader.GetDepth(), reader.GetNodeType(), - TString(reader.GetName()), + TString(reader.GetName()), JoinSeq(", ", kv), - reader.HasValue() ? TString(reader.GetValue()) : TString(), + reader.HasValue() ? TString(reader.GetValue()) : TString(), }); } - const TVector<TItem> expected = { + const TVector<TItem> expected = { TItem{0, ENT::Element, "example", "toto: 1", ""}, TItem{1, ENT::SignificantWhitespace, "#text", "", "\n "}, TItem{1, ENT::Element, "examplechild", "id: 1", ""}, @@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { } } - const TString GEODATA = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + const TString GEODATA = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<root>" "" " <country id=\"225\">" @@ -136,22 +136,22 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { Y_UNIT_TEST(ParseXmlSimple) { struct TCountry { - TString Name; - TVector<TString> Cities; + TString Name; + TVector<TString> Cities; }; - THashMap<int, TCountry> data; + THashMap<int, TCountry> data; auto handler = [&data](NXml::TConstNode node) { const int id = node.Attr<int>("id"); TCountry& c = data[id]; - c.Name = node.FirstChild("name").Value<TString>(); + c.Name = node.FirstChild("name").Value<TString>(); const NXml::TConstNodes cityNodes = node.Nodes("cities/city"); for (auto cityNode : cityNodes) { - c.Cities.push_back(cityNode.Value<TString>()); + c.Cities.push_back(cityNode.Value<TString>()); } }; @@ -180,10 +180,10 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { } Y_UNIT_TEST(ParseXmlDeepLevel) { - TVector<TString> cities; + TVector<TString> cities; auto handler = [&cities](NXml::TConstNode node) { - cities.push_back(node.Value<TString>()); + cities.push_back(node.Value<TString>()); }; ParseXml(GEODATA, handler, "city"); @@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EXCEPTION(ParseXml("<root><a id=\"1\"></a><a id=\"2></a></root>", handler, "a"), yexception); } - const TString BACKA = // UTF-8 encoding is used implicitly + const TString BACKA = // UTF-8 encoding is used implicitly "<Companies" " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" " xmlns=\"http://maps.yandex.ru/backa/1.x\"" @@ -259,18 +259,18 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { TNS{"xal", "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"}}; int count = 0; - THashMap<TString, TString> positions; - THashMap<TString, TString> addresses; + THashMap<TString, TString> positions; + THashMap<TString, TString> addresses; auto handler = [&](NXml::TConstNode node) { count++; - const auto id = node.Attr<TString>("id"); + const auto id = node.Attr<TString>("id"); NXml::TXPathContextPtr ctxt = node.CreateXPathContext(ns); const NXml::TConstNode location = node.Node("b:Geo/b:Location", false, *ctxt); - positions[id] = location.Node("gml:pos", false, *ctxt).Value<TString>(); - addresses[id] = node.Node("b:Geo/xal:AddressDetails/xal:Country/xal:AddressLine", false, *ctxt).Value<TString>(); + positions[id] = location.Node("gml:pos", false, *ctxt).Value<TString>(); + addresses[id] = node.Node("b:Geo/xal:AddressDetails/xal:Country/xal:AddressLine", false, *ctxt).Value<TString>(); }; ParseXml(BACKA, handler, "Company"); diff --git a/library/cpp/xml/init/init.cpp b/library/cpp/xml/init/init.cpp index aa96c2dd31..a399211393 100644 --- a/library/cpp/xml/init/init.cpp +++ b/library/cpp/xml/init/init.cpp @@ -28,7 +28,7 @@ namespace { xmlNewCharEncodingHandler("windows-1251", CharEncodingInput, nullptr); } - inline ~TLibXml2() { + inline ~TLibXml2() { xmlCleanupParser(); } }; diff --git a/library/cpp/xml/init/ptr.h b/library/cpp/xml/init/ptr.h index 7387c7cc40..6fc431787a 100644 --- a/library/cpp/xml/init/ptr.h +++ b/library/cpp/xml/init/ptr.h @@ -11,7 +11,7 @@ template <class T, void (*DestroyFun)(T*)> struct TFunctionDestroy { - static inline void Destroy(T* t) noexcept { + static inline void Destroy(T* t) noexcept { if (t) DestroyFun(t); } diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index b39e070718..d2deeeb764 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -111,7 +111,7 @@ TNode::TNode(const std::string& s) : Value_(TString(s)) { } -TNode::TNode(TString s) +TNode::TNode(TString s) : Value_(std::move(s)) { } @@ -292,7 +292,7 @@ TNode::EType TNode::GetType() const }, Value_); } -const TString& TNode::AsString() const +const TString& TNode::AsString() const { CheckType(String); return std::get<TString>(Value_); @@ -322,25 +322,25 @@ bool TNode::AsBool() const return std::get<bool>(Value_); } -const TNode::TListType& TNode::AsList() const +const TNode::TListType& TNode::AsList() const { CheckType(List); return std::get<TListType>(Value_); } -const TNode::TMapType& TNode::AsMap() const +const TNode::TMapType& TNode::AsMap() const { CheckType(Map); return std::get<TMapType>(Value_); } -TNode::TListType& TNode::AsList() +TNode::TListType& TNode::AsList() { CheckType(List); return std::get<TListType>(Value_); } -TNode::TMapType& TNode::AsMap() +TNode::TMapType& TNode::AsMap() { CheckType(Map); return std::get<TMapType>(Value_); @@ -371,22 +371,22 @@ bool TNode::UncheckedAsBool() const noexcept return std::get<bool>(Value_); } -const TNode::TListType& TNode::UncheckedAsList() const noexcept +const TNode::TListType& TNode::UncheckedAsList() const noexcept { return std::get<TListType>(Value_); } -const TNode::TMapType& TNode::UncheckedAsMap() const noexcept +const TNode::TMapType& TNode::UncheckedAsMap() const noexcept { return std::get<TMapType>(Value_); } -TNode::TListType& TNode::UncheckedAsList() noexcept +TNode::TListType& TNode::UncheckedAsList() noexcept { return std::get<TListType>(Value_); } -TNode::TMapType& TNode::UncheckedAsMap() noexcept +TNode::TMapType& TNode::UncheckedAsMap() noexcept { return std::get<TMapType>(Value_); } @@ -526,7 +526,7 @@ const TNode& TNode::operator[](const TStringBuf key) const CheckType(Map); static TNode notFound; const auto& map = std::get<TMapType>(Value_); - TMapType::const_iterator i = map.find(key); + TMapType::const_iterator i = map.find(key); if (i == map.end()) { return notFound; } else { @@ -829,7 +829,7 @@ void TNode::CheckType(EType type) const void TNode::AssureMap() { if (std::holds_alternative<TUndefined>(Value_)) { - Value_ = TMapType(); + Value_ = TMapType(); } else { CheckType(Map); } @@ -838,7 +838,7 @@ void TNode::AssureMap() void TNode::AssureList() { if (std::holds_alternative<TUndefined>(Value_)) { - Value_ = TListType(); + Value_ = TListType(); } else { CheckType(List); } @@ -847,7 +847,7 @@ void TNode::AssureList() void TNode::CreateAttributes() { Attributes_ = MakeHolder<TNode>(); - Attributes_->Value_ = TMapType(); + Attributes_->Value_ = TMapType(); } void TNode::Save(IOutputStream* out) const diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h index 5f90f95df0..c82e846adf 100644 --- a/library/cpp/yson/node/node.h +++ b/library/cpp/yson/node/node.h @@ -45,8 +45,8 @@ public: Null = 8 /*"null"*/, }; - using TListType = TVector<TNode>; - using TMapType = THashMap<TString, TNode>; + using TListType = TVector<TNode>; + using TMapType = THashMap<TString, TNode>; private: struct TNull { @@ -62,9 +62,9 @@ private: i64, ui64, double, - TString, - TListType, - TMapType, + TString, + TListType, + TMapType, TNull, TUndefined >; @@ -76,7 +76,7 @@ public: TNode(TStringBuf s); explicit TNode(std::string_view s); explicit TNode(const std::string& s); - TNode(TString s); + TNode(TString s); TNode(int i); //this case made speccially for prevent mess cast of EType into TNode through TNode(int) constructor @@ -139,25 +139,25 @@ public: EType GetType() const; - const TString& AsString() const; + const TString& AsString() const; i64 AsInt64() const; ui64 AsUint64() const; double AsDouble() const; bool AsBool() const; - const TListType& AsList() const; - const TMapType& AsMap() const; - TListType& AsList(); - TMapType& AsMap(); + const TListType& AsList() const; + const TMapType& AsMap() const; + TListType& AsList(); + TMapType& AsMap(); const TString& UncheckedAsString() const noexcept; i64 UncheckedAsInt64() const noexcept; ui64 UncheckedAsUint64() const noexcept; double UncheckedAsDouble() const noexcept; bool UncheckedAsBool() const noexcept; - const TListType& UncheckedAsList() const noexcept; - const TMapType& UncheckedAsMap() const noexcept; - TListType& UncheckedAsList() noexcept; - TMapType& UncheckedAsMap() noexcept; + const TListType& UncheckedAsList() const noexcept; + const TMapType& UncheckedAsMap() const noexcept; + TListType& UncheckedAsList() noexcept; + TMapType& UncheckedAsMap() noexcept; // integer types cast // makes overflow checks diff --git a/library/cpp/yson/node/node_builder.cpp b/library/cpp/yson/node/node_builder.cpp index b4431bc77a..25fcb0f1f8 100644 --- a/library/cpp/yson/node/node_builder.cpp +++ b/library/cpp/yson/node/node_builder.cpp @@ -61,7 +61,7 @@ void TNodeBuilder::OnBeginMap() void TNodeBuilder::OnKeyedItem(TStringBuf key) { - Stack_.push(&(*Stack_.top())[TString(key)]); + Stack_.push(&(*Stack_.top())[TString(key)]); } void TNodeBuilder::OnEndMap() diff --git a/library/cpp/yson/node/node_builder.h b/library/cpp/yson/node/node_builder.h index 69800016e0..0190870f91 100644 --- a/library/cpp/yson/node/node_builder.h +++ b/library/cpp/yson/node/node_builder.h @@ -35,7 +35,7 @@ public: void OnNode(TNode node); private: - TStack<TNode*> Stack_; + TStack<TNode*> Stack_; private: inline void AddNode(TNode node, bool pop); diff --git a/library/cpp/yson/node/node_visitor.cpp b/library/cpp/yson/node/node_visitor.cpp index 899fbfa02a..69a66cc4ed 100644 --- a/library/cpp/yson/node/node_visitor.cpp +++ b/library/cpp/yson/node/node_visitor.cpp @@ -112,7 +112,7 @@ void TNodeVisitor::VisitBool(const TNode& node) Consumer_->OnBooleanScalar(node.AsBool()); } -void TNodeVisitor::VisitList(const TNode::TListType& nodeList) +void TNodeVisitor::VisitList(const TNode::TListType& nodeList) { Consumer_->OnBeginList(); size_t index = 0; @@ -128,7 +128,7 @@ void TNodeVisitor::VisitList(const TNode::TListType& nodeList) Consumer_->OnEndList(); } -void TNodeVisitor::VisitMap(const TNode::TMapType& nodeMap) +void TNodeVisitor::VisitMap(const TNode::TMapType& nodeMap) { Consumer_->OnBeginMap(); Iterate(nodeMap, SortMapKeys_, [&](const std::pair<TString, TNode>& item) { diff --git a/library/cpp/yson/node/node_visitor.h b/library/cpp/yson/node/node_visitor.h index db25832309..927df5d9e7 100644 --- a/library/cpp/yson/node/node_visitor.h +++ b/library/cpp/yson/node/node_visitor.h @@ -14,8 +14,8 @@ public: TNodeVisitor(NYson::IYsonConsumer* consumer, bool sortMapKeys = false); void Visit(const TNode& node); - void VisitMap(const TNode::TMapType& nodeMap); - void VisitList(const TNode::TListType& nodeMap); + void VisitMap(const TNode::TMapType& nodeMap); + void VisitList(const TNode::TListType& nodeMap); private: NYson::IYsonConsumer* Consumer_; diff --git a/library/cpp/yson_pull/detail/cescape.h b/library/cpp/yson_pull/detail/cescape.h index 1ea150e69a..738e8ec32f 100644 --- a/library/cpp/yson_pull/detail/cescape.h +++ b/library/cpp/yson_pull/detail/cescape.h @@ -6,7 +6,7 @@ #include "macros.h" #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/vector.h> /* REFERENCES FOR ESCAPE SEQUENCE INTERPRETATION: @@ -38,7 +38,7 @@ namespace NYsonPull { namespace NDetail { namespace NCEscape { - inline void encode(TString& dest, TStringBuf data) { + inline void encode(TString& dest, TStringBuf data) { NImpl::escape_impl( reinterpret_cast<const ui8*>(data.data()), data.size(), @@ -78,14 +78,14 @@ namespace NYsonPull { } } - inline TString encode(TStringBuf data) { - TString result; + inline TString encode(TStringBuf data) { + TString result; result.reserve(data.size()); encode(result, data); return result; } - inline void decode(TString& dest, TStringBuf data) { + inline void decode(TString& dest, TStringBuf data) { NImpl::unescape_impl( reinterpret_cast<const ui8*>(data.begin()), reinterpret_cast<const ui8*>(data.end()), @@ -97,7 +97,7 @@ namespace NYsonPull { }); } - inline void decode_inplace(TVector<ui8>& data) { + inline void decode_inplace(TVector<ui8>& data) { auto* out = static_cast<ui8*>( ::memchr(data.data(), '\\', data.size())); if (out == nullptr) { @@ -116,16 +116,16 @@ namespace NYsonPull { data.resize(out - &data[0]); } - inline TString decode(TStringBuf data) { - TString result; + inline TString decode(TStringBuf data) { + TString result; result.reserve(data.size()); decode(result, data); return result; } ATTRIBUTE(noinline, cold) - inline TString quote(TStringBuf str) { - TString result; + inline TString quote(TStringBuf str) { + TString result; result.reserve(str.size() + 16); result += '"'; encode(result, str); @@ -134,7 +134,7 @@ namespace NYsonPull { } ATTRIBUTE(noinline, cold) - inline TString quote(ui8 ch) { + inline TString quote(ui8 ch) { char c = ch; return quote(TStringBuf(&c, 1)); } diff --git a/library/cpp/yson_pull/detail/format_string.h b/library/cpp/yson_pull/detail/format_string.h index 683fd1bf36..57bc2697ae 100644 --- a/library/cpp/yson_pull/detail/format_string.h +++ b/library/cpp/yson_pull/detail/format_string.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/builder.h> namespace NYsonPull { @@ -17,10 +17,10 @@ namespace NYsonPull { } template <typename... Args> - TString format_string(Args&&... args) { + TString format_string(Args&&... args) { TStringBuilder builder; NImpl::apply_args(builder, std::forward<Args>(args)...); - return TString(std::move(builder)); + return TString(std::move(builder)); } } } diff --git a/library/cpp/yson_pull/detail/input/stream.h b/library/cpp/yson_pull/detail/input/stream.h index 791cd5a3f5..abe495aa47 100644 --- a/library/cpp/yson_pull/detail/input/stream.h +++ b/library/cpp/yson_pull/detail/input/stream.h @@ -57,10 +57,10 @@ namespace NYsonPull { } }; - class TFHandle: public TOwned<TFileInput> { + class TFHandle: public TOwned<TFileInput> { public: TFHandle(int fd, size_t buffer_size) - : TOwned<TFileInput>(Duplicate(fd), buffer_size) + : TOwned<TFileInput>(Duplicate(fd), buffer_size) { } }; diff --git a/library/cpp/yson_pull/detail/lexer_base.h b/library/cpp/yson_pull/detail/lexer_base.h index 572bdb3d18..525304ec8e 100644 --- a/library/cpp/yson_pull/detail/lexer_base.h +++ b/library/cpp/yson_pull/detail/lexer_base.h @@ -19,7 +19,7 @@ namespace NYsonPull { using Base = byte_reader< stream_counter<EnableLinePositionInfo>>; - TVector<ui8> token_buffer_; + TVector<ui8> token_buffer_; TMaybe<size_t> memory_limit_; public: diff --git a/library/cpp/yson_pull/detail/output/stream.h b/library/cpp/yson_pull/detail/output/stream.h index d4810f3353..4c5ca4db82 100644 --- a/library/cpp/yson_pull/detail/output/stream.h +++ b/library/cpp/yson_pull/detail/output/stream.h @@ -44,10 +44,10 @@ namespace NYsonPull { } }; - class TFHandle: public TOwned<TUnbufferedFileOutput> { + class TFHandle: public TOwned<TUnbufferedFileOutput> { public: TFHandle(int fd, size_t buffer_size) - : TOwned<TUnbufferedFileOutput>(buffer_size, Duplicate(fd)) + : TOwned<TUnbufferedFileOutput>(buffer_size, Duplicate(fd)) { } }; diff --git a/library/cpp/yson_pull/detail/reader.h b/library/cpp/yson_pull/detail/reader.h index 0e02396358..655d450b8e 100644 --- a/library/cpp/yson_pull/detail/reader.h +++ b/library/cpp/yson_pull/detail/reader.h @@ -188,7 +188,7 @@ namespace NYsonPull { lexer_base<EnableLinePositionInfo> lexer_; state state_; TEvent event_; - TVector<EEventType> stack_; + TVector<EEventType> stack_; EStreamType mode_; public: diff --git a/library/cpp/yson_pull/detail/writer.h b/library/cpp/yson_pull/detail/writer.h index b24b994292..4b3238ec33 100644 --- a/library/cpp/yson_pull/detail/writer.h +++ b/library/cpp/yson_pull/detail/writer.h @@ -32,7 +32,7 @@ namespace NYsonPull { }; byte_writer<stream_counter<false>> stream_; - TVector<EEventType> stack_; + TVector<EEventType> stack_; bool need_item_separator_ = false; EStreamType mode_ = EStreamType::ListFragment; state state_ = state::before_begin; diff --git a/library/cpp/yson_pull/exceptions.h b/library/cpp/yson_pull/exceptions.h index ebfed950a5..2d651990f8 100644 --- a/library/cpp/yson_pull/exceptions.h +++ b/library/cpp/yson_pull/exceptions.h @@ -2,7 +2,7 @@ #include "position_info.h" -#include <util/generic/string.h> +#include <util/generic/string.h> #include <stdexcept> #include <string> @@ -10,13 +10,13 @@ namespace NYsonPull { namespace NException { class TBadStream: public std::exception { - TString Message_; + TString Message_; TPositionInfo Position_; - mutable TString FormattedMessage_; + mutable TString FormattedMessage_; public: TBadStream( - TString message, + TString message, const TPositionInfo& position) : Message_(std::move(message)) , Position_(position) diff --git a/library/cpp/yson_pull/output.cpp b/library/cpp/yson_pull/output.cpp index 27c9ef9e69..5b01023e37 100644 --- a/library/cpp/yson_pull/output.cpp +++ b/library/cpp/yson_pull/output.cpp @@ -20,7 +20,7 @@ THolder<IStream> NOutput::FromPosixFd(int fd, size_t buffer_size) { return MakeHolder<TFHandle>(fd, buffer_size); } -THolder<IStream> NOutput::FromString(TString* output, size_t buffer_size) { +THolder<IStream> NOutput::FromString(TString* output, size_t buffer_size) { return MakeHolder<TOwned<TStringOutput>>(buffer_size, *output); } diff --git a/library/cpp/yson_pull/output.h b/library/cpp/yson_pull/output.h index 2d78107a93..ba1c1bee31 100644 --- a/library/cpp/yson_pull/output.h +++ b/library/cpp/yson_pull/output.h @@ -60,6 +60,6 @@ namespace NYsonPull { THolder<IStream> FromOutputStream(IOutputStream* output, size_t buffer_size = 65536); - THolder<IStream> FromString(TString* output, size_t buffer_size = 1024); + THolder<IStream> FromString(TString* output, size_t buffer_size = 1024); } } diff --git a/library/cpp/yson_pull/read_ops.h b/library/cpp/yson_pull/read_ops.h index 5c084983ea..125f6c9a57 100644 --- a/library/cpp/yson_pull/read_ops.h +++ b/library/cpp/yson_pull/read_ops.h @@ -119,8 +119,8 @@ namespace NYsonPull { } template <> - inline TString ReadScalar<TString>(TReader& reader) { - return TString(ReadScalar<TStringBuf>(reader)); + inline TString ReadScalar<TString>(TReader& reader) { + return TString(ReadScalar<TStringBuf>(reader)); } template <> diff --git a/library/cpp/yson_pull/ut/cescape_ut.cpp b/library/cpp/yson_pull/ut/cescape_ut.cpp index 6628ba1d15..d0f65be3fe 100644 --- a/library/cpp/yson_pull/ut/cescape_ut.cpp +++ b/library/cpp/yson_pull/ut/cescape_ut.cpp @@ -5,7 +5,7 @@ using namespace NYsonPull::NDetail; namespace { - void test_roundtrip(const TVector<ui8>& str) { + void test_roundtrip(const TVector<ui8>& str) { TStringBuf str_buf( reinterpret_cast<const char*>(str.data()), str.size()); @@ -19,7 +19,7 @@ namespace { } template <size_t N> - void test_exhaustive(TVector<ui8>& str) { + void test_exhaustive(TVector<ui8>& str) { for (int i = 0; i < 256; ++i) { str[str.size() - N] = static_cast<char>(i); test_exhaustive<N - 1>(str); @@ -27,13 +27,13 @@ namespace { } template <> - void test_exhaustive<0>(TVector<ui8>& str) { + void test_exhaustive<0>(TVector<ui8>& str) { test_roundtrip(str); } template <size_t N> void test_exhaustive() { - TVector<ui8> str(N, ' '); + TVector<ui8> str(N, ' '); test_exhaustive<N>(str); } diff --git a/library/cpp/yson_pull/ut/loop_ut.cpp b/library/cpp/yson_pull/ut/loop_ut.cpp index 8c7b11dd1c..361c3df8ca 100644 --- a/library/cpp/yson_pull/ut/loop_ut.cpp +++ b/library/cpp/yson_pull/ut/loop_ut.cpp @@ -215,7 +215,7 @@ namespace { template <typename Function> void test_memory(Function make_writer, size_t nrepeat) { - TString text; + TString text; { auto writer = make_writer(NYsonPull::NOutput::FromString(&text)); generate(writer, nrepeat); diff --git a/library/cpp/yson_pull/ut/writer_ut.cpp b/library/cpp/yson_pull/ut/writer_ut.cpp index 5c304bad0f..da20469697 100644 --- a/library/cpp/yson_pull/ut/writer_ut.cpp +++ b/library/cpp/yson_pull/ut/writer_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <climits> #include <limits> @@ -12,8 +12,8 @@ using namespace std::string_view_literals; namespace { template <typename Writer, typename Function> - TString with_writer(Function&& function) { - TString result; + TString with_writer(Function&& function) { + TString result; auto writer = NYsonPull::NDetail::make_writer<Writer>( NYsonPull::NOutput::FromString(&result), NYsonPull::EStreamType::Node); @@ -24,19 +24,19 @@ namespace { } template <typename Writer> - TString to_yson_string(const NYsonPull::TScalar& value) { + TString to_yson_string(const NYsonPull::TScalar& value) { return with_writer<Writer>([&](NYsonPull::TWriter& writer) { writer.BeginStream().Scalar(value).EndStream(); }); } template <typename T> - TString to_yson_binary_string(T&& value) { + TString to_yson_binary_string(T&& value) { return to_yson_string<NYsonPull::NDetail::TBinaryWriterImpl>(std::forward<T>(value)); } template <typename T> - TString to_yson_text_string(T&& value) { + TString to_yson_text_string(T&& value) { return to_yson_string<NYsonPull::NDetail::TTextWriterImpl>(std::forward<T>(value)); } |