diff options
author | eeight <eeight@yandex-team.ru> | 2022-02-10 16:46:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:19 +0300 |
commit | bd085aee9b4f7a0bee302ce687964ffb7098f986 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library | |
parent | 475c0a46f28166e83fd263badc7546377cddcabe (diff) | |
download | ydb-bd085aee9b4f7a0bee302ce687964ffb7098f986.tar.gz |
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
162 files changed, 1255 insertions, 1255 deletions
diff --git a/library/cpp/actors/core/actor_ut.cpp b/library/cpp/actors/core/actor_ut.cpp index 2f022c2d80..e1b765ec72 100644 --- a/library/cpp/actors/core/actor_ut.cpp +++ b/library/cpp/actors/core/actor_ut.cpp @@ -188,9 +188,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { TThreadParkPad pad; TAtomic actorsAlive = 0; double elapsedTime = 0; - THolder<IActor> endActor{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, {}, allocation, Leader)), &pad, &actorsAlive)}; + THolder<IActor> endActor{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, {}, allocation, Leader)), &pad, &actorsAlive)}; actorSystem.Register(endActor.Release(), mType); @@ -213,9 +213,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { ui32 leaderPoolId = poolsCount == 1 ? 0 : 1; TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, allocation, Follower), TMailboxType::HTSwap, followerPoolId); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, followerId, allocation, Leader)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, followerId, allocation, Leader)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap, leaderPoolId); pad.Park(); @@ -235,9 +235,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, false, Follower, MailboxNeighbourActors), TMailboxType::HTSwap); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&elapsedTime, followerId, false, Leader, MailboxNeighbourActors)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&elapsedTime, followerId, false, Leader, MailboxNeighbourActors)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap); pad.Park(); @@ -262,9 +262,9 @@ Y_UNIT_TEST_SUITE(ActorBenchmark) { ui32 leaderPoolId = 0; TActorId followerId = actorSystem.Register( new TSendReceiveActor(nullptr, {}, true, Follower), TMailboxType::HTSwap, followerPoolId); - THolder<IActor> leader{ - new TTestEndDecorator(THolder( - new TSendReceiveActor(&dummy[i], followerId, true, Leader)), &pad, &actorsAlive)}; + THolder<IActor> leader{ + new TTestEndDecorator(THolder( + new TSendReceiveActor(&dummy[i], followerId, true, Leader)), &pad, &actorsAlive)}; actorSystem.Register(leader.Release(), TMailboxType::HTSwap, leaderPoolId); } @@ -550,16 +550,16 @@ Y_UNIT_TEST_SUITE(TestDecorator) { TActorSystem actorSystem(setup); actorSystem.Start(); - THolder<IActor> innerActor = MakeHolder<TTestActor>(); + THolder<IActor> innerActor = MakeHolder<TTestActor>(); ui64 pongCounter = 0; - THolder<IActor> pongActor = MakeHolder<TPongDecorator>(std::move(innerActor), &pongCounter); + THolder<IActor> pongActor = MakeHolder<TPongDecorator>(std::move(innerActor), &pongCounter); ui64 pingCounter = 0; - THolder<IActor> pingActor = MakeHolder<TPingDecorator>(std::move(pongActor), &pingCounter); + THolder<IActor> pingActor = MakeHolder<TPingDecorator>(std::move(pongActor), &pingCounter); TThreadParkPad pad; TAtomic actorsAlive = 0; - THolder<IActor> endActor = MakeHolder<TTestEndDecorator>(std::move(pingActor), &pad, &actorsAlive); + THolder<IActor> endActor = MakeHolder<TTestEndDecorator>(std::move(pingActor), &pad, &actorsAlive); actorSystem.Register(endActor.Release(), TMailboxType::HTSwap); pad.Park(); diff --git a/library/cpp/actors/core/actorid.h b/library/cpp/actors/core/actorid.h index 4a57bed146..d972b1a0ff 100644 --- a/library/cpp/actors/core/actorid.h +++ b/library/cpp/actors/core/actorid.h @@ -66,40 +66,40 @@ namespace NActors { return Raw.X.X1 != 0 || Raw.X.X2 != 0; } - ui64 LocalId() const noexcept { + ui64 LocalId() const noexcept { return Raw.N.LocalId; } - ui32 Hint() const noexcept { + ui32 Hint() const noexcept { return Raw.N.Hint; } - ui32 NodeId() const noexcept { + ui32 NodeId() const noexcept { return Raw.N.NodeId & NodeIdMask; } - bool IsService() const noexcept { + bool IsService() const noexcept { return (Raw.N.NodeId & ServiceMask); } - TStringBuf ServiceId() const noexcept { + TStringBuf ServiceId() const noexcept { Y_VERIFY_DEBUG(IsService()); return TStringBuf((const char*)Raw.Buf, MaxServiceIDLength); } - static ui32 PoolIndex(ui32 nodeid) noexcept { + static ui32 PoolIndex(ui32 nodeid) noexcept { return ((nodeid & PoolIndexMask) >> PoolIndexShift); } - ui32 PoolID() const noexcept { + ui32 PoolID() const noexcept { return PoolIndex(Raw.N.NodeId); } - ui64 RawX1() const noexcept { + ui64 RawX1() const noexcept { return Raw.X.X1; } - ui64 RawX2() const noexcept { + ui64 RawX2() const noexcept { return Raw.X.X2; } diff --git a/library/cpp/actors/core/executor_pool_basic_ut.cpp b/library/cpp/actors/core/executor_pool_basic_ut.cpp index 71dc9d3b20..76dff693af 100644 --- a/library/cpp/actors/core/executor_pool_basic_ut.cpp +++ b/library/cpp/actors/core/executor_pool_basic_ut.cpp @@ -82,7 +82,7 @@ THolder<TActorSystemSetup> GetActorSystemSetup(TBasicExecutorPool* pool) auto setup = MakeHolder<NActors::TActorSystemSetup>(); setup->NodeId = 1; setup->ExecutorsCount = 1; - setup->Executors.Reset(new TAutoPtr<NActors::IExecutorPool>[1]); + setup->Executors.Reset(new TAutoPtr<NActors::IExecutorPool>[1]); setup->Executors[0] = pool; setup->Scheduler = new TBasicSchedulerThread(NActors::TSchedulerConfig(512, 0)); return setup; diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp index af8965365f..446b651efd 100644 --- a/library/cpp/actors/core/executor_thread.cpp +++ b/library/cpp/actors/core/executor_thread.cpp @@ -64,7 +64,7 @@ namespace NActors { void TExecutorThread::UnregisterActor(TMailboxHeader* mailbox, ui64 localActorId) { IActor* actor = mailbox->DetachActor(localActorId); Ctx.DecrementActorsAliveByActivity(actor->GetActivityType()); - DyingActors.push_back(THolder(actor)); + DyingActors.push_back(THolder(actor)); } void TExecutorThread::DropUnregistered() { @@ -298,7 +298,7 @@ namespace NActors { #endif if (ThreadName) { - ::SetCurrentThreadName(ThreadName); + ::SetCurrentThreadName(ThreadName); } ExecutorPool->SetRealTimeMode(); diff --git a/library/cpp/actors/core/mailbox.h b/library/cpp/actors/core/mailbox.h index 43a2ffdbf4..0bd9c4d314 100644 --- a/library/cpp/actors/core/mailbox.h +++ b/library/cpp/actors/core/mailbox.h @@ -95,7 +95,7 @@ namespace NActors { bool UnlockFromExecution2(bool wouldReschedule); // proceed with releasing lock bool UnlockAsFree(bool wouldReschedule); // preceed with releasing lock, but mark as free one - bool IsEmpty() const noexcept { + bool IsEmpty() const noexcept { return (ActorPack == TMailboxActorPack::Simple && ActorsInfo.Simple.ActorId == 0); } @@ -123,7 +123,7 @@ namespace NActors { } } - IActor* FindActor(ui64 localActorId) noexcept { + IActor* FindActor(ui64 localActorId) noexcept { switch (ActorPack) { case TMailboxActorPack::Simple: { if (ActorsInfo.Simple.ActorId == localActorId) @@ -150,7 +150,7 @@ namespace NActors { return nullptr; } - void AttachActor(ui64 localActorId, IActor* actor) noexcept { + void AttachActor(ui64 localActorId, IActor* actor) noexcept { switch (ActorPack) { case TMailboxActorPack::Simple: { if (ActorsInfo.Simple.ActorId == 0) { @@ -192,7 +192,7 @@ namespace NActors { } } - IActor* DetachActor(ui64 localActorId) noexcept { + IActor* DetachActor(ui64 localActorId) noexcept { Y_VERIFY_DEBUG(FindActor(localActorId) != nullptr); IActor* actorToDestruct = nullptr; diff --git a/library/cpp/actors/core/mailbox_queue_simple.h b/library/cpp/actors/core/mailbox_queue_simple.h index 535c012f19..2e44c21adb 100644 --- a/library/cpp/actors/core/mailbox_queue_simple.h +++ b/library/cpp/actors/core/mailbox_queue_simple.h @@ -12,7 +12,7 @@ namespace NActors { TTicketLock Lock; public: - ui32 Push(T x) noexcept { + ui32 Push(T x) noexcept { const ui32 spins = Lock.Acquire(); Queue.Push(x); Lock.Release(); diff --git a/library/cpp/actors/core/scheduler_basic.cpp b/library/cpp/actors/core/scheduler_basic.cpp index 59129d568e..fba200e16b 100644 --- a/library/cpp/actors/core/scheduler_basic.cpp +++ b/library/cpp/actors/core/scheduler_basic.cpp @@ -53,7 +53,7 @@ namespace NActors { #ifdef BALLOC ThreadDisableBalloc(); #endif - ::SetCurrentThreadName("Scheduler"); + ::SetCurrentThreadName("Scheduler"); ui64 currentMonotonic = RelaxedLoad(CurrentMonotonic); ui64 throttledMonotonic = currentMonotonic; diff --git a/library/cpp/actors/core/scheduler_cookie.cpp b/library/cpp/actors/core/scheduler_cookie.cpp index faee2a206a..0fa6f543a7 100644 --- a/library/cpp/actors/core/scheduler_cookie.cpp +++ b/library/cpp/actors/core/scheduler_cookie.cpp @@ -10,11 +10,11 @@ namespace NActors { { } - bool IsArmed() noexcept override { + bool IsArmed() noexcept override { return (AtomicGet(Value) == 2); } - bool Detach() noexcept override { + bool Detach() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 1) return true; @@ -27,7 +27,7 @@ namespace NActors { Y_FAIL(); } - bool DetachEvent() noexcept override { + bool DetachEvent() noexcept override { Y_FAIL(); } }; @@ -45,11 +45,11 @@ namespace NActors { { } - bool IsArmed() noexcept override { + bool IsArmed() noexcept override { return (AtomicGet(Value) == 3); } - bool Detach() noexcept override { + bool Detach() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 2) return true; @@ -63,7 +63,7 @@ namespace NActors { Y_FAIL(); } - bool DetachEvent() noexcept override { + bool DetachEvent() noexcept override { const ui64 x = AtomicDecrement(Value); if (x == 2) return false; diff --git a/library/cpp/actors/core/scheduler_cookie.h b/library/cpp/actors/core/scheduler_cookie.h index 68f7e1b94d..2c20ca67f3 100644 --- a/library/cpp/actors/core/scheduler_cookie.h +++ b/library/cpp/actors/core/scheduler_cookie.h @@ -10,9 +10,9 @@ namespace NActors { } public: - virtual bool Detach() noexcept = 0; - virtual bool DetachEvent() noexcept = 0; - virtual bool IsArmed() noexcept = 0; + virtual bool Detach() noexcept = 0; + virtual bool DetachEvent() noexcept = 0; + virtual bool IsArmed() noexcept = 0; static ISchedulerCookie* Make2Way(); static ISchedulerCookie* Make3Way(); @@ -36,7 +36,7 @@ namespace NActors { Detach(); } - bool operator==(const TSchedulerCookieHolder& x) const noexcept { + bool operator==(const TSchedulerCookieHolder& x) const noexcept { return (Cookie == x.Cookie); } @@ -55,7 +55,7 @@ namespace NActors { Cookie = cookie; } - bool Detach() noexcept { + bool Detach() noexcept { if (Cookie) { const bool res = Cookie->Detach(); Cookie = nullptr; @@ -65,7 +65,7 @@ namespace NActors { } } - bool DetachEvent() noexcept { + bool DetachEvent() noexcept { if (Cookie) { const bool res = Cookie->DetachEvent(); Cookie = nullptr; diff --git a/library/cpp/actors/http/http_cache.cpp b/library/cpp/actors/http/http_cache.cpp index 4ea22ffaa7..27c4eeb6f3 100644 --- a/library/cpp/actors/http/http_cache.cpp +++ b/library/cpp/actors/http/http_cache.cpp @@ -9,7 +9,7 @@ #include <library/cpp/digest/md5/md5.h> #include <util/digest/multi.h> #include <util/generic/queue.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NHttp { diff --git a/library/cpp/actors/memory_log/memlog.cpp b/library/cpp/actors/memory_log/memlog.cpp index 5358e1b0f1..8e6b46727d 100644 --- a/library/cpp/actors/memory_log/memlog.cpp +++ b/library/cpp/actors/memory_log/memlog.cpp @@ -105,7 +105,7 @@ char* TMemoryLog::LastMarkIsHere = nullptr; std::atomic<bool> TMemoryLog::PrintLastMark(true); -TMemoryLog::TMemoryLog(size_t totalSize, size_t grainSize) +TMemoryLog::TMemoryLog(size_t totalSize, size_t grainSize) : GrainSize(grainSize) , FreeGrains(DEFAULT_TOTAL_SIZE / DEFAULT_GRAIN_SIZE * 2) , Buf(totalSize) diff --git a/library/cpp/actors/testlib/decorator_ut.cpp b/library/cpp/actors/testlib/decorator_ut.cpp index 3b297b63e6..e9a2fa3560 100644 --- a/library/cpp/actors/testlib/decorator_ut.cpp +++ b/library/cpp/actors/testlib/decorator_ut.cpp @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { { Write("Start master actor"); for (auto &actor : Actors) { - THolder<IActor> decaratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); + THolder<IActor> decaratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); TActorId id = Register(decaratedActor.Release()); Write("Register test actor"); UNIT_ASSERT(ActorIds.insert(id).second); @@ -232,11 +232,11 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { void Bootstrap() { Write("TFizzBuzzSender::Bootstrap"); - THolder<IActor> actor = MakeHolder<TFooBarReceiver>(SelfId()); - THolder<IActor> decoratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); + THolder<IActor> actor = MakeHolder<TFooBarReceiver>(SelfId()); + THolder<IActor> decoratedActor = MakeHolder<TDyingChecker>(std::move(actor), SelfId()); SlaveId = Register(decoratedActor.Release()); for (ui64 idx = 1; idx <= 30; ++idx) { - THolder<TEvWords> ev = MakeHolder<TEvWords>(); + THolder<TEvWords> ev = MakeHolder<TEvWords>(); if (idx % 3 == 0) { ev->Words.push_back("Fizz"); } @@ -295,11 +295,11 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { } THolder<IActor> CreateFizzBuzzSender() { - THolder<IActor> actor = MakeHolder<TFizzBuzzSender>(); - THolder<IActor> foobar = MakeHolder<TFizzBuzzToFooBar>(std::move(actor)); - THolder<IActor> fizzEraser = MakeHolder<TWordEraser>(std::move(foobar), "Fizz"); - THolder<IActor> buzzEraser = MakeHolder<TWordEraser>(std::move(fizzEraser), "Buzz"); - return MakeHolder<TWithoutWordsDroper>(std::move(buzzEraser)); + THolder<IActor> actor = MakeHolder<TFizzBuzzSender>(); + THolder<IActor> foobar = MakeHolder<TFizzBuzzToFooBar>(std::move(actor)); + THolder<IActor> fizzEraser = MakeHolder<TWordEraser>(std::move(foobar), "Fizz"); + THolder<IActor> buzzEraser = MakeHolder<TWordEraser>(std::move(fizzEraser), "Buzz"); + return MakeHolder<TWithoutWordsDroper>(std::move(buzzEraser)); } Y_UNIT_TEST(Basic) { @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TesTTestDecorator) { TVector<THolder<IActor>> actors(1); actors[0] = CreateFizzBuzzSender(); //actors[1] = CreateFizzBuzzSender(); - THolder<IActor> testActor = MakeHolder<TTestMasterActor>(std::move(actors), edgeActor); + THolder<IActor> testActor = MakeHolder<TTestMasterActor>(std::move(actors), edgeActor); Write("Start test"); runtime.Register(testActor.Release()); diff --git a/library/cpp/actors/util/queue_oneone_inplace.h b/library/cpp/actors/util/queue_oneone_inplace.h index a473c500b8..d7ec8bb21c 100644 --- a/library/cpp/actors/util/queue_oneone_inplace.h +++ b/library/cpp/actors/util/queue_oneone_inplace.h @@ -53,7 +53,7 @@ public: } struct TPtrCleanDestructor { - static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { while (T head = x->Pop()) delete head; delete x; @@ -61,7 +61,7 @@ public: }; struct TCleanDestructor { - static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<T, TSize>* x) noexcept { while (x->Pop() != nullptr) continue; delete x; @@ -70,7 +70,7 @@ public: struct TPtrCleanInplaceMallocDestructor { template <typename TPtrVal> - static inline void Destroy(TOneOneQueueInplace<TPtrVal*, TSize>* x) noexcept { + static inline void Destroy(TOneOneQueueInplace<TPtrVal*, TSize>* x) noexcept { while (TPtrVal* head = x->Pop()) { head->~TPtrVal(); free(head); @@ -79,7 +79,7 @@ public: } }; - void Push(T x) noexcept { + void Push(T x) noexcept { if (WritePosition != TChunk::EntriesCount) { AtomicStore(&WriteTo->Entries[WritePosition], x); ++WritePosition; diff --git a/library/cpp/actors/util/thread.h b/library/cpp/actors/util/thread.h index 5f7bc27b69..d742c8c585 100644 --- a/library/cpp/actors/util/thread.h +++ b/library/cpp/actors/util/thread.h @@ -18,9 +18,9 @@ inline void SetCurrentThreadName(const TString& name, TStringStream linuxName; linuxName << procName << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else Y_UNUSED(maxCharsFromProcessName); - TThread::SetCurrentThreadName(name.data()); + TThread::SetCurrentThreadName(name.data()); #endif } diff --git a/library/cpp/actors/util/threadparkpad.cpp b/library/cpp/actors/util/threadparkpad.cpp index 6d5701e109..74069ff15b 100644 --- a/library/cpp/actors/util/threadparkpad.cpp +++ b/library/cpp/actors/util/threadparkpad.cpp @@ -19,25 +19,25 @@ namespace NActors { ~TImpl() { } - bool Park() noexcept { + bool Park() noexcept { __atomic_fetch_sub(&Futex, 1, __ATOMIC_SEQ_CST); while (__atomic_load_n(&Futex, __ATOMIC_ACQUIRE) == -1) SysFutex(&Futex, FUTEX_WAIT_PRIVATE, -1, nullptr, nullptr, 0); return IsInterrupted(); } - void Unpark() noexcept { + void Unpark() noexcept { const int old = __atomic_fetch_add(&Futex, 1, __ATOMIC_SEQ_CST); if (old == -1) SysFutex(&Futex, FUTEX_WAKE_PRIVATE, -1, nullptr, nullptr, 0); } - void Interrupt() noexcept { + void Interrupt() noexcept { __atomic_store_n(&Interrupted, true, __ATOMIC_SEQ_CST); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return __atomic_load_n(&Interrupted, __ATOMIC_ACQUIRE); } }; @@ -59,26 +59,26 @@ namespace NActors { if (!EvHandle) ythrow TWithBackTrace<yexception>() << "::CreateEvent failed"; } - ~TImpl() { + ~TImpl() { if (EvHandle) ::CloseHandle(EvHandle); } - bool Park() noexcept { + bool Park() noexcept { ::WaitForSingleObject(EvHandle, INFINITE); return AtomicGet(Interrupted); } - void Unpark() noexcept { + void Unpark() noexcept { ::SetEvent(EvHandle); } - void Interrupt() noexcept { + void Interrupt() noexcept { AtomicSet(Interrupted, true); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return AtomicGet(Interrupted); } }; @@ -98,24 +98,24 @@ namespace NActors { , Ev(TSystemEvent::rAuto) { } - ~TImpl() { + ~TImpl() { } - bool Park() noexcept { + bool Park() noexcept { Ev.Wait(); return AtomicGet(Interrupted); } - void Unpark() noexcept { + void Unpark() noexcept { Ev.Signal(); } - void Interrupt() noexcept { + void Interrupt() noexcept { AtomicSet(Interrupted, true); Unpark(); } - bool IsInterrupted() const noexcept { + bool IsInterrupted() const noexcept { return AtomicGet(Interrupted); } }; @@ -126,22 +126,22 @@ namespace NActors { { } - TThreadParkPad::~TThreadParkPad() { + TThreadParkPad::~TThreadParkPad() { } - bool TThreadParkPad::Park() noexcept { + bool TThreadParkPad::Park() noexcept { return Impl->Park(); } - void TThreadParkPad::Unpark() noexcept { + void TThreadParkPad::Unpark() noexcept { Impl->Unpark(); } - void TThreadParkPad::Interrupt() noexcept { + void TThreadParkPad::Interrupt() noexcept { Impl->Interrupt(); } - bool TThreadParkPad::Interrupted() const noexcept { + bool TThreadParkPad::Interrupted() const noexcept { return Impl->IsInterrupted(); } diff --git a/library/cpp/actors/util/threadparkpad.h b/library/cpp/actors/util/threadparkpad.h index a3f33e601a..5b574ccf34 100644 --- a/library/cpp/actors/util/threadparkpad.h +++ b/library/cpp/actors/util/threadparkpad.h @@ -10,12 +10,12 @@ namespace NActors { public: TThreadParkPad(); - ~TThreadParkPad(); + ~TThreadParkPad(); - bool Park() noexcept; - void Unpark() noexcept; - void Interrupt() noexcept; - bool Interrupted() const noexcept; + bool Park() noexcept; + void Unpark() noexcept; + void Interrupt() noexcept; + bool Interrupted() const noexcept; }; } diff --git a/library/cpp/actors/util/ticket_lock.h b/library/cpp/actors/util/ticket_lock.h index c6c6aebb32..3b1fa80393 100644 --- a/library/cpp/actors/util/ticket_lock.h +++ b/library/cpp/actors/util/ticket_lock.h @@ -15,11 +15,11 @@ public: { } - void Release() noexcept { + void Release() noexcept { AtomicUi32Increment(&TicketOut); } - ui32 Acquire() noexcept { + ui32 Acquire() noexcept { ui32 revolves = 0; const ui32 ticket = AtomicUi32Increment(&TicketIn) - 1; while (ticket != AtomicLoad(&TicketOut)) { @@ -30,7 +30,7 @@ public: return revolves; } - bool TryAcquire() noexcept { + bool TryAcquire() noexcept { const ui32 x = AtomicLoad(&TicketOut); if (x == AtomicLoad(&TicketIn) && AtomicUi32Cas(&TicketIn, x + 1, x)) return true; @@ -38,7 +38,7 @@ public: return false; } - bool IsLocked() noexcept { + bool IsLocked() noexcept { const ui32 ticketIn = AtomicLoad(&TicketIn); const ui32 ticketOut = AtomicLoad(&TicketOut); return (ticketIn != ticketOut); diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 623a795bbc..1becc3e5da 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -145,7 +145,7 @@ public: } inline void Add(const TString& key, IInputStream* src) { - Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); + Y_ENSURE(!Dict_.contains(key), "key " << key.data() << " already stored"); TCountingOutput out(Out_); if (UseCompression) { @@ -173,8 +173,8 @@ public: } inline void AddSynonym(const TString& existingKey, const TString& newKey) { - Y_ENSURE(Dict_.contains(existingKey), "key " << existingKey.data() << " not stored yet"); - Y_ENSURE(!Dict_.contains(newKey), "key " << newKey.data() << " already stored"); + Y_ENSURE(Dict_.contains(existingKey), "key " << existingKey.data() << " not stored yet"); + Y_ENSURE(!Dict_.contains(newKey), "key " << newKey.data() << " already stored"); TArchiveRecordDescriptorRef existingDescr = Dict_[existingKey]; TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(existingDescr->Offset(), existingDescr->Length(), newKey)); @@ -312,7 +312,7 @@ public: } inline bool Has(const TStringBuf key) const { - return Dict_.contains(key); + return Dict_.contains(key); } inline TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const { diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 2dd31b4879..412424889f 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -471,13 +471,13 @@ public: }; template <class... TVariantTypes> - int Add(const chunk_id, std::variant<TVariantTypes...>* pData) { - static_assert(std::variant_size_v<std::variant<TVariantTypes...>> < Max<ui32>()); + int Add(const chunk_id, std::variant<TVariantTypes...>* pData) { + static_assert(std::variant_size_v<std::variant<TVariantTypes...>> < Max<ui32>()); ui32 index; if (IsReading()) { Add(1, &index); - TLoadFromTypeFromListHelper<std::variant<TVariantTypes...>>::template Do<TVariantTypes...>( + TLoadFromTypeFromListHelper<std::variant<TVariantTypes...>>::template Do<TVariantTypes...>( *this, index, pData @@ -485,7 +485,7 @@ public: } else { index = pData->index(); // type cast is safe because of static_assert check above Add(1, &index); - std::visit([&](auto& dst) -> void { Add(2, &dst); }, *pData); + std::visit([&](auto& dst) -> void { Add(2, &dst); }, *pData); } return 0; } diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 9f6569fbee..37eba5406f 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -111,13 +111,13 @@ Y_UNIT_TEST(TestBlob) { Y_UNIT_TEST(TestVariant) { { - using T = std::variant<TString, int>; + using T = std::variant<TString, int>; TestBinSaverSerialization(T(TString(""))); TestBinSaverSerialization(T(0)); } { - using T = std::variant<TString, int, float>; + using T = std::variant<TString, int, float>; TestBinSaverSerialization(T(TString("ask"))); TestBinSaverSerialization(T(12)); diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h index e5125c2154..b13fbef101 100644 --- a/library/cpp/bit_io/bitinput_impl.h +++ b/library/cpp/bit_io/bitinput_impl.h @@ -33,7 +33,7 @@ namespace NBitIO { protected: template <ui32 bits> Y_FORCE_INLINE bool ReadKImpl(ui64& result) { - result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & Mask64(bits); + result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & Mask64(bits); BOffset += bits; if (BOffset < FakeStart) return true; @@ -79,7 +79,7 @@ namespace NBitIO { protected: template <ui64 bits, typename T> Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) { - result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits); + result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits); } template <typename T> @@ -92,8 +92,8 @@ namespace NBitIO { Y_FORCE_INLINE bool ReadWordsImpl(ui64& data) { data = 0; - const ui64 haveMore = NthBit64(bits); - const ui64 mask = Mask64(bits); + const ui64 haveMore = NthBit64(bits); + const ui64 mask = Mask64(bits); ui64 current = 0; ui64 byteNo = 0; diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index 24dda13178..2b886c1f02 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -14,10 +14,10 @@ namespace NBitIO { // Almost all code is hard tuned for sequential write performance. // Use tools/bursttrie/benchmarks/bitstreams_benchmark to check your changes. - inline constexpr ui64 BytesUp(ui64 bits) { - return (bits + 7ULL) >> 3ULL; - } - + inline constexpr ui64 BytesUp(ui64 bits) { + return (bits + 7ULL) >> 3ULL; + } + template <typename TStorage> class TBitOutputBase { protected: @@ -36,7 +36,7 @@ namespace NBitIO { } ui64 GetOffset() const { - return Offset + BytesUp(64ULL - FreeBits); + return Offset + BytesUp(64ULL - FreeBits); } ui64 GetBitOffset() const { @@ -83,7 +83,7 @@ namespace NBitIO { ui64 part = data; data >>= bits; - part |= FastZeroIfFalse(data, NthBit64(bits)); + part |= FastZeroIfFalse(data, NthBit64(bits)); Write(part, bits + 1ULL); } while (data); } diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index 6cf6cb83d7..f3277b8e4b 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -3,8 +3,8 @@ #include <library/cpp/string_utils/scan/scan.h> #include <library/cpp/string_utils/quote/quote.h> -#include <util/generic/singleton.h> - +#include <util/generic/singleton.h> + TCgiParameters::TCgiParameters(std::initializer_list<std::pair<TString, TString>> il) { for (const auto& item : il) { insert(item); diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index b28713606e..87d1ab0ad4 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -1,8 +1,8 @@ #pragma once -#include <library/cpp/iterator/iterate_values.h> - -#include <util/generic/iterator_range.h> +#include <library/cpp/iterator/iterate_values.h> + +#include <util/generic/iterator_range.h> #include <util/generic/map.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> @@ -63,8 +63,8 @@ public: TString QuotedPrint(const char* safe = "/") const; Y_PURE_FUNCTION - auto Range(const TStringBuf name) const noexcept { - return IterateValues(MakeIteratorRange(equal_range(name))); + auto Range(const TStringBuf name) const noexcept { + return IterateValues(MakeIteratorRange(equal_range(name))); } Y_PURE_FUNCTION diff --git a/library/cpp/cgiparam/ya.make b/library/cpp/cgiparam/ya.make index f9859d1631..fa1a6a13c0 100644 --- a/library/cpp/cgiparam/ya.make +++ b/library/cpp/cgiparam/ya.make @@ -8,7 +8,7 @@ SRCS( ) PEERDIR( - library/cpp/iterator + library/cpp/iterator library/cpp/string_utils/quote library/cpp/string_utils/scan ) diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index a3c546ab3f..6097e40131 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -1,15 +1,15 @@ #include "ci_string.h" int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { - return cp.stricmp(s1.data(), s2.data()); + return cp.stricmp(s1.data(), s2.data()); } int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { - return cp.stricmp(p, s2.data()); + return cp.stricmp(p, s2.data()); } int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { - return cp.stricmp(s1.data(), p); + return cp.stricmp(s1.data(), p); } int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { diff --git a/library/cpp/charset/ci_string.h b/library/cpp/charset/ci_string.h index 4756379808..edf24c1b6f 100644 --- a/library/cpp/charset/ci_string.h +++ b/library/cpp/charset/ci_string.h @@ -209,7 +209,7 @@ public: static size_t hashVal(const char* pc, size_t len, const CodePage& cp = csYandex); size_t hash() const { - return TCiString::hashVal(data(), length()); + return TCiString::hashVal(data(), length()); } }; diff --git a/library/cpp/charset/ci_string_ut.cpp b/library/cpp/charset/ci_string_ut.cpp index c1d979d93a..3d2a53d5fe 100644 --- a/library/cpp/charset/ci_string_ut.cpp +++ b/library/cpp/charset/ci_string_ut.cpp @@ -1,13 +1,13 @@ #include "ci_string.h" -#include <util/generic/hash.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 - size_t hash_val = ComputeHash(ss); + size_t hash_val = ComputeHash(ss); UNIT_ASSERT(hash_val == 1489244); } diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp index a9b64bdd64..0431bef31b 100644 --- a/library/cpp/charset/codepage.cpp +++ b/library/cpp/charset/codepage.cpp @@ -6,7 +6,7 @@ #include <util/string/cast.h> #include <util/string/subst.h> #include <util/string/util.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/yassert.h> #include <util/generic/hash.h> #include <util/generic/string.h> @@ -256,8 +256,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { if (SingleByteCodepage(enc)) { const CodePage* cp = CodePageByCharset(enc); for (TxChar* s = str; s < e; s++) { - if (Hi8(Lo16(*s)) == 0xF0) - *s = (TxChar)cp->unicode[Lo8(Lo16(*s))]; // NOT mb compliant + if (Hi8(Lo16(*s)) == 0xF0) + *s = (TxChar)cp->unicode[Lo8(Lo16(*s))]; // NOT mb compliant } } else if (enc == CODES_UTF8) { TxChar* s; @@ -276,8 +276,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { e = d; } else if (enc == CODES_UNKNOWN) { for (TxChar* s = str; s < e; s++) { - if (Hi8(Lo16(*s)) == 0xF0) - *s = Lo8(Lo16(*s)); + if (Hi8(Lo16(*s)) == 0xF0) + *s = Lo8(Lo16(*s)); } } else { Y_ASSERT(!SingleByteCodepage(enc)); @@ -290,8 +290,8 @@ void DoDecodeUnknownPlane(TxChar* str, TxChar*& ee, const ECharset enc) { size_t read = 0; size_t written = 0; for (; s < e; ++s) { - if (Hi8(Lo16(*s)) == 0xF0) { - buf.push_back(Lo8(Lo16(*s))); + if (Hi8(Lo16(*s)) == 0xF0) { + buf.push_back(Lo8(Lo16(*s))); } else { if (!buf.empty()) { if (RecodeToUnicode(enc, buf.data(), d, buf.size(), e - d, read, written) == RECODE_OK) { diff --git a/library/cpp/charset/ut/ya.make b/library/cpp/charset/ut/ya.make index 008f323970..1f9934c712 100644 --- a/library/cpp/charset/ut/ya.make +++ b/library/cpp/charset/ut/ya.make @@ -3,7 +3,7 @@ UNITTEST_FOR(library/cpp/charset) OWNER(alzobnin) SRCS( - ci_string_ut.cpp + ci_string_ut.cpp codepage_ut.cpp iconv_ut.cpp wide_ut.cpp diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 6097773b4b..78947d51ba 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -261,10 +261,10 @@ void TConversionTest::TestRecodeIntoString() { 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 +#ifndef TSTRING_IS_STD_STRING UNIT_ASSERT(sUnicode.data() != wdata); // re-allocated (shared buffer supplied) UNIT_ASSERT(sUnicode.data() == wres.data()); // same buffer -#endif +#endif UNIT_ASSERT(sUnicode.size() == wres.size()); // same content } @@ -372,7 +372,7 @@ void TConversionTest::TestRecode() { UNIT_ASSERT_VALUES_EQUAL(size_t(1), written); UNIT_ASSERT_VALUES_EQUAL(rch2, rch); - if (hash.contains(rch)) { // there are some stupid encodings with duplicate characters + if (hash.contains(rch)) { // there are some stupid encodings with duplicate characters continue; } else { hash.insert(rch); diff --git a/library/cpp/codecs/codecs.h b/library/cpp/codecs/codecs.h index 6716574b9e..cc5e72b285 100644 --- a/library/cpp/codecs/codecs.h +++ b/library/cpp/codecs/codecs.h @@ -10,7 +10,7 @@ #include <util/stream/input.h> #include <util/stream/output.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/vector.h> #include <util/system/tls.h> #include <util/ysaveload.h> diff --git a/library/cpp/codecs/codecs_registry.cpp b/library/cpp/codecs/codecs_registry.cpp index 05caa50d58..17d07062ab 100644 --- a/library/cpp/codecs/codecs_registry.cpp +++ b/library/cpp/codecs/codecs_registry.cpp @@ -9,7 +9,7 @@ #include <library/cpp/blockcodecs/codecs.h> #include <util/string/builder.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { TCodecPtr ICodec::GetInstance(TStringBuf name) { @@ -24,7 +24,7 @@ namespace NCodecs { void TCodecRegistry::RegisterFactory(TFactoryPtr fac) { TVector<TString> names = fac->ListNames(); for (const auto& name : names) { - Y_VERIFY(!Registry.contains(name), "already has %s", name.data()); + Y_VERIFY(!Registry.contains(name), "already has %s", name.data()); Registry[name] = fac; } } @@ -37,7 +37,7 @@ namespace NCodecs { } if (TStringBuf::npos == name.find(':')) { - Y_ENSURE_EX(Registry.contains(name), TNoCodecException(name)); + Y_ENSURE_EX(Registry.contains(name), TNoCodecException(name)); return Registry.find(name)->second->MakeCodec(name); } else { TPipelineCodec* pipe = new TPipelineCodec; @@ -190,7 +190,7 @@ namespace NCodecs { } TCodecPtr MakeCodec(TStringBuf name) const override { - if (!Registry.contains(name)) { + if (!Registry.contains(name)) { ythrow TNoCodecException(name); } return Registry.find(name)->second; diff --git a/library/cpp/codecs/codecs_registry.h b/library/cpp/codecs/codecs_registry.h index 3f2e994320..53710310d5 100644 --- a/library/cpp/codecs/codecs_registry.h +++ b/library/cpp/codecs/codecs_registry.h @@ -1,7 +1,7 @@ #pragma once #include "codecs.h" -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { struct TNoCodecException : TCodecException { diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp index 0fa8104369..476b8ada80 100644 --- a/library/cpp/codecs/comptable_codec.cpp +++ b/library/cpp/codecs/comptable_codec.cpp @@ -1,7 +1,7 @@ #include "comptable_codec.h" #include <library/cpp/comptable/comptable.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { class TCompTableCodec::TImpl: public TAtomicRefCount<TImpl> { diff --git a/library/cpp/codecs/delta_codec.h b/library/cpp/codecs/delta_codec.h index 78dbd8f1ee..21325825e6 100644 --- a/library/cpp/codecs/delta_codec.h +++ b/library/cpp/codecs/delta_codec.h @@ -4,8 +4,8 @@ #include <util/generic/array_ref.h> #include <util/generic/typetraits.h> -#include <util/generic/bitops.h> -#include <util/string/cast.h> +#include <util/generic/bitops.h> +#include <util/string/cast.h> namespace NCodecs { template <typename T = ui64, bool UnsignedDelta = true> diff --git a/library/cpp/codecs/float_huffman.cpp b/library/cpp/codecs/float_huffman.cpp index 9029877023..c4a8bd228f 100644 --- a/library/cpp/codecs/float_huffman.cpp +++ b/library/cpp/codecs/float_huffman.cpp @@ -1,333 +1,333 @@ #include "float_huffman.h" -#include <util/generic/array_ref.h> -#include <util/generic/bitops.h> -#include <util/generic/cast.h> -#include <util/generic/yexception.h> -#include <util/system/unaligned_mem.h> -#include <util/system/yassert.h> -#include <util/stream/format.h> - -namespace NCodecs::NFloatHuff { - namespace { - struct THuffEntry { - ui32 CodeBase; - ui16 Prefix; - int PrefLength; - int CodeLength; - int TotalLength; - ui32 Mask; - ui64 Offset; - - THuffEntry() = default; - - constexpr THuffEntry(ui32 codeBase, ui16 prefix, int prefLength, int codeLength) - : CodeBase(codeBase) - , Prefix(prefix) - , PrefLength(prefLength) - , CodeLength(codeLength) - , TotalLength(prefLength + codeLength) - , Mask(Mask64(codeLength)) - , Offset(-(ui64(codeBase) << prefLength) + prefix) - {} - - bool Fit(ui32 code) const { - return code >= CodeBase && code < CodeBase + (1ULL << CodeLength); - } - }; - - // NB. There is a typo in the penultimate line (34 instead of 24). It was there from the very - // first commit and we cannot fix it without breaking all the clients. - constexpr THuffEntry entries[16] = { - {0x00000000, 0x01, 1, 0}, // Only +0.0f, 1 bit, prefix [1] - {0x3f800000, 0x0e, 4, 0}, // Only +1.0f, 4 bits, prefix [0111] - {0x3f700000, 0x08, 5, 20}, // [0.9375, 1.0), 25 bits, prefix [00010] - {0x3f000000, 0x00, 5, 20}, // [0.5, 0.5625), 25 bits, prefx [00000] - {0x3f400000, 0x06, 6, 20}, // [0.75, 0.8125), 26 bits, prefix [011000] - {0x3f500000, 0x22, 6, 20}, // [0.8125, 0.875), 26 bits, prefix [010001] - {0x3f200000, 0x02, 6, 20}, // [0.625, 0.6875), 26 bits, prefix [010000] - {0x3f100000, 0x38, 6, 20}, // [0.5625, 0.625), 26 bits, prefix [000111] - {0x3f600000, 0x18, 6, 20}, // [0.875, 0.9375), 26 bits, prefix [000110] - {0x3f300000, 0x30, 6, 20}, // [0.6875, 0.75), 26 bits, prefix [000011] - {0x3e800000, 0x10, 6, 20}, // [0.25, 0.28125), 26 bits, prefix [000010] - {0x3e000000, 0x04, 3, 24}, // [0.125, 0.5), 27 bits, prefix [001] - {0x3d000000, 0x0a, 4, 24}, // [0.03125, 0.125), 28 bits, prefix [0101] - {0x3c000000, 0x12, 5, 24}, // [0.0078125, 0.03125), 29 bits, prefix [01001] - {0x3b000000, 0x26, 6, 34}, // [0.001953125, end of range), 40 bits, prefix [011001] - {0x00000000, 0x16, 5, 32}, // whole range, 37 bits, prefix [01101] +#include <util/generic/array_ref.h> +#include <util/generic/bitops.h> +#include <util/generic/cast.h> +#include <util/generic/yexception.h> +#include <util/system/unaligned_mem.h> +#include <util/system/yassert.h> +#include <util/stream/format.h> + +namespace NCodecs::NFloatHuff { + namespace { + struct THuffEntry { + ui32 CodeBase; + ui16 Prefix; + int PrefLength; + int CodeLength; + int TotalLength; + ui32 Mask; + ui64 Offset; + + THuffEntry() = default; + + constexpr THuffEntry(ui32 codeBase, ui16 prefix, int prefLength, int codeLength) + : CodeBase(codeBase) + , Prefix(prefix) + , PrefLength(prefLength) + , CodeLength(codeLength) + , TotalLength(prefLength + codeLength) + , Mask(Mask64(codeLength)) + , Offset(-(ui64(codeBase) << prefLength) + prefix) + {} + + bool Fit(ui32 code) const { + return code >= CodeBase && code < CodeBase + (1ULL << CodeLength); + } + }; + + // NB. There is a typo in the penultimate line (34 instead of 24). It was there from the very + // first commit and we cannot fix it without breaking all the clients. + constexpr THuffEntry entries[16] = { + {0x00000000, 0x01, 1, 0}, // Only +0.0f, 1 bit, prefix [1] + {0x3f800000, 0x0e, 4, 0}, // Only +1.0f, 4 bits, prefix [0111] + {0x3f700000, 0x08, 5, 20}, // [0.9375, 1.0), 25 bits, prefix [00010] + {0x3f000000, 0x00, 5, 20}, // [0.5, 0.5625), 25 bits, prefx [00000] + {0x3f400000, 0x06, 6, 20}, // [0.75, 0.8125), 26 bits, prefix [011000] + {0x3f500000, 0x22, 6, 20}, // [0.8125, 0.875), 26 bits, prefix [010001] + {0x3f200000, 0x02, 6, 20}, // [0.625, 0.6875), 26 bits, prefix [010000] + {0x3f100000, 0x38, 6, 20}, // [0.5625, 0.625), 26 bits, prefix [000111] + {0x3f600000, 0x18, 6, 20}, // [0.875, 0.9375), 26 bits, prefix [000110] + {0x3f300000, 0x30, 6, 20}, // [0.6875, 0.75), 26 bits, prefix [000011] + {0x3e800000, 0x10, 6, 20}, // [0.25, 0.28125), 26 bits, prefix [000010] + {0x3e000000, 0x04, 3, 24}, // [0.125, 0.5), 27 bits, prefix [001] + {0x3d000000, 0x0a, 4, 24}, // [0.03125, 0.125), 28 bits, prefix [0101] + {0x3c000000, 0x12, 5, 24}, // [0.0078125, 0.03125), 29 bits, prefix [01001] + {0x3b000000, 0x26, 6, 34}, // [0.001953125, end of range), 40 bits, prefix [011001] + {0x00000000, 0x16, 5, 32}, // whole range, 37 bits, prefix [01101] }; [[noreturn]] Y_NO_INLINE void ThrowInvalidOffset(size_t size, size_t byteOffset) { - ythrow yexception() << - "Decompression error: requested decoding 8 bytes past end of input buffer of " << size << " bytes size at position " << byteOffset << ". "; - } - - struct THuffInfo { - constexpr THuffInfo() { - for (size_t i = 0; i < 64; ++i) { - bool init = false; - for (size_t j = 0; j != 16; ++j) { - ui16 prefix = i & Mask64(entries[j].PrefLength); - if (entries[j].Prefix == prefix) { - init = true; - DecodeLookup[i] = entries[j]; - break; - } - } - Y_ASSERT(init); - } - - for (ui32 i = 0; i < (1 << 12); ++i) { - // First two entries (+0.0f and +1.0f) are not present in the lookup, they are handled separately - for (int value = 2; value < 16; ++value) { - if (entries[value].Fit(i << 20)) { - EncodeLookup[i] = value; - break; - } - } - } - } - - std::pair<ui64, int> GetCode(ui32 value) const { - // Zeros are handled separately in the main loop - Y_ASSERT(value != 0); - - if (value == 0x3f800000) { - return {0x0e, 4}; - } - - const auto& entry = entries[EncodeLookup[value >> 20]]; - - return { - (ui64(value) << entry.PrefLength) + entry.Offset, - entry.TotalLength - }; - } - - THuffEntry DecodeLookup[64]; - ui8 EncodeLookup[1 << 12]; - }; - - const THuffInfo huffInfo; - /// End Of Stream - const ui32 EOS = ui32(-1); - } - - TString Encode(TArrayRef<const float> factors) { - TString result; - result.resize((factors.size() + 1) * 40 / 8 + 8, 0); // Max code length is 40 bits - int usedBits = 0; - ui64 buffer = 0; - char* writePtr = result.begin(); - - auto writeBits = [&](ui64 code, int size) { - const auto bitsToTransfer = Min(size, 64 - usedBits); - buffer |= (code << usedBits); - usedBits += bitsToTransfer; - if (usedBits == 64) { - memcpy(writePtr, &buffer, 8); - usedBits = size - bitsToTransfer; - if (bitsToTransfer != 64) { - buffer = code >> bitsToTransfer; - } else { - buffer = 0; - } - writePtr += 8; - } - }; - - for (size_t i = 0; i != factors.size();) { - if (BitCast<ui32>(factors[i]) == 0) { - int zeroCount = 1; - for (;;) { - ++i; - if (i == factors.size() || BitCast<ui32>(factors[i]) != 0) { - break; - } - ++zeroCount; - } - for (; zeroCount >= 64; zeroCount -= 64) { - writeBits(ui64(-1), 64); - } - writeBits(Mask64(zeroCount), zeroCount); - } else { - const auto [code, codeSize] = huffInfo.GetCode(BitCast<ui32>(factors[i])); - writeBits(code, codeSize); - ++i; - } - } - // Write EOS. - // We use precomputed constants instead of the following: - // auto [code, codeSize] = huffInfo.GetCode(EOS); - // writeBits(code, codeSize); - writeBits(211527139302, 40); - memcpy(writePtr, &buffer, 8); - result.resize(writePtr - result.begin() + usedBits / 8 + 8); - - return result; - } - - TDecoder::TDecoder(TStringBuf data) - : State{ - .Workspace = data.size() < 8 ? ThrowInvalidOffset(data.size(), 0), 0 : ReadUnaligned<ui64>(data.data()), - .WorkspaceSize = 64, - .Position = 8, - .Data = data - } - { - FillDecodeBuffer(); - } - - TVector<float> TDecoder::DecodeAll(size_t sizeHint) { - TVector<float> result; - result.reserve(sizeHint); - - while (Begin != End) { - result.insert(result.end(), Begin, End); - FillDecodeBuffer(); - } - return result; - } - - size_t TDecoder::Decode(TArrayRef<float> dest) { - size_t count = 0; - while (count < dest.size()) { - if (dest.size() - count < size_t(End - Begin)) { - const auto size = dest.size() - count; - std::copy(Begin, Begin + size, dest.data() + count); - Begin += size; - return dest.size(); - } else { - std::copy(Begin, End, dest.data() + count); - count += End - Begin; - FillDecodeBuffer(); - if (Begin == End) { - break; - } - } - } - return count; - } - - size_t TDecoder::Skip(size_t count) { - size_t skippedCount = 0; - while (skippedCount < count) { - if (count - skippedCount < size_t(End - Begin)) { - const auto size = count - skippedCount; - Begin += size; - return count; - } else { - skippedCount += End - Begin; - FillDecodeBuffer(); - if (Begin == End) { - break; - } - } - } - return skippedCount; - } - - bool TDecoder::HasMore() const { - return Begin != End; - } - - void TDecoder::FillDecodeBuffer() { - Begin = DecodeBuffer.data(); - End = DecodeBuffer.data(); - - if (HitEos) { - return; - } - - // This helps to keep most of the variables in the registers. - float* end = End; - TState state = State; - - // It is faster to just zero all the memory here in one go - // and then avoid inner loop when writing zeros. There we - // can just increment end pointer. - std::fill(DecodeBuffer.begin(), DecodeBuffer.end(), 0.0f); - - // Make sure that inside the loop we always have space to put 64 zeros and one other - // value. - float* cap = DecodeBuffer.data() + DecodeBuffer.size() - 64 - 1; - - while (end < cap) { - if (state.Workspace % 2 == 1) { - // Decode zeros - // There we can just scan whole state.Workspace for ones because it contains - // zeros outside of the WorkspaceSize bits. - const auto negWorkspace = ~state.Workspace; - const int zeroCount = negWorkspace ? CountTrailingZeroBits(negWorkspace) : 64; - end += zeroCount; - state.SkipBits(zeroCount); - continue; - } - if (state.PeekBits(4) == 0x0e) { - *end++ = 1.0f; - state.SkipBits(4); - continue; - } - const auto& entry = huffInfo.DecodeLookup[state.PeekBits(6)]; - const auto code = ui32((state.NextBitsUnmasked(entry.TotalLength) >> entry.PrefLength) & entry.Mask) + entry.CodeBase; - if (Y_UNLIKELY(code == EOS)) { - HitEos = true; - break; - } - *end++ = BitCast<float>(code); - } - - End = end; - State = state; - } - - ui64 TDecoder::TState::PeekBits(int count) { - if (WorkspaceSize > count) { - return Workspace & Mask64(count); - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - return (Workspace | (ReadUnaligned<ui64>(Data.data() + Position) << WorkspaceSize)) & Mask64(count); - } - } - - ui64 TDecoder::TState::NextBitsUnmasked(int count) { - if (WorkspaceSize > count) { - const auto result = Workspace; - Workspace >>= count; - WorkspaceSize -= count; - return result; - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - ui64 result = Workspace; - Workspace = ReadUnaligned<ui64>(Data.data() + Position); - Position += 8; - result |= Workspace << WorkspaceSize; - Workspace >>= count - WorkspaceSize; - WorkspaceSize += 64 - count; - return result; - } - } - - void TDecoder::TState::SkipBits(int count) { - if (WorkspaceSize > count) { - Workspace >>= count; - WorkspaceSize -= count; - } else { - if (Y_UNLIKELY(Position + 8 > Data.size())) { - ThrowInvalidOffset(Data.size(), Position); - } - Workspace = ReadUnaligned<ui64>(Data.data() + Position); - Position += 8; - Workspace >>= count - WorkspaceSize; - WorkspaceSize += 64 - count; - } - } - - TVector<float> Decode(TStringBuf data, size_t sizeHint) { - return TDecoder(data).DecodeAll(sizeHint); - } -} // namespace NCodecs::NFloatHuff + ythrow yexception() << + "Decompression error: requested decoding 8 bytes past end of input buffer of " << size << " bytes size at position " << byteOffset << ". "; + } + + struct THuffInfo { + constexpr THuffInfo() { + for (size_t i = 0; i < 64; ++i) { + bool init = false; + for (size_t j = 0; j != 16; ++j) { + ui16 prefix = i & Mask64(entries[j].PrefLength); + if (entries[j].Prefix == prefix) { + init = true; + DecodeLookup[i] = entries[j]; + break; + } + } + Y_ASSERT(init); + } + + for (ui32 i = 0; i < (1 << 12); ++i) { + // First two entries (+0.0f and +1.0f) are not present in the lookup, they are handled separately + for (int value = 2; value < 16; ++value) { + if (entries[value].Fit(i << 20)) { + EncodeLookup[i] = value; + break; + } + } + } + } + + std::pair<ui64, int> GetCode(ui32 value) const { + // Zeros are handled separately in the main loop + Y_ASSERT(value != 0); + + if (value == 0x3f800000) { + return {0x0e, 4}; + } + + const auto& entry = entries[EncodeLookup[value >> 20]]; + + return { + (ui64(value) << entry.PrefLength) + entry.Offset, + entry.TotalLength + }; + } + + THuffEntry DecodeLookup[64]; + ui8 EncodeLookup[1 << 12]; + }; + + const THuffInfo huffInfo; + /// End Of Stream + const ui32 EOS = ui32(-1); + } + + TString Encode(TArrayRef<const float> factors) { + TString result; + result.resize((factors.size() + 1) * 40 / 8 + 8, 0); // Max code length is 40 bits + int usedBits = 0; + ui64 buffer = 0; + char* writePtr = result.begin(); + + auto writeBits = [&](ui64 code, int size) { + const auto bitsToTransfer = Min(size, 64 - usedBits); + buffer |= (code << usedBits); + usedBits += bitsToTransfer; + if (usedBits == 64) { + memcpy(writePtr, &buffer, 8); + usedBits = size - bitsToTransfer; + if (bitsToTransfer != 64) { + buffer = code >> bitsToTransfer; + } else { + buffer = 0; + } + writePtr += 8; + } + }; + + for (size_t i = 0; i != factors.size();) { + if (BitCast<ui32>(factors[i]) == 0) { + int zeroCount = 1; + for (;;) { + ++i; + if (i == factors.size() || BitCast<ui32>(factors[i]) != 0) { + break; + } + ++zeroCount; + } + for (; zeroCount >= 64; zeroCount -= 64) { + writeBits(ui64(-1), 64); + } + writeBits(Mask64(zeroCount), zeroCount); + } else { + const auto [code, codeSize] = huffInfo.GetCode(BitCast<ui32>(factors[i])); + writeBits(code, codeSize); + ++i; + } + } + // Write EOS. + // We use precomputed constants instead of the following: + // auto [code, codeSize] = huffInfo.GetCode(EOS); + // writeBits(code, codeSize); + writeBits(211527139302, 40); + memcpy(writePtr, &buffer, 8); + result.resize(writePtr - result.begin() + usedBits / 8 + 8); + + return result; + } + + TDecoder::TDecoder(TStringBuf data) + : State{ + .Workspace = data.size() < 8 ? ThrowInvalidOffset(data.size(), 0), 0 : ReadUnaligned<ui64>(data.data()), + .WorkspaceSize = 64, + .Position = 8, + .Data = data + } + { + FillDecodeBuffer(); + } + + TVector<float> TDecoder::DecodeAll(size_t sizeHint) { + TVector<float> result; + result.reserve(sizeHint); + + while (Begin != End) { + result.insert(result.end(), Begin, End); + FillDecodeBuffer(); + } + return result; + } + + size_t TDecoder::Decode(TArrayRef<float> dest) { + size_t count = 0; + while (count < dest.size()) { + if (dest.size() - count < size_t(End - Begin)) { + const auto size = dest.size() - count; + std::copy(Begin, Begin + size, dest.data() + count); + Begin += size; + return dest.size(); + } else { + std::copy(Begin, End, dest.data() + count); + count += End - Begin; + FillDecodeBuffer(); + if (Begin == End) { + break; + } + } + } + return count; + } + + size_t TDecoder::Skip(size_t count) { + size_t skippedCount = 0; + while (skippedCount < count) { + if (count - skippedCount < size_t(End - Begin)) { + const auto size = count - skippedCount; + Begin += size; + return count; + } else { + skippedCount += End - Begin; + FillDecodeBuffer(); + if (Begin == End) { + break; + } + } + } + return skippedCount; + } + + bool TDecoder::HasMore() const { + return Begin != End; + } + + void TDecoder::FillDecodeBuffer() { + Begin = DecodeBuffer.data(); + End = DecodeBuffer.data(); + + if (HitEos) { + return; + } + + // This helps to keep most of the variables in the registers. + float* end = End; + TState state = State; + + // It is faster to just zero all the memory here in one go + // and then avoid inner loop when writing zeros. There we + // can just increment end pointer. + std::fill(DecodeBuffer.begin(), DecodeBuffer.end(), 0.0f); + + // Make sure that inside the loop we always have space to put 64 zeros and one other + // value. + float* cap = DecodeBuffer.data() + DecodeBuffer.size() - 64 - 1; + + while (end < cap) { + if (state.Workspace % 2 == 1) { + // Decode zeros + // There we can just scan whole state.Workspace for ones because it contains + // zeros outside of the WorkspaceSize bits. + const auto negWorkspace = ~state.Workspace; + const int zeroCount = negWorkspace ? CountTrailingZeroBits(negWorkspace) : 64; + end += zeroCount; + state.SkipBits(zeroCount); + continue; + } + if (state.PeekBits(4) == 0x0e) { + *end++ = 1.0f; + state.SkipBits(4); + continue; + } + const auto& entry = huffInfo.DecodeLookup[state.PeekBits(6)]; + const auto code = ui32((state.NextBitsUnmasked(entry.TotalLength) >> entry.PrefLength) & entry.Mask) + entry.CodeBase; + if (Y_UNLIKELY(code == EOS)) { + HitEos = true; + break; + } + *end++ = BitCast<float>(code); + } + + End = end; + State = state; + } + + ui64 TDecoder::TState::PeekBits(int count) { + if (WorkspaceSize > count) { + return Workspace & Mask64(count); + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + return (Workspace | (ReadUnaligned<ui64>(Data.data() + Position) << WorkspaceSize)) & Mask64(count); + } + } + + ui64 TDecoder::TState::NextBitsUnmasked(int count) { + if (WorkspaceSize > count) { + const auto result = Workspace; + Workspace >>= count; + WorkspaceSize -= count; + return result; + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + ui64 result = Workspace; + Workspace = ReadUnaligned<ui64>(Data.data() + Position); + Position += 8; + result |= Workspace << WorkspaceSize; + Workspace >>= count - WorkspaceSize; + WorkspaceSize += 64 - count; + return result; + } + } + + void TDecoder::TState::SkipBits(int count) { + if (WorkspaceSize > count) { + Workspace >>= count; + WorkspaceSize -= count; + } else { + if (Y_UNLIKELY(Position + 8 > Data.size())) { + ThrowInvalidOffset(Data.size(), Position); + } + Workspace = ReadUnaligned<ui64>(Data.data() + Position); + Position += 8; + Workspace >>= count - WorkspaceSize; + WorkspaceSize += 64 - count; + } + } + + TVector<float> Decode(TStringBuf data, size_t sizeHint) { + return TDecoder(data).DecodeAll(sizeHint); + } +} // namespace NCodecs::NFloatHuff diff --git a/library/cpp/codecs/float_huffman.h b/library/cpp/codecs/float_huffman.h index 0fc1573d8e..786a8eae1d 100644 --- a/library/cpp/codecs/float_huffman.h +++ b/library/cpp/codecs/float_huffman.h @@ -1,50 +1,50 @@ #pragma once -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/generic/vector.h> #include <util/generic/strbuf.h> -#include <array> - -namespace NCodecs::NFloatHuff { - TString Encode(TArrayRef<const float> factors); - - class TDecoder { - public: - explicit TDecoder(TStringBuf data); - - TVector<float> DecodeAll(size_t sizeHint = 0); - - // Returns number of decoded floats. May be fewer than requested if the EOS is found. - size_t Decode(TArrayRef<float> dest); - - // Returns the number of skipped values. - size_t Skip(size_t count); - - bool HasMore() const; - - private: - struct TState { - ui64 Workspace = 0; - int WorkspaceSize = 0; - ui64 Position = 0; - TStringBuf Data; - - ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary - ui64 PeekBits(int count); - void SkipBits(int count); - }; - - void FillDecodeBuffer(); - - TState State; - std::array<float, 128> DecodeBuffer; - // The range of already decompressed numbers inside the DecodeBuffer. - // Always kept non-empty until the EOS is encountered. - float* Begin; - float* End; - bool HitEos = false; - }; - - TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); +#include <array> + +namespace NCodecs::NFloatHuff { + TString Encode(TArrayRef<const float> factors); + + class TDecoder { + public: + explicit TDecoder(TStringBuf data); + + TVector<float> DecodeAll(size_t sizeHint = 0); + + // Returns number of decoded floats. May be fewer than requested if the EOS is found. + size_t Decode(TArrayRef<float> dest); + + // Returns the number of skipped values. + size_t Skip(size_t count); + + bool HasMore() const; + + private: + struct TState { + ui64 Workspace = 0; + int WorkspaceSize = 0; + ui64 Position = 0; + TStringBuf Data; + + ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary + ui64 PeekBits(int count); + void SkipBits(int count); + }; + + void FillDecodeBuffer(); + + TState State; + std::array<float, 128> DecodeBuffer; + // The range of already decompressed numbers inside the DecodeBuffer. + // Always kept non-empty until the EOS is encountered. + float* Begin; + float* End; + bool HitEos = false; + }; + + TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); } diff --git a/library/cpp/codecs/float_huffman_bench/main.cpp b/library/cpp/codecs/float_huffman_bench/main.cpp index c5dd456bbe..1018c17834 100644 --- a/library/cpp/codecs/float_huffman_bench/main.cpp +++ b/library/cpp/codecs/float_huffman_bench/main.cpp @@ -1,145 +1,145 @@ -#include <library/cpp/codecs/float_huffman.h> - -#include <benchmark/benchmark.h> - -#include <util/generic/vector.h> - -const float Factors[] = { - 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, - 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, - 0.008253, 1, 0, 0, 0.00993935, 0.450213, 0.000974026, 1, 1, 1, 1, 0, 0, 0.20564, - 0.97561, 0.913896, 1, 1, 0, 1, 0, 0, 0.5, 0, 0, 0, 0.1, 1, 0, 0, 0, 0, 0, 0.450923, - 0, 0.5, 0, 0, 0.20564, 0, 0.5, 0, 0, 0.20564, 0, 0, 0.0313726, 0, 1, 1, 1, 0.363636, - 0.5, 0.686073, 0.45121, 0.00574382, 0.366166, 0.413295, 1, 1, 1, 0, 0, 0, 0, 0.160784, - 0, 0.937255, 0.537255, 0.133333, 0, 0, 0, 0, 0.00392157, 0, 0.333333, 0.027451, 0.0156863, - 1, 0.105882, 1, 0.00220908, 0.000112501, 0.0111262, 0.102384, 0.00140808, 0.123581, - 0.29308, 6.57282e-06, 0.00489498, 2.10209e-05, 0.00140559, 5.907e-06, 0, 0.559322, - 0.559322, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0.794765, 0, - 0.352648, 0.225904, 1, 0.047619, 0.0107276, 0.399461, 0.0304838, 0.292932, 0.00969929, - 0, 0, 0.886904, 0.714693, 0, 0.00223213, 0.000544069, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0.00507403, 0, 0, 0, 0, 0, 0.875, 0, 0, 1, 1, 1, 0, 0.20564, 0, 0.00176048, 0, - 0.000440121, 0, 0, 0, 0.000974026, 0.487168, 0, 0, 0.533333, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 1, 0, 0, 0.723187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0.206882, 0.00483367, 0.792983, 0.00126106, 1, 0.0313726, 0.470588, - 0.254902, 0.188235, 0.188235, 0.388235, 0.164706, 0, 0.870588, 0.843137, 0.635294, - 0.384314, 0.384314, 0.643137, 0, 0, 0, 0, 0, 0, 0, 0, 0.541176, 0, 0.541176, 0, 0, - 0.0532634, 1, 0, 0, 0, 0.015044, 1, 0, 1, 1, 1, 0.47451, 0.329412, 0.964706, 0, 0, - 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0941176, 0.970588, 0.970588, 0, 0.970588, 0.97561, - 0, 0.0431373, 0.47451, 0.329412, 0.964706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.231373, 0.00392157, 0, 0, 0, 0.054902, 0, 0, - 1, 0, 0, 0.0235294, 0, 1, 0, 0, 0, 0, 0.34902, 0.0352941, 0.925379, 0.623681, 0, - 0.954543, 0, 0, 0.00102756, 0.709804, 0.498039, 0.0901961, 0.631373, 0.847059, 0.270588, - 0.0156863, 0.133333, 0.980392, 1e-12, 1e-12, 1e-12, 1e-12, 0.497159, 0, 0.407487, - 0, 0, 0, 0.00392157, 0.00202156, 0.046875, 0.187159, 0.046875, 0.15625, 0.434232, - 0.15625, 0, 2.95083e-07, 0.20564, 0.20564, 0.97561, 0.913896, 0, 0, 0, 0, 0, 0, 0.00784314, - 0, 0.695525, 1, 0.07205, 0, 0, 0.176471, 0, 0, 0, 1, 1, 0.98, 0.01, 0.01, 0, 0.00690702, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.29078, 0.29078, 1, 0, 0, 0, 0, 0.192157, 0.188235, - 0.0941176, 0, 0.0313726, 0, 0.141176, 0.207843, 0.0901961, 0.00784314, 0.0784314, - 0, 0, 0, 0, 0, 0.203922, 0.0196078, 0.34902, 0.0235294, 0.0980392, 0.164706, 0.133333, - 0.368627, 0, 0.0941176, 0, 1, 0.313726, 0, 0, 0.433582, 0.384508, 0.0532186, 0.0833333, - 0.01609, 0, 1, 0, 0, 0, 0.0666667, 0, 0, 0, 0, 1, 0, 0.564706, 0.501961, 0, 0, 0, - 0, 0, 0.0516447, 0.000173065, 0, 0, 0, 0, 0, 0, 0, 0.996309, 0, 0, 0.00392157, 1, - 0, 0.01, 0, 0, 0, 0, 0, 0.439505, 0.206882, 0.206882, 0.260891, 0, 0.875, 0, 0, 0, - 0, 0, 0.185657, 1, 1, 0, 0, 0, 0.0332647, 0.206106, 0.0688878, 0.239216, 0, 0, 0, - 0, 0.054902, 0, 0.101961, 0.160784, 0.180392, 0, 0.737828, 0, 0, 0.875, 0.0142566, - 0, 0.662745, 1, 0, 0, 0, 0.225806, 0.99992, 0.631373, 0.00392157, 1, 0, 0.143647, - 0.00270085, 1, 0.231482, 0.246735, 0.0428062, 0, 0, 1, 0, 0.186441, 0.0115358, 0, - 0.221762, 0, 0.2, 0, 0.0156863, 0, 0, 0, 0.976471, 0, 0.231373, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0.00392157, 0.00392157, 0.0666667, 0, 0, 0, 0, 0.0117647, 0.580392, 0.98737, - 1, 1, 1, 0, 0, 0, 0.153, 0.847, 0.931373, 0.94697, 0.94697, 0, 0.946294, 0.408118, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0.99992, 0.97561, 0, 0, 0, 0, 0, 0, - 0.274677, 0.153017, 0, 0.642356, 0, 0, 0.1, 0, 0, 0, 0, 0.327944, 0.327944, 0, 0, - 0.815686, 0, 0, 0, 0, 0.206106, 0.439126, 0, 0, 0, 0, 0, 1, 1, 1, 0.00392157, 0.232788, - 0.232465, 0.999899, 0.00309296, 0.0636097, 0.445954, 0.156863, 0, 0, 0, 0, 0, 0, - 0.3796, 0.0784, 0.0651664, 0, 0, 0.254902, 0.266667, 1, 0, 0, 0, 0, 0, 0.596073, - 0.517876, 0.145833, 0.372549, 0, 0.991667, 0.602125, 0.161979, 0, 0, 0, 0, 0.0255146, - 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, - 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, - 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; - -const ui8 CodedFactors[] = { - 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, - 0x5A, 0x1A, 0x93, 0x5F, 0x5F, 0x13, 0x00, 0x00, 0x10, 0x00, 0x3D, 0xEF, 0xFF, 0xEE, 0x0F, 0xDC, - 0xF0, 0xAB, 0x3F, 0x37, 0x92, 0x24, 0x5D, 0x5E, 0xDE, 0x1C, 0xF8, 0x12, 0x15, 0x5B, 0x84, 0x51, - 0x82, 0xE6, 0xF6, 0xB8, 0xEA, 0x4F, 0xC7, 0xDD, 0x7D, 0x2E, 0x4D, 0x4A, 0x21, 0xCA, 0xE0, 0xC4, - 0x2E, 0xEA, 0xD3, 0xBD, 0x0F, 0x00, 0x00, 0xE0, 0xDA, 0xCC, 0xCC, 0xEC, 0x9F, 0x61, 0xDF, 0xE6, - 0x01, 0x00, 0x00, 0xCC, 0xA5, 0x49, 0xA9, 0x00, 0x00, 0x00, 0xE6, 0xD2, 0xA4, 0xD4, 0xEA, 0x08, - 0x08, 0xD0, 0xDD, 0xF9, 0xE7, 0xA2, 0x0B, 0x00, 0x00, 0x40, 0xD8, 0x13, 0x7D, 0xFE, 0x13, 0x9C, - 0x9B, 0xA8, 0x36, 0xBC, 0x00, 0x90, 0x43, 0x6F, 0x97, 0x67, 0x9B, 0xD3, 0xEE, 0xFE, 0x84, 0x24, - 0x25, 0x89, 0xC9, 0xBF, 0x3F, 0x58, 0x4C, 0x4C, 0xCA, 0x21, 0x22, 0xBC, 0x39, 0x08, 0x08, 0x08, - 0x40, 0x7E, 0xAA, 0xAA, 0xCA, 0x75, 0x70, 0x70, 0xE9, 0x08, 0x08, 0xE8, 0x9A, 0x8A, 0x8D, 0xED, - 0xA6, 0x8D, 0x31, 0x04, 0x00, 0x96, 0xD0, 0x7D, 0x1D, 0x47, 0xAA, 0x2A, 0xD9, 0x28, 0xAD, 0x6B, - 0xB4, 0x9D, 0x7A, 0xC4, 0xD5, 0xD1, 0x04, 0x8C, 0x7E, 0x56, 0x3A, 0x58, 0x5A, 0x0C, 0x46, 0x6E, - 0x1B, 0x53, 0xC2, 0x0C, 0x14, 0x00, 0xAB, 0x60, 0x05, 0x7B, 0x63, 0x8D, 0x77, 0x70, 0x75, 0xAC, - 0x2F, 0x8D, 0xB1, 0x4D, 0xA0, 0xFB, 0xF2, 0x40, 0xF7, 0xE5, 0x7F, 0xDF, 0xDD, 0xFD, 0xBB, 0x1B, - 0xB8, 0x75, 0x9B, 0x47, 0x8E, 0xB4, 0x0C, 0x9B, 0x3A, 0x73, 0x25, 0x61, 0x18, 0x92, 0xD1, 0xC2, - 0x2F, 0x3C, 0x31, 0x64, 0x96, 0x2A, 0xB9, 0xF9, 0x7C, 0xD9, 0xAF, 0x94, 0xC5, 0xE9, 0x1E, 0x63, - 0x24, 0x0C, 0x03, 0x7F, 0xD8, 0x5B, 0xB3, 0x1D, 0x49, 0x02, 0x00, 0xAB, 0xFD, 0xE9, 0xA0, 0xF3, - 0xBF, 0xC9, 0x40, 0x64, 0x0A, 0xC0, 0xC7, 0x00, 0x00, 0x60, 0x77, 0xCF, 0xA5, 0x49, 0xA9, 0x16, - 0xFD, 0xD7, 0x5C, 0xA7, 0x55, 0x00, 0x36, 0xCF, 0xB9, 0x3D, 0xAE, 0xFA, 0xD3, 0xA1, 0x85, 0x5B, - 0xFE, 0x60, 0x10, 0x11, 0xFF, 0xF7, 0x7D, 0x38, 0x59, 0x24, 0xFF, 0xFF, 0xDF, 0x13, 0x1C, 0x7B, - 0xCA, 0x1C, 0x1E, 0xF3, 0x04, 0xC0, 0x78, 0x07, 0x58, 0x7B, 0xA2, 0x54, 0xAA, 0xE3, 0xEA, 0x08, - 0x08, 0xC0, 0x74, 0x78, 0x78, 0x88, 0x50, 0x50, 0xD8, 0x0A, 0x0C, 0xC4, 0x56, 0x60, 0x20, 0xF6, - 0x1A, 0x1B, 0x33, 0x16, 0x15, 0xA5, 0xB8, 0xED, 0xED, 0x22, 0xF5, 0xF5, 0x09, 0xA1, 0xA2, 0x42, - 0x67, 0x62, 0x62, 0x3A, 0x13, 0x13, 0x0B, 0xA0, 0xA4, 0xF4, 0x0F, 0x06, 0x15, 0x35, 0x18, 0x54, - 0xD4, 0x35, 0x57, 0x45, 0xCB, 0x2F, 0x39, 0xF6, 0xEC, 0xBC, 0xBB, 0x53, 0x5F, 0x5E, 0x9E, 0xB1, - 0xA8, 0xA8, 0x28, 0xDF, 0xDE, 0x3E, 0x00, 0x00, 0x80, 0x5F, 0x75, 0x81, 0x81, 0x51, 0x1D, 0x1E, - 0xA2, 0x3A, 0x3C, 0x8C, 0xEA, 0xF0, 0x10, 0x51, 0x06, 0x67, 0xED, 0x85, 0x85, 0xA1, 0xBE, 0xBC, - 0x3C, 0x63, 0x51, 0x51, 0x51, 0xBE, 0xBD, 0xFD, 0xFF, 0xFD, 0xFE, 0xCE, 0x85, 0x76, 0x36, 0x73, - 0x10, 0x10, 0x10, 0x80, 0xEB, 0x3A, 0x38, 0xD8, 0xBE, 0xD4, 0x05, 0x06, 0xEE, 0x4F, 0x60, 0x59, - 0x59, 0x65, 0x84, 0x84, 0xC0, 0x46, 0xCB, 0x19, 0x7F, 0x4C, 0xFD, 0xC8, 0x9D, 0x8B, 0xB6, 0x31, - 0xAF, 0x86, 0x3A, 0xF0, 0x6D, 0x6D, 0x11, 0xDF, 0xDF, 0x5F, 0x79, 0x71, 0x71, 0x85, 0xD4, 0xD0, - 0x10, 0xB9, 0xB1, 0x11, 0x1A, 0x54, 0x54, 0xE9, 0x08, 0x08, 0x48, 0x39, 0x44, 0x04, 0x84, 0xAF, - 0xAF, 0x96, 0x99, 0x97, 0x71, 0xC5, 0x32, 0xF3, 0x32, 0xAE, 0x58, 0x66, 0x5E, 0xC6, 0x15, 0xCB, - 0xCC, 0xCB, 0xB8, 0x42, 0xD0, 0x45, 0xFF, 0x1C, 0x11, 0x85, 0xBE, 0x39, 0x08, 0x08, 0x08, 0x80, - 0x69, 0xC2, 0x47, 0x00, 0x80, 0x02, 0x00, 0x00, 0x91, 0xD3, 0xF4, 0x47, 0x01, 0x00, 0x80, 0x08, - 0x00, 0x00, 0x42, 0xD4, 0x29, 0x6F, 0x02, 0x00, 0x80, 0xB4, 0xE6, 0x6B, 0x9E, 0x34, 0x5C, 0x9A, - 0x94, 0xE2, 0xD2, 0xA4, 0x14, 0xA2, 0x0C, 0x4E, 0xEC, 0xA2, 0x3E, 0x7F, 0x39, 0x08, 0x08, 0x10, - 0x6E, 0x6F, 0x10, 0xD7, 0x79, 0xC7, 0xC9, 0x09, 0x4D, 0x4B, 0x73, 0x77, 0x84, 0x14, 0xAE, 0x52, - 0xE1, 0x7A, 0x44, 0x2A, 0x5C, 0x8F, 0x34, 0x93, 0xA8, 0xC4, 0x01, 0xF8, 0x3F, 0x3D, 0xC2, 0x29, - 0xE9, 0x11, 0x4E, 0xE9, 0x4F, 0x67, 0x62, 0x22, 0xB6, 0x02, 0x03, 0xA9, 0x2E, 0x30, 0x70, 0x75, - 0x04, 0x04, 0xC8, 0x38, 0x48, 0x08, 0x32, 0x53, 0x53, 0x29, 0x2F, 0x2E, 0xAE, 0x1C, 0x04, 0x04, - 0x50, 0x52, 0x50, 0xD0, 0x4F, 0x77, 0x68, 0x28, 0x99, 0x08, 0x0A, 0x4A, 0x60, 0x59, 0x59, 0xA9, - 0x0B, 0x0C, 0xAC, 0xC7, 0xC8, 0xC8, 0x8C, 0x45, 0x45, 0xA1, 0x1C, 0x22, 0x02, 0x5D, 0x79, 0x79, - 0xAB, 0x2E, 0x30, 0x70, 0xA7, 0x2C, 0x28, 0xE8, 0xB4, 0xF3, 0xEF, 0x26, 0x8F, 0x37, 0xB1, 0xFE, - 0xEE, 0x67, 0xA9, 0xA9, 0xAA, 0xAA, 0x6C, 0x79, 0x1E, 0xEC, 0xD7, 0x46, 0x44, 0xC4, 0xF7, 0xF8, - 0x24, 0x24, 0x00, 0x42, 0x40, 0xF8, 0x5A, 0x96, 0x38, 0x65, 0x91, 0xF1, 0x6A, 0x72, 0xFE, 0x68, - 0xC3, 0xE1, 0x37, 0x07, 0x01, 0x01, 0x01, 0xF0, 0x52, 0xE1, 0x7A, 0xE4, 0xB3, 0xD9, 0x20, 0x9C, - 0xE0, 0xD8, 0x53, 0x04, 0xC7, 0x9E, 0x82, 0x02, 0x27, 0x2B, 0x06, 0x00, 0x00, 0x9F, 0xDE, 0x1C, - 0x3E, 0xEE, 0xD7, 0x48, 0x20, 0x04, 0xD2, 0x35, 0x4C, 0x29, 0x43, 0x45, 0x23, 0x15, 0xEA, 0xE9, - 0x5E, 0xD7, 0xC1, 0xC1, 0xAA, 0x3B, 0x34, 0x34, 0x21, 0x49, 0x49, 0xE8, 0x8A, 0x8B, 0x13, 0x66, - 0x12, 0xE7, 0x31, 0x00, 0x00, 0x90, 0x84, 0x94, 0x69, 0x05, 0xD4, 0xD4, 0xF4, 0x13, 0x36, 0xE7, - 0x0C, 0x09, 0xEB, 0xBF, 0x90, 0x1A, 0x1A, 0xE6, 0x20, 0x20, 0x20, 0x00, 0x9E, 0x33, 0x18, 0x13, - 0xA6, 0x2F, 0x40, 0x0C, 0x00, 0x4E, 0xCF, 0x84, 0x36, 0x6A, 0xA0, 0xF2, 0xA9, 0x63, 0xD5, 0xCB, - 0x9E, 0x64, 0xEA, 0x3E, 0xF2, 0x14, 0xA0, 0x27, 0x29, 0x2B, 0xC6, 0xB2, 0x99, 0x99, 0xA9, 0x74, - 0x04, 0x04, 0x3C, 0x0A, 0xD0, 0xCF, 0x5C, 0x68, 0x67, 0xFB, 0xDF, 0x1C, 0x04, 0x04, 0x04, 0xC0, - 0x1C, 0x04, 0x04, 0x04, 0x40, 0x1B, 0x11, 0x11, 0x5F, 0xEA, 0x02, 0x03, 0xE1, 0x92, 0x94, 0x84, - 0x90, 0x88, 0xD9, 0xDD, 0x4F, 0x04, 0x56, 0x0E, 0xD1, 0x9F, 0x1A, 0x31, 0x3B, 0x37, 0x47, 0xA0, - 0x6C, 0x82, 0x40, 0xD9, 0x24, 0x9A, 0x02, 0x12, 0x62, 0xD3, 0x43, 0xFF, 0xBF, 0x8F, 0x84, 0xF5, - 0x1F, 0x51, 0x06, 0xE7, 0x0F, 0xDD, 0x89, 0x32, 0xFB, 0x60, 0x39, 0x0A, 0x71, 0x71, 0xB4, 0x36, - 0x33, 0x33, 0x3F, 0x8F, 0xD0, 0x4F, 0x79, 0x84, 0x7E, 0xBA, 0xC8, 0x0C, 0x0D, 0x4F, 0xBA, 0x86, - 0x29, 0x82, 0x54, 0x83, 0x7F, 0x77, 0x37, 0x07, 0x01, 0x01, 0x01, 0xA0, 0xFE, 0x97, 0x1B, 0x9D, - 0x16, 0xDC, 0x90, 0x58, 0xFE, 0x9B, 0x42, 0xB3, 0x4A, 0x00, 0x68, 0x73, 0x91, 0x20, 0x2B, 0xA8, - 0xC8, 0x29, 0x0B, 0x0A, 0xF2, 0xD3, 0x5D, 0x4B, 0x58, 0x5D, 0x20, 0x41, 0xD5, 0xBE, 0xAE, 0x70, - 0x88, 0x50, 0x50, 0x20, 0x4A, 0x44, 0xF4, 0x8F, 0xF7, 0x60, 0x22, 0x30, 0x9C, 0x24, 0xFE, 0x54, - 0x55, 0xD0, 0xD7, 0xD7, 0x37, 0x1A, 0xEF, 0x6E, 0xBC, 0x9B, 0x44, 0x39, 0xDD, 0x5D, 0xF2, 0xF2, - 0x7F, 0x20, 0x1A, 0x81, 0x9A, 0xCA, 0xBF, 0xC8, 0x8D, 0x8D, 0xC2, 0x83, 0x82, 0xA7, 0x2C, 0x28, - 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, - 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, - 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), Y_ARRAY_SIZE(CodedFactors)); - -void BM_Encode(benchmark::State& state) { - for (const auto _ : state) { - NCodecs::NFloatHuff::Encode(Factors); - } -} - -void BM_Decode(benchmark::State& state) { - for (const auto _ : state) { - NCodecs::NFloatHuff::Decode(CodedFactorsBuf, Y_ARRAY_SIZE(Factors)); - } -} - -BENCHMARK(BM_Encode); -BENCHMARK(BM_Decode); +#include <library/cpp/codecs/float_huffman.h> + +#include <benchmark/benchmark.h> + +#include <util/generic/vector.h> + +const float Factors[] = { + 0.340582, 0.000974026, 0.487168, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0.411765, 0.921569, + 0.00390625, 0.109371, 0, 1, 0, 0, 0, 0, 0.523322, 0, 1, 0, 0, 0, 0, 0.285714, 1, + 0.008253, 1, 0, 0, 0.00993935, 0.450213, 0.000974026, 1, 1, 1, 1, 0, 0, 0.20564, + 0.97561, 0.913896, 1, 1, 0, 1, 0, 0, 0.5, 0, 0, 0, 0.1, 1, 0, 0, 0, 0, 0, 0.450923, + 0, 0.5, 0, 0, 0.20564, 0, 0.5, 0, 0, 0.20564, 0, 0, 0.0313726, 0, 1, 1, 1, 0.363636, + 0.5, 0.686073, 0.45121, 0.00574382, 0.366166, 0.413295, 1, 1, 1, 0, 0, 0, 0, 0.160784, + 0, 0.937255, 0.537255, 0.133333, 0, 0, 0, 0, 0.00392157, 0, 0.333333, 0.027451, 0.0156863, + 1, 0.105882, 1, 0.00220908, 0.000112501, 0.0111262, 0.102384, 0.00140808, 0.123581, + 0.29308, 6.57282e-06, 0.00489498, 2.10209e-05, 0.00140559, 5.907e-06, 0, 0.559322, + 0.559322, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0.794765, 0, + 0.352648, 0.225904, 1, 0.047619, 0.0107276, 0.399461, 0.0304838, 0.292932, 0.00969929, + 0, 0, 0.886904, 0.714693, 0, 0.00223213, 0.000544069, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0.00507403, 0, 0, 0, 0, 0, 0.875, 0, 0, 1, 1, 1, 0, 0.20564, 0, 0.00176048, 0, + 0.000440121, 0, 0, 0, 0.000974026, 0.487168, 0, 0, 0.533333, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 1, 0, 0, 0.723187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0.206882, 0.00483367, 0.792983, 0.00126106, 1, 0.0313726, 0.470588, + 0.254902, 0.188235, 0.188235, 0.388235, 0.164706, 0, 0.870588, 0.843137, 0.635294, + 0.384314, 0.384314, 0.643137, 0, 0, 0, 0, 0, 0, 0, 0, 0.541176, 0, 0.541176, 0, 0, + 0.0532634, 1, 0, 0, 0, 0.015044, 1, 0, 1, 1, 1, 0.47451, 0.329412, 0.964706, 0, 0, + 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0.0941176, 0.970588, 0.970588, 0, 0.970588, 0.97561, + 0, 0.0431373, 0.47451, 0.329412, 0.964706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.231373, 0.00392157, 0, 0, 0, 0.054902, 0, 0, + 1, 0, 0, 0.0235294, 0, 1, 0, 0, 0, 0, 0.34902, 0.0352941, 0.925379, 0.623681, 0, + 0.954543, 0, 0, 0.00102756, 0.709804, 0.498039, 0.0901961, 0.631373, 0.847059, 0.270588, + 0.0156863, 0.133333, 0.980392, 1e-12, 1e-12, 1e-12, 1e-12, 0.497159, 0, 0.407487, + 0, 0, 0, 0.00392157, 0.00202156, 0.046875, 0.187159, 0.046875, 0.15625, 0.434232, + 0.15625, 0, 2.95083e-07, 0.20564, 0.20564, 0.97561, 0.913896, 0, 0, 0, 0, 0, 0, 0.00784314, + 0, 0.695525, 1, 0.07205, 0, 0, 0.176471, 0, 0, 0, 1, 1, 0.98, 0.01, 0.01, 0, 0.00690702, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.29078, 0.29078, 1, 0, 0, 0, 0, 0.192157, 0.188235, + 0.0941176, 0, 0.0313726, 0, 0.141176, 0.207843, 0.0901961, 0.00784314, 0.0784314, + 0, 0, 0, 0, 0, 0.203922, 0.0196078, 0.34902, 0.0235294, 0.0980392, 0.164706, 0.133333, + 0.368627, 0, 0.0941176, 0, 1, 0.313726, 0, 0, 0.433582, 0.384508, 0.0532186, 0.0833333, + 0.01609, 0, 1, 0, 0, 0, 0.0666667, 0, 0, 0, 0, 1, 0, 0.564706, 0.501961, 0, 0, 0, + 0, 0, 0.0516447, 0.000173065, 0, 0, 0, 0, 0, 0, 0, 0.996309, 0, 0, 0.00392157, 1, + 0, 0.01, 0, 0, 0, 0, 0, 0.439505, 0.206882, 0.206882, 0.260891, 0, 0.875, 0, 0, 0, + 0, 0, 0.185657, 1, 1, 0, 0, 0, 0.0332647, 0.206106, 0.0688878, 0.239216, 0, 0, 0, + 0, 0.054902, 0, 0.101961, 0.160784, 0.180392, 0, 0.737828, 0, 0, 0.875, 0.0142566, + 0, 0.662745, 1, 0, 0, 0, 0.225806, 0.99992, 0.631373, 0.00392157, 1, 0, 0.143647, + 0.00270085, 1, 0.231482, 0.246735, 0.0428062, 0, 0, 1, 0, 0.186441, 0.0115358, 0, + 0.221762, 0, 0.2, 0, 0.0156863, 0, 0, 0, 0.976471, 0, 0.231373, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0.00392157, 0.00392157, 0.0666667, 0, 0, 0, 0, 0.0117647, 0.580392, 0.98737, + 1, 1, 1, 0, 0, 0, 0.153, 0.847, 0.931373, 0.94697, 0.94697, 0, 0.946294, 0.408118, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0.99992, 0.97561, 0, 0, 0, 0, 0, 0, + 0.274677, 0.153017, 0, 0.642356, 0, 0, 0.1, 0, 0, 0, 0, 0.327944, 0.327944, 0, 0, + 0.815686, 0, 0, 0, 0, 0.206106, 0.439126, 0, 0, 0, 0, 0, 1, 1, 1, 0.00392157, 0.232788, + 0.232465, 0.999899, 0.00309296, 0.0636097, 0.445954, 0.156863, 0, 0, 0, 0, 0, 0, + 0.3796, 0.0784, 0.0651664, 0, 0, 0.254902, 0.266667, 1, 0, 0, 0, 0, 0, 0.596073, + 0.517876, 0.145833, 0.372549, 0, 0.991667, 0.602125, 0.161979, 0, 0, 0, 0, 0.0255146, + 0.947855, 0, 0, 0, 0, 0, 0, 0, 0, 0.847059, 0.679841, 0, 0.156863, 0, 0, 1, 0, 0, + 0, 0, 0.969697, 0, 0, 0.564706, 0, 0, 0, 0, 0, 1, 0.0367282, 0.0395228, 0, 0, 0, + 0, 0, 0.0470588, 0.141176, 0.054902, 0, 0, 0, 0}; + +const ui8 CodedFactors[] = { + 0x24, 0x06, 0x73, 0xB5, 0xC7, 0x55, 0x7F, 0x3A, 0xB4, 0x70, 0xCB, 0xEF, 0xEE, 0xFE, 0xB3, 0x5B, + 0x5A, 0x1A, 0x93, 0x5F, 0x5F, 0x13, 0x00, 0x00, 0x10, 0x00, 0x3D, 0xEF, 0xFF, 0xEE, 0x0F, 0xDC, + 0xF0, 0xAB, 0x3F, 0x37, 0x92, 0x24, 0x5D, 0x5E, 0xDE, 0x1C, 0xF8, 0x12, 0x15, 0x5B, 0x84, 0x51, + 0x82, 0xE6, 0xF6, 0xB8, 0xEA, 0x4F, 0xC7, 0xDD, 0x7D, 0x2E, 0x4D, 0x4A, 0x21, 0xCA, 0xE0, 0xC4, + 0x2E, 0xEA, 0xD3, 0xBD, 0x0F, 0x00, 0x00, 0xE0, 0xDA, 0xCC, 0xCC, 0xEC, 0x9F, 0x61, 0xDF, 0xE6, + 0x01, 0x00, 0x00, 0xCC, 0xA5, 0x49, 0xA9, 0x00, 0x00, 0x00, 0xE6, 0xD2, 0xA4, 0xD4, 0xEA, 0x08, + 0x08, 0xD0, 0xDD, 0xF9, 0xE7, 0xA2, 0x0B, 0x00, 0x00, 0x40, 0xD8, 0x13, 0x7D, 0xFE, 0x13, 0x9C, + 0x9B, 0xA8, 0x36, 0xBC, 0x00, 0x90, 0x43, 0x6F, 0x97, 0x67, 0x9B, 0xD3, 0xEE, 0xFE, 0x84, 0x24, + 0x25, 0x89, 0xC9, 0xBF, 0x3F, 0x58, 0x4C, 0x4C, 0xCA, 0x21, 0x22, 0xBC, 0x39, 0x08, 0x08, 0x08, + 0x40, 0x7E, 0xAA, 0xAA, 0xCA, 0x75, 0x70, 0x70, 0xE9, 0x08, 0x08, 0xE8, 0x9A, 0x8A, 0x8D, 0xED, + 0xA6, 0x8D, 0x31, 0x04, 0x00, 0x96, 0xD0, 0x7D, 0x1D, 0x47, 0xAA, 0x2A, 0xD9, 0x28, 0xAD, 0x6B, + 0xB4, 0x9D, 0x7A, 0xC4, 0xD5, 0xD1, 0x04, 0x8C, 0x7E, 0x56, 0x3A, 0x58, 0x5A, 0x0C, 0x46, 0x6E, + 0x1B, 0x53, 0xC2, 0x0C, 0x14, 0x00, 0xAB, 0x60, 0x05, 0x7B, 0x63, 0x8D, 0x77, 0x70, 0x75, 0xAC, + 0x2F, 0x8D, 0xB1, 0x4D, 0xA0, 0xFB, 0xF2, 0x40, 0xF7, 0xE5, 0x7F, 0xDF, 0xDD, 0xFD, 0xBB, 0x1B, + 0xB8, 0x75, 0x9B, 0x47, 0x8E, 0xB4, 0x0C, 0x9B, 0x3A, 0x73, 0x25, 0x61, 0x18, 0x92, 0xD1, 0xC2, + 0x2F, 0x3C, 0x31, 0x64, 0x96, 0x2A, 0xB9, 0xF9, 0x7C, 0xD9, 0xAF, 0x94, 0xC5, 0xE9, 0x1E, 0x63, + 0x24, 0x0C, 0x03, 0x7F, 0xD8, 0x5B, 0xB3, 0x1D, 0x49, 0x02, 0x00, 0xAB, 0xFD, 0xE9, 0xA0, 0xF3, + 0xBF, 0xC9, 0x40, 0x64, 0x0A, 0xC0, 0xC7, 0x00, 0x00, 0x60, 0x77, 0xCF, 0xA5, 0x49, 0xA9, 0x16, + 0xFD, 0xD7, 0x5C, 0xA7, 0x55, 0x00, 0x36, 0xCF, 0xB9, 0x3D, 0xAE, 0xFA, 0xD3, 0xA1, 0x85, 0x5B, + 0xFE, 0x60, 0x10, 0x11, 0xFF, 0xF7, 0x7D, 0x38, 0x59, 0x24, 0xFF, 0xFF, 0xDF, 0x13, 0x1C, 0x7B, + 0xCA, 0x1C, 0x1E, 0xF3, 0x04, 0xC0, 0x78, 0x07, 0x58, 0x7B, 0xA2, 0x54, 0xAA, 0xE3, 0xEA, 0x08, + 0x08, 0xC0, 0x74, 0x78, 0x78, 0x88, 0x50, 0x50, 0xD8, 0x0A, 0x0C, 0xC4, 0x56, 0x60, 0x20, 0xF6, + 0x1A, 0x1B, 0x33, 0x16, 0x15, 0xA5, 0xB8, 0xED, 0xED, 0x22, 0xF5, 0xF5, 0x09, 0xA1, 0xA2, 0x42, + 0x67, 0x62, 0x62, 0x3A, 0x13, 0x13, 0x0B, 0xA0, 0xA4, 0xF4, 0x0F, 0x06, 0x15, 0x35, 0x18, 0x54, + 0xD4, 0x35, 0x57, 0x45, 0xCB, 0x2F, 0x39, 0xF6, 0xEC, 0xBC, 0xBB, 0x53, 0x5F, 0x5E, 0x9E, 0xB1, + 0xA8, 0xA8, 0x28, 0xDF, 0xDE, 0x3E, 0x00, 0x00, 0x80, 0x5F, 0x75, 0x81, 0x81, 0x51, 0x1D, 0x1E, + 0xA2, 0x3A, 0x3C, 0x8C, 0xEA, 0xF0, 0x10, 0x51, 0x06, 0x67, 0xED, 0x85, 0x85, 0xA1, 0xBE, 0xBC, + 0x3C, 0x63, 0x51, 0x51, 0x51, 0xBE, 0xBD, 0xFD, 0xFF, 0xFD, 0xFE, 0xCE, 0x85, 0x76, 0x36, 0x73, + 0x10, 0x10, 0x10, 0x80, 0xEB, 0x3A, 0x38, 0xD8, 0xBE, 0xD4, 0x05, 0x06, 0xEE, 0x4F, 0x60, 0x59, + 0x59, 0x65, 0x84, 0x84, 0xC0, 0x46, 0xCB, 0x19, 0x7F, 0x4C, 0xFD, 0xC8, 0x9D, 0x8B, 0xB6, 0x31, + 0xAF, 0x86, 0x3A, 0xF0, 0x6D, 0x6D, 0x11, 0xDF, 0xDF, 0x5F, 0x79, 0x71, 0x71, 0x85, 0xD4, 0xD0, + 0x10, 0xB9, 0xB1, 0x11, 0x1A, 0x54, 0x54, 0xE9, 0x08, 0x08, 0x48, 0x39, 0x44, 0x04, 0x84, 0xAF, + 0xAF, 0x96, 0x99, 0x97, 0x71, 0xC5, 0x32, 0xF3, 0x32, 0xAE, 0x58, 0x66, 0x5E, 0xC6, 0x15, 0xCB, + 0xCC, 0xCB, 0xB8, 0x42, 0xD0, 0x45, 0xFF, 0x1C, 0x11, 0x85, 0xBE, 0x39, 0x08, 0x08, 0x08, 0x80, + 0x69, 0xC2, 0x47, 0x00, 0x80, 0x02, 0x00, 0x00, 0x91, 0xD3, 0xF4, 0x47, 0x01, 0x00, 0x80, 0x08, + 0x00, 0x00, 0x42, 0xD4, 0x29, 0x6F, 0x02, 0x00, 0x80, 0xB4, 0xE6, 0x6B, 0x9E, 0x34, 0x5C, 0x9A, + 0x94, 0xE2, 0xD2, 0xA4, 0x14, 0xA2, 0x0C, 0x4E, 0xEC, 0xA2, 0x3E, 0x7F, 0x39, 0x08, 0x08, 0x10, + 0x6E, 0x6F, 0x10, 0xD7, 0x79, 0xC7, 0xC9, 0x09, 0x4D, 0x4B, 0x73, 0x77, 0x84, 0x14, 0xAE, 0x52, + 0xE1, 0x7A, 0x44, 0x2A, 0x5C, 0x8F, 0x34, 0x93, 0xA8, 0xC4, 0x01, 0xF8, 0x3F, 0x3D, 0xC2, 0x29, + 0xE9, 0x11, 0x4E, 0xE9, 0x4F, 0x67, 0x62, 0x22, 0xB6, 0x02, 0x03, 0xA9, 0x2E, 0x30, 0x70, 0x75, + 0x04, 0x04, 0xC8, 0x38, 0x48, 0x08, 0x32, 0x53, 0x53, 0x29, 0x2F, 0x2E, 0xAE, 0x1C, 0x04, 0x04, + 0x50, 0x52, 0x50, 0xD0, 0x4F, 0x77, 0x68, 0x28, 0x99, 0x08, 0x0A, 0x4A, 0x60, 0x59, 0x59, 0xA9, + 0x0B, 0x0C, 0xAC, 0xC7, 0xC8, 0xC8, 0x8C, 0x45, 0x45, 0xA1, 0x1C, 0x22, 0x02, 0x5D, 0x79, 0x79, + 0xAB, 0x2E, 0x30, 0x70, 0xA7, 0x2C, 0x28, 0xE8, 0xB4, 0xF3, 0xEF, 0x26, 0x8F, 0x37, 0xB1, 0xFE, + 0xEE, 0x67, 0xA9, 0xA9, 0xAA, 0xAA, 0x6C, 0x79, 0x1E, 0xEC, 0xD7, 0x46, 0x44, 0xC4, 0xF7, 0xF8, + 0x24, 0x24, 0x00, 0x42, 0x40, 0xF8, 0x5A, 0x96, 0x38, 0x65, 0x91, 0xF1, 0x6A, 0x72, 0xFE, 0x68, + 0xC3, 0xE1, 0x37, 0x07, 0x01, 0x01, 0x01, 0xF0, 0x52, 0xE1, 0x7A, 0xE4, 0xB3, 0xD9, 0x20, 0x9C, + 0xE0, 0xD8, 0x53, 0x04, 0xC7, 0x9E, 0x82, 0x02, 0x27, 0x2B, 0x06, 0x00, 0x00, 0x9F, 0xDE, 0x1C, + 0x3E, 0xEE, 0xD7, 0x48, 0x20, 0x04, 0xD2, 0x35, 0x4C, 0x29, 0x43, 0x45, 0x23, 0x15, 0xEA, 0xE9, + 0x5E, 0xD7, 0xC1, 0xC1, 0xAA, 0x3B, 0x34, 0x34, 0x21, 0x49, 0x49, 0xE8, 0x8A, 0x8B, 0x13, 0x66, + 0x12, 0xE7, 0x31, 0x00, 0x00, 0x90, 0x84, 0x94, 0x69, 0x05, 0xD4, 0xD4, 0xF4, 0x13, 0x36, 0xE7, + 0x0C, 0x09, 0xEB, 0xBF, 0x90, 0x1A, 0x1A, 0xE6, 0x20, 0x20, 0x20, 0x00, 0x9E, 0x33, 0x18, 0x13, + 0xA6, 0x2F, 0x40, 0x0C, 0x00, 0x4E, 0xCF, 0x84, 0x36, 0x6A, 0xA0, 0xF2, 0xA9, 0x63, 0xD5, 0xCB, + 0x9E, 0x64, 0xEA, 0x3E, 0xF2, 0x14, 0xA0, 0x27, 0x29, 0x2B, 0xC6, 0xB2, 0x99, 0x99, 0xA9, 0x74, + 0x04, 0x04, 0x3C, 0x0A, 0xD0, 0xCF, 0x5C, 0x68, 0x67, 0xFB, 0xDF, 0x1C, 0x04, 0x04, 0x04, 0xC0, + 0x1C, 0x04, 0x04, 0x04, 0x40, 0x1B, 0x11, 0x11, 0x5F, 0xEA, 0x02, 0x03, 0xE1, 0x92, 0x94, 0x84, + 0x90, 0x88, 0xD9, 0xDD, 0x4F, 0x04, 0x56, 0x0E, 0xD1, 0x9F, 0x1A, 0x31, 0x3B, 0x37, 0x47, 0xA0, + 0x6C, 0x82, 0x40, 0xD9, 0x24, 0x9A, 0x02, 0x12, 0x62, 0xD3, 0x43, 0xFF, 0xBF, 0x8F, 0x84, 0xF5, + 0x1F, 0x51, 0x06, 0xE7, 0x0F, 0xDD, 0x89, 0x32, 0xFB, 0x60, 0x39, 0x0A, 0x71, 0x71, 0xB4, 0x36, + 0x33, 0x33, 0x3F, 0x8F, 0xD0, 0x4F, 0x79, 0x84, 0x7E, 0xBA, 0xC8, 0x0C, 0x0D, 0x4F, 0xBA, 0x86, + 0x29, 0x82, 0x54, 0x83, 0x7F, 0x77, 0x37, 0x07, 0x01, 0x01, 0x01, 0xA0, 0xFE, 0x97, 0x1B, 0x9D, + 0x16, 0xDC, 0x90, 0x58, 0xFE, 0x9B, 0x42, 0xB3, 0x4A, 0x00, 0x68, 0x73, 0x91, 0x20, 0x2B, 0xA8, + 0xC8, 0x29, 0x0B, 0x0A, 0xF2, 0xD3, 0x5D, 0x4B, 0x58, 0x5D, 0x20, 0x41, 0xD5, 0xBE, 0xAE, 0x70, + 0x88, 0x50, 0x50, 0x20, 0x4A, 0x44, 0xF4, 0x8F, 0xF7, 0x60, 0x22, 0x30, 0x9C, 0x24, 0xFE, 0x54, + 0x55, 0xD0, 0xD7, 0xD7, 0x37, 0x1A, 0xEF, 0x6E, 0xBC, 0x9B, 0x44, 0x39, 0xDD, 0x5D, 0xF2, 0xF2, + 0x7F, 0x20, 0x1A, 0x81, 0x9A, 0xCA, 0xBF, 0xC8, 0x8D, 0x8D, 0xC2, 0x83, 0x82, 0xA7, 0x2C, 0x28, + 0xC8, 0xFE, 0x08, 0xC2, 0x07, 0xC7, 0x27, 0x21, 0xE1, 0xBB, 0x3E, 0xC1, 0x59, 0x68, 0xAA, 0x78, + 0xC8, 0x57, 0x5D, 0x60, 0x20, 0xC6, 0x41, 0x42, 0xE8, 0x3A, 0x38, 0xD8, 0x9B, 0xFF, 0xFF, 0xFF, + 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), Y_ARRAY_SIZE(CodedFactors)); + +void BM_Encode(benchmark::State& state) { + for (const auto _ : state) { + NCodecs::NFloatHuff::Encode(Factors); + } +} + +void BM_Decode(benchmark::State& state) { + for (const auto _ : state) { + NCodecs::NFloatHuff::Decode(CodedFactorsBuf, Y_ARRAY_SIZE(Factors)); + } +} + +BENCHMARK(BM_Encode); +BENCHMARK(BM_Decode); diff --git a/library/cpp/codecs/float_huffman_bench/ya.make b/library/cpp/codecs/float_huffman_bench/ya.make index 8892fff60e..c8fae6873a 100644 --- a/library/cpp/codecs/float_huffman_bench/ya.make +++ b/library/cpp/codecs/float_huffman_bench/ya.make @@ -1,13 +1,13 @@ -OWNER(eeight) - -G_BENCHMARK() - -SRCS( - main.cpp -) - -PEERDIR( - library/cpp/codecs -) - -END() +OWNER(eeight) + +G_BENCHMARK() + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/codecs +) + +END() diff --git a/library/cpp/codecs/huffman_codec.h b/library/cpp/codecs/huffman_codec.h index 8b81e665e1..559545b90d 100644 --- a/library/cpp/codecs/huffman_codec.h +++ b/library/cpp/codecs/huffman_codec.h @@ -3,7 +3,7 @@ #include "codecs.h" #include <util/generic/ptr.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { // for types greater than char, pipeline with TFreqCodec. diff --git a/library/cpp/codecs/pfor_codec.h b/library/cpp/codecs/pfor_codec.h index 26b8fa0c33..d7d4bb8bf4 100644 --- a/library/cpp/codecs/pfor_codec.h +++ b/library/cpp/codecs/pfor_codec.h @@ -7,7 +7,7 @@ #include <library/cpp/bit_io/bitinput.h> #include <library/cpp/bit_io/bitoutput.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NCodecs { template <typename T, bool WithDelta = false> diff --git a/library/cpp/codecs/solar_codec.h b/library/cpp/codecs/solar_codec.h index d1ded5c208..7158ae7926 100644 --- a/library/cpp/codecs/solar_codec.h +++ b/library/cpp/codecs/solar_codec.h @@ -4,7 +4,7 @@ #include <library/cpp/containers/comptrie/comptrie_trie.h> #include <library/cpp/codecs/greedy_dict/gd_builder.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/escape.h> namespace NCodecs { diff --git a/library/cpp/codecs/ut/float_huffman_ut.cpp b/library/cpp/codecs/ut/float_huffman_ut.cpp index 91bf9b42b3..3156fb1f46 100644 --- a/library/cpp/codecs/ut/float_huffman_ut.cpp +++ b/library/cpp/codecs/ut/float_huffman_ut.cpp @@ -167,32 +167,32 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { } Y_UNIT_TEST(TestCompress) { - const auto codedFactors = fh::Encode(Factors); + const auto codedFactors = fh::Encode(Factors); UNIT_ASSERT_VALUES_EQUAL(codedFactors.size(), CodedSize); for (size_t i = 0; i < Min(codedFactors.size(), CodedSize); ++i) - UNIT_ASSERT_VALUES_EQUAL((ui8)codedFactors[i], CodedFactors[i]); + UNIT_ASSERT_VALUES_EQUAL((ui8)codedFactors[i], CodedFactors[i]); //PrintCompressed(codedFactors); } Y_UNIT_TEST(TestSimpleDecompress) { - TVector<float> factors = fh::Decode(CodedFactorsBuf); + TVector<float> factors = fh::Decode(CodedFactorsBuf); UNIT_ASSERT_VALUES_EQUAL(factors.size(), FactorCount); for (size_t i = 0; i < Min(factors.size(), FactorCount); ++i) UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[i]); //PrintDecompressed(factors); } - Y_UNIT_TEST(TestDecompressInParts) { + Y_UNIT_TEST(TestDecompressInParts) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); - fh::TDecoder decoder(CodedFactorsBuf); + fh::TDecoder decoder(CodedFactorsBuf); const size_t firstPack = 100; // unpack first pack - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); // unpack all the rest - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, FactorCount - firstPack}), FactorCount - firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, FactorCount - firstPack}), FactorCount - firstPack); - for (size_t i = 0; i < FactorCount; ++i) + for (size_t i = 0; i < FactorCount; ++i) UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[i]); //PrintDecompressed(factors); } @@ -200,18 +200,18 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { Y_UNIT_TEST(TestSkip) { float factors[FactorCount]; FillWithGarbage(factors, FactorCount); - fh::TDecoder decoder(CodedFactorsBuf); + fh::TDecoder decoder(CodedFactorsBuf); const size_t firstPack = 100; // unpack first pack - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack); // skip some factors const size_t skipCount = 60; - UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); + UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); // unpack all, except some factors in the end - const auto toDecode = FactorCount - firstPack - skipCount; - UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode); - UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); - for (size_t i = 0; i < FactorCount - skipCount; ++i) { + const auto toDecode = FactorCount - firstPack - skipCount; + UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode); + UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2); + for (size_t i = 0; i < FactorCount - skipCount; ++i) { size_t correctedI = i < firstPack ? i : i + skipCount / 2; UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]); } @@ -227,11 +227,11 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) { "d4ZfQZrETm3B+OxxB8bbnTPM5+qtbQ92mJ3fHPGj+iH5+8tzcnJuamry1tWUw" "MBD693f07+9+DQQEkIGAgIgPetzN5yEbAGxWpbCNxXK/0JGTKRz2KkIoR7aM"; UNIT_ASSERT_EXCEPTION( - fh::Decode(Base64Decode(brokenBase64Encoded)), + fh::Decode(Base64Decode(brokenBase64Encoded)), yexception); } - - Y_UNIT_TEST(TestDecompressEmpty) { - UNIT_ASSERT_EXCEPTION(fh::Decode({}), yexception); - } + + Y_UNIT_TEST(TestDecompressEmpty) { + UNIT_ASSERT_EXCEPTION(fh::Decode({}), yexception); + } }; diff --git a/library/cpp/codecs/ya.make b/library/cpp/codecs/ya.make index 174db32828..7e76fb0c9a 100644 --- a/library/cpp/codecs/ya.make +++ b/library/cpp/codecs/ya.make @@ -11,7 +11,7 @@ SRCS( codecs_registry.cpp comptable_codec.cpp delta_codec.cpp - float_huffman.cpp + float_huffman.cpp huffman_codec.cpp pfor_codec.cpp solar_codec.cpp diff --git a/library/cpp/containers/bitseq/bititerator.h b/library/cpp/containers/bitseq/bititerator.h index 2977abdd54..52dadd3798 100644 --- a/library/cpp/containers/bitseq/bititerator.h +++ b/library/cpp/containers/bitseq/bititerator.h @@ -2,7 +2,7 @@ #include "traits.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> template <typename T> class TBitIterator { diff --git a/library/cpp/containers/bitseq/bitvector.h b/library/cpp/containers/bitseq/bitvector.h index a620f83cb2..3f8fd81ee5 100644 --- a/library/cpp/containers/bitseq/bitvector.h +++ b/library/cpp/containers/bitseq/bitvector.h @@ -2,7 +2,7 @@ #include "traits.h" -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <util/generic/vector.h> #include <util/ysaveload.h> diff --git a/library/cpp/containers/bitseq/readonly_bitvector.h b/library/cpp/containers/bitseq/readonly_bitvector.h index 02f04f9439..8612739c3f 100644 --- a/library/cpp/containers/bitseq/readonly_bitvector.h +++ b/library/cpp/containers/bitseq/readonly_bitvector.h @@ -19,12 +19,12 @@ public: { } - explicit TReadonlyBitVector(const TBitVector<T>& vector) - : Size_(vector.Size_) - , Data_(vector.Data_.data()) - { - } - + explicit TReadonlyBitVector(const TBitVector<T>& vector) + : Size_(vector.Size_) + , Data_(vector.Data_.data()) + { + } + bool Test(ui64 pos) const { return TTraits::Test(Data_, pos, Size_); } diff --git a/library/cpp/containers/bitseq/ya.make b/library/cpp/containers/bitseq/ya.make index ec000d827e..7090956c55 100644 --- a/library/cpp/containers/bitseq/ya.make +++ b/library/cpp/containers/bitseq/ya.make @@ -4,7 +4,7 @@ OWNER(g:util) PEERDIR( util/draft - library/cpp/pop_count + library/cpp/pop_count ) SRCS( diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index 02e998607c..cfa35f5ba2 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -85,7 +85,7 @@ public: bool Get(const char* key, T* value) const { ui64 trieValue; if (Trie.Find(key, strlen(key), &trieValue)) { - *value = ReadUnaligned<T>(&trieValue); + *value = ReadUnaligned<T>(&trieValue); return true; } else { return false; @@ -95,7 +95,7 @@ public: T Get(const char* key, T def = T()) const { ui64 trieValue; if (Trie.Find(key, strlen(key), &trieValue)) { - return ReadUnaligned<T>(&trieValue); + return ReadUnaligned<T>(&trieValue); } else { return def; } @@ -126,9 +126,9 @@ public: } void Add(const char* key, const T& value) { - ui64 intValue = 0; - memcpy(&intValue, &value, sizeof(T)); - Builder.Add(key, strlen(key), intValue); + ui64 intValue = 0; + memcpy(&intValue, &value, sizeof(T)); + Builder.Add(key, strlen(key), intValue); #ifndef NDEBUG /* if (!IsSorted) { @@ -140,15 +140,15 @@ public: } void Add(const TString& s, const T& value) { - ui64 intValue = 0; - memcpy(&intValue, &value, sizeof(T)); - Builder.Add(s.data(), s.size(), intValue); + ui64 intValue = 0; + memcpy(&intValue, &value, sizeof(T)); + Builder.Add(s.data(), s.size(), intValue); } bool Get(const char* key, T* value) const { ui64 trieValue; if (Builder.Find(key, strlen(key), &trieValue)) { - *value = ReadUnaligned<T>(&trieValue); + *value = ReadUnaligned<T>(&trieValue); return true; } else { return false; @@ -158,7 +158,7 @@ public: T Get(const char* key, T def = (T)0) const { ui64 trieValue; if (Builder.Find(key, strlen(key), &trieValue)) { - return ReadUnaligned<T>(&trieValue); + return ReadUnaligned<T>(&trieValue); } else { return def; } diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 278e36ed0c..74bee09b5d 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -18,7 +18,7 @@ #include <util/random/fast.h> #include <util/string/hex.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include "comptrie.h" #include "set.h" diff --git a/library/cpp/containers/sorted_vector/sorted_vector.h b/library/cpp/containers/sorted_vector/sorted_vector.h index 93c4bdfb44..123539af9e 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector.h +++ b/library/cpp/containers/sorted_vector/sorted_vector.h @@ -4,7 +4,7 @@ #include <util/generic/hash.h> #include <util/generic/vector.h> #include <util/generic/algorithm.h> -#include <util/generic/mapfindptr.h> +#include <util/generic/mapfindptr.h> #include <util/ysaveload.h> #include <utility> @@ -328,10 +328,10 @@ namespace NSorted { // and then inserts a new one, the existing reference can be broken (due to reallocation). // Please keep this in mind when using this structure. template <typename TKeyType, typename TValueType, class TPredicate = TLess<TKeyType>, class A = std::allocator<TValueType>> - class TSimpleMap: - public TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A>, - public TMapOps<TSimpleMap<TKeyType, TValueType, TPredicate, A>> - { + class TSimpleMap: + public TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A>, + public TMapOps<TSimpleMap<TKeyType, TValueType, TPredicate, A>> + { private: typedef TSortedVector<std::pair<TKeyType, TValueType>, TKeyType, TSelect1st, TPredicate, A> TBase; @@ -379,22 +379,22 @@ namespace NSorted { Y_FORCE_INLINE TValueType& operator[](const K& key) { return Get(key); } - + template<class K> const TValueType& at(const K& key) const { - const auto i = TBase::Find(key); - if (i == TBase::end()) { - throw std::out_of_range("NSorted::TSimpleMap: missing key"); - } - - return i->second; - } - + const auto i = TBase::Find(key); + if (i == TBase::end()) { + throw std::out_of_range("NSorted::TSimpleMap: missing key"); + } + + return i->second; + } + template<class K> TValueType& at(const K& key) { - return const_cast<TValueType&>( - const_cast<const TSimpleMap<TKeyType, TValueType, TPredicate, A>*>(this)->at(key)); - } + return const_cast<TValueType&>( + const_cast<const TSimpleMap<TKeyType, TValueType, TPredicate, A>*>(this)->at(key)); + } }; // The simplified set (a.k.a TFlatSet, flat_set), which is implemented by the sorted-vector. diff --git a/library/cpp/containers/stack_vector/stack_vec.h b/library/cpp/containers/stack_vector/stack_vec.h index 4fc3f26d89..fcc5d9a2a5 100644 --- a/library/cpp/containers/stack_vector/stack_vec.h +++ b/library/cpp/containers/stack_vector/stack_vec.h @@ -3,23 +3,23 @@ #include <util/generic/vector.h> #include <util/ysaveload.h> -#include <type_traits> - +#include <type_traits> + // 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). // // Inspired by: http://qt-project.org/doc/qt-4.8/qvarlengtharray.html#details -template <typename T, size_t CountOnStack = 256, bool UseFallbackAlloc = true, class Alloc = std::allocator<T>> +template <typename T, size_t CountOnStack = 256, bool UseFallbackAlloc = true, class Alloc = std::allocator<T>> class TStackVec; template <typename T, class Alloc = std::allocator<T>> -using TSmallVec = TStackVec<T, 16, true, Alloc>; +using TSmallVec = TStackVec<T, 16, true, Alloc>; + +template <typename T, size_t CountOnStack = 256> +using TStackOnlyVec = TStackVec<T, CountOnStack, false>; -template <typename T, size_t CountOnStack = 256> -using TStackOnlyVec = TStackVec<T, CountOnStack, false>; - namespace NPrivate { template <class Alloc, class StackAlloc, typename T, typename U> struct TRebind { @@ -31,10 +31,10 @@ namespace NPrivate { typedef StackAlloc other; }; - template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc = std::allocator<T>> + template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc = std::allocator<T>> class TStackBasedAllocator: public Alloc { public: - typedef TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, Alloc> TSelf; + typedef TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, Alloc> TSelf; using typename Alloc::difference_type; using typename Alloc::size_type; @@ -58,14 +58,14 @@ namespace NPrivate { {} T* allocate(size_type n) { - if (!IsStorageUsed && CountOnStack >= n) { - IsStorageUsed = true; + if (!IsStorageUsed && CountOnStack >= n) { + IsStorageUsed = true; return reinterpret_cast<T*>(&StackBasedStorage[0]); } else { - if constexpr (!UseFallbackAlloc) { - Y_FAIL( - "Stack storage overflow. Capacity: %d, requested: %d", (int)CountOnStack, int(n)); - } + if constexpr (!UseFallbackAlloc) { + Y_FAIL( + "Stack storage overflow. Capacity: %d, requested: %d", (int)CountOnStack, int(n)); + } return FallbackAllocator().allocate(n); } } @@ -73,15 +73,15 @@ namespace NPrivate { void deallocate(T* p, size_type n) { if (p >= reinterpret_cast<T*>(&StackBasedStorage[0]) && p < reinterpret_cast<T*>(&StackBasedStorage[CountOnStack])) { - Y_VERIFY(IsStorageUsed); - IsStorageUsed = false; + Y_VERIFY(IsStorageUsed); + IsStorageUsed = false; } else { FallbackAllocator().deallocate(p, n); } } private: - std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; + std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; bool IsStorageUsed = false; private: @@ -91,8 +91,8 @@ namespace NPrivate { }; } -template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc> -class TStackVec: public TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>> { +template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc> +class TStackVec: public TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>> { private: using TBase = TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>>; using TAllocator = typename TBase::allocator_type; @@ -131,13 +131,13 @@ public: } TStackVec(const TStackVec& src) - : TStackVec(src.begin(), src.end()) + : TStackVec(src.begin(), src.end()) { } template <class A> - TStackVec(const TVector<T, A>& src) - : TStackVec(src.begin(), src.end()) + TStackVec(const TVector<T, A>& src) + : TStackVec(src.begin(), src.end()) { } @@ -150,20 +150,20 @@ public: TStackVec(TIter first, TIter last, const TAllocator& alloc = TAllocator()) : TBase(alloc) { - // NB(eeight) Since we want to call 'reserve' here, we cannot just delegate to TVector ctor. - // The best way to insert values afterwards is to call TVector::insert. However there is a caveat. - // In order to call this ctor of TVector, T needs to be just move-constructible. Insert however - // requires T to be move-assignable. - TBase::reserve(CountOnStack); - if constexpr (std::is_move_assignable_v<T>) { - // Fast path - TBase::insert(TBase::end(), first, last); - } else { - // Slow path. - for (; first != last; ++first) { - TBase::push_back(*first); - } - } + // NB(eeight) Since we want to call 'reserve' here, we cannot just delegate to TVector ctor. + // The best way to insert values afterwards is to call TVector::insert. However there is a caveat. + // In order to call this ctor of TVector, T needs to be just move-constructible. Insert however + // requires T to be move-assignable. + TBase::reserve(CountOnStack); + if constexpr (std::is_move_assignable_v<T>) { + // Fast path + TBase::insert(TBase::end(), first, last); + } else { + // Slow path. + for (; first != last; ++first) { + TBase::push_back(*first); + } + } } public: @@ -188,25 +188,25 @@ public: }; template <typename T, size_t CountOnStack, class Alloc> -class TSerializer<TStackVec<T, CountOnStack, true, Alloc>>: public TVectorSerializer<TStackVec<T, CountOnStack, true, Alloc>> { +class TSerializer<TStackVec<T, CountOnStack, true, Alloc>>: public TVectorSerializer<TStackVec<T, CountOnStack, true, Alloc>> { +}; + +template <typename T, size_t CountOnStack, class Alloc> +class TSerializer<TStackVec<T, CountOnStack, false, Alloc>> { +public: + static void Save(IOutputStream* rh, const TStackVec<T, CountOnStack, false, Alloc>& v) { + if constexpr (CountOnStack < 256) { + ::Save(rh, (ui8)v.size()); + } else { + ::Save(rh, v.size()); + } + ::SaveArray(rh, v.data(), v.size()); + } + + static void Load(IInputStream* rh, TStackVec<T, CountOnStack, false, Alloc>& v) { + std::conditional_t<CountOnStack < 256, ui8, size_t> size; + ::Load(rh, size); + v.resize(size); + ::LoadPodArray(rh, v.data(), v.size()); + } }; - -template <typename T, size_t CountOnStack, class Alloc> -class TSerializer<TStackVec<T, CountOnStack, false, Alloc>> { -public: - static void Save(IOutputStream* rh, const TStackVec<T, CountOnStack, false, Alloc>& v) { - if constexpr (CountOnStack < 256) { - ::Save(rh, (ui8)v.size()); - } else { - ::Save(rh, v.size()); - } - ::SaveArray(rh, v.data(), v.size()); - } - - static void Load(IInputStream* rh, TStackVec<T, CountOnStack, false, Alloc>& v) { - std::conditional_t<CountOnStack < 256, ui8, size_t> size; - ::Load(rh, size); - v.resize(size); - ::LoadPodArray(rh, v.data(), v.size()); - } -}; diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index 89821dd4a8..19f9677781 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -2,13 +2,13 @@ #include <library/cpp/testing/unittest/registar.h> -namespace { - struct TNotCopyAssignable { - const int Value; - }; - - static_assert(std::is_copy_constructible_v<TNotCopyAssignable>); - static_assert(!std::is_copy_assignable_v<TNotCopyAssignable>); +namespace { + struct TNotCopyAssignable { + const int Value; + }; + + static_assert(std::is_copy_constructible_v<TNotCopyAssignable>); + static_assert(!std::is_copy_assignable_v<TNotCopyAssignable>); template <class T, size_t JunkPayloadSize> struct TThickAlloc: public std::allocator<T> { @@ -41,8 +41,8 @@ namespace { return TBase::allocate(n); } }; -} - +} + Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { Y_UNIT_TEST(TestCreateEmpty) { TStackVec<int> ints; @@ -98,34 +98,34 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { UNIT_ASSERT_EQUAL(ints3[i], (int)i); } } - - Y_UNIT_TEST(TestCappedSize) { - TStackVec<int, 8, false> ints; - ints.push_back(1); - ints.push_back(2); - - auto intsCopy = ints; - UNIT_ASSERT_VALUES_EQUAL(intsCopy.capacity(), 8); - - for (int i = 2; i != 8; ++i) { - intsCopy.push_back(i); - } - // Just verify that the program did not crash. - } - - Y_UNIT_TEST(TestCappedSizeWithNotCopyAssignable) { - TStackVec<TNotCopyAssignable, 8, false> values; - values.push_back({1}); - values.push_back({2}); - - auto valuesCopy = values; - UNIT_ASSERT_VALUES_EQUAL(valuesCopy.capacity(), 8); - - for (int i = 2; i != 8; ++i) { - valuesCopy.push_back({i}); - } - // Just verify that the program did not crash. - } + + Y_UNIT_TEST(TestCappedSize) { + TStackVec<int, 8, false> ints; + ints.push_back(1); + ints.push_back(2); + + auto intsCopy = ints; + UNIT_ASSERT_VALUES_EQUAL(intsCopy.capacity(), 8); + + for (int i = 2; i != 8; ++i) { + intsCopy.push_back(i); + } + // Just verify that the program did not crash. + } + + Y_UNIT_TEST(TestCappedSizeWithNotCopyAssignable) { + TStackVec<TNotCopyAssignable, 8, false> values; + values.push_back({1}); + values.push_back({2}); + + auto valuesCopy = values; + UNIT_ASSERT_VALUES_EQUAL(valuesCopy.capacity(), 8); + + for (int i = 2; i != 8; ++i) { + valuesCopy.push_back({i}); + } + // Just verify that the program did not crash. + } Y_UNIT_TEST(TestCustomAllocSize) { constexpr size_t n = 16384; diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index 786725a7ed..283a96ecf1 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -131,7 +131,7 @@ static void ContHelperFunc(TCont* cont, void* arg) { template <typename T, void (T::*M)(TCont*)> static void ContHelperMemberFunc(TCont* c, void* arg) { - ((reinterpret_cast<T*>(arg))->*M)(c); + ((reinterpret_cast<T*>(arg))->*M)(c); } class IUserEvent diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index 1d4d1da950..c7efa105ee 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -50,7 +50,7 @@ namespace NPrivate { template <class V> inline void Pointer(const V* v) { - if (v && !Visited.contains((size_t)v)) { + if (v && !Visited.contains((size_t)v)) { Visited.insert((size_t)v); *this << DumpRaw("(") << DumpRaw(TypeName(v).data()) << DumpRaw(")") << Hex((size_t)v) << DumpRaw(" -> ") << *v; Visited.erase((size_t)v); diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp index 4433e2dda0..b0e4511299 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.cpp +++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp @@ -2,13 +2,13 @@ #include <util/generic/yexception.h> #include <util/system/defaults.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/filemap.h> TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) { Map_ = map; i64 len = Map_->Length(); - if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32)) + if (Hi32(len) != 0 && sizeof(size_t) <= sizeof(ui32)) ythrow yexception() << "File '" << dbgName << "' mapping error: " << len << " too large"; Map_->Map(0, static_cast<size_t>(len)); diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 22b591c356..6c753f68a9 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -39,7 +39,7 @@ RECURSE( iterators_heap parse_utils parse_utils/ut - small_array + small_array solartrie solartrie/indexed_region/ut solartrie/test diff --git a/library/cpp/dns/cache.cpp b/library/cpp/dns/cache.cpp index d98d37cf8f..05c14e82fc 100644 --- a/library/cpp/dns/cache.cpp +++ b/library/cpp/dns/cache.cpp @@ -38,7 +38,7 @@ namespace { struct THashResolveInfo { inline size_t operator()(const TResolveInfo& ri) const { - return ComputeHash(ri.Host) ^ ri.Port; + return ComputeHash(ri.Host) ^ ri.Port; } }; diff --git a/library/cpp/dns/thread.cpp b/library/cpp/dns/thread.cpp index efec63831c..8b27d2d527 100644 --- a/library/cpp/dns/thread.cpp +++ b/library/cpp/dns/thread.cpp @@ -3,7 +3,7 @@ #include "magic.h" #include <util/network/socket.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <util/thread/lfqueue.h> #include <util/system/event.h> #include <util/generic/vector.h> @@ -12,7 +12,7 @@ using namespace NDns; namespace { - class TThreadedResolver: public IThreadFactory::IThreadAble, public TNonCopyable { + class TThreadedResolver: public IThreadFactory::IThreadAble, public TNonCopyable { struct TResolveRequest { inline TResolveRequest(const TString& host, ui16 port) : Host(host) @@ -61,7 +61,7 @@ namespace { inline TThreadedResolver() : E_(TSystemEvent::rAuto) { - T_.push_back(SystemThreadFactory()->Run(this)); + T_.push_back(SystemThreadFactory()->Run(this)); } inline ~TThreadedResolver() override { @@ -121,7 +121,7 @@ namespace { private: TLockFreeQueue<TResolveRequest*> Q_; TSystemEvent E_; - typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; + typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; TVector<IThreadRef> T_; }; } diff --git a/library/cpp/getopt/small/completion_generator.cpp b/library/cpp/getopt/small/completion_generator.cpp index 7bacd5fffa..ac41988217 100644 --- a/library/cpp/getopt/small/completion_generator.cpp +++ b/library/cpp/getopt/small/completion_generator.cpp @@ -48,7 +48,7 @@ namespace NLastGetopt { L << "local prefix_orig=\"$PREFIX\""; L << "local suffix_orig=\"$SUFFIX\""; L; - std::visit(TOverloaded{ + std::visit(TOverloaded{ [&out, &manager](const TModChooser* modChooser) { GenerateModesCompletion(out, *modChooser, manager); }, @@ -390,7 +390,7 @@ namespace NLastGetopt { L << "local need_space=\"1\""; L << "local IFS=$' \\t\\n'"; L; - std::visit(TOverloaded{ + std::visit(TOverloaded{ [&out, &manager](const TModChooser* modChooser) { GenerateModesCompletion(out, *modChooser, manager, 1); }, diff --git a/library/cpp/getopt/small/completion_generator.h b/library/cpp/getopt/small/completion_generator.h index 8c21d6fa36..4241bb7d6c 100644 --- a/library/cpp/getopt/small/completion_generator.h +++ b/library/cpp/getopt/small/completion_generator.h @@ -19,7 +19,7 @@ namespace NLastGetopt { virtual void Generate(TStringBuf command, IOutputStream& stream) = 0; protected: - std::variant<const TModChooser*, const TOpts*> Options_; + std::variant<const TModChooser*, const TOpts*> Options_; }; class TZshCompletionGenerator: public TCompletionGenerator { diff --git a/library/cpp/getopt/small/last_getopt_handlers.h b/library/cpp/getopt/small/last_getopt_handlers.h index 961298127f..d35456ef34 100644 --- a/library/cpp/getopt/small/last_getopt_handlers.h +++ b/library/cpp/getopt/small/last_getopt_handlers.h @@ -3,7 +3,7 @@ #include "last_getopt_support.h" #include <util/string/split.h> -#include <util/system/compiler.h> +#include <util/system/compiler.h> namespace NLastGetopt { /// Handler to split option value by delimiter into a target container. diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h index 707b7cc279..a8dd5adca9 100644 --- a/library/cpp/getopt/small/last_getopt_opt.h +++ b/library/cpp/getopt/small/last_getopt_opt.h @@ -8,7 +8,7 @@ #include <util/generic/string.h> #include <util/generic/maybe.h> #include <util/generic/vector.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <stdarg.h> diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp index 698cc8bee7..03c432849f 100644 --- a/library/cpp/getopt/small/last_getopt_opts.cpp +++ b/library/cpp/getopt/small/last_getopt_opts.cpp @@ -260,7 +260,7 @@ namespace NLastGetopt { } TStringBuf TOpts::GetFreeArgTitle(size_t pos) const { - if (FreeArgSpecs_.contains(pos)) { + if (FreeArgSpecs_.contains(pos)) { return FreeArgSpecs_.at(pos).GetTitle(DefaultFreeArgTitle_); } return DefaultFreeArgTitle_; diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 477723a7d8..7668b12a03 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -341,7 +341,7 @@ namespace NLastGetopt { const TOpt* opt = (*it).Get(); if (nullptr == opt) continue; - if (OptsSeen_.contains(opt)) + if (OptsSeen_.contains(opt)) continue; if (opt->IsRequired()) { diff --git a/library/cpp/grpc/client/grpc_client_low.h b/library/cpp/grpc/client/grpc_client_low.h index c0a5a2d86e..ab0a0627be 100644 --- a/library/cpp/grpc/client/grpc_client_low.h +++ b/library/cpp/grpc/client/grpc_client_low.h @@ -2,7 +2,7 @@ #include "grpc_common.h" -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <grpc++/grpc++.h> #include <grpc++/support/async_stream.h> #include <grpc++/support/async_unary_call.h> @@ -1371,7 +1371,7 @@ public: void AddWorkerThreadForTest(); private: - using IThreadRef = std::unique_ptr<IThreadFactory::IThread>; + using IThreadRef = std::unique_ptr<IThreadFactory::IThread>; using CompletionQueueRef = std::unique_ptr<grpc::CompletionQueue>; void Init(size_t numWorkerThread); diff --git a/library/cpp/grpc/server/grpc_server.h b/library/cpp/grpc/server/grpc_server.h index 39b32260b9..d6814a90a0 100644 --- a/library/cpp/grpc/server/grpc_server.h +++ b/library/cpp/grpc/server/grpc_server.h @@ -13,7 +13,7 @@ #include <util/generic/hash_set.h> #include <util/system/types.h> #include <util/system/mutex.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <grpc++/grpc++.h> @@ -342,7 +342,7 @@ public: TString GetHost() const; private: - using IThreadRef = TAutoPtr<IThreadFactory::IThread>; + using IThreadRef = TAutoPtr<IThreadFactory::IThread>; const TServerOptions Options_; std::unique_ptr<grpc::Server> Server_; diff --git a/library/cpp/histogram/adaptive/adaptive_histogram.h b/library/cpp/histogram/adaptive/adaptive_histogram.h index 6e1f00ff4c..fa8f48433f 100644 --- a/library/cpp/histogram/adaptive/adaptive_histogram.h +++ b/library/cpp/histogram/adaptive/adaptive_histogram.h @@ -54,40 +54,40 @@ namespace NKiwiAggr { TAdaptiveHistogram(const THistogram& histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = nullptr); TAdaptiveHistogram(IHistogram* histo, size_t defaultIntervals = DEFAULT_INTERVALS, ui64 defaultId = 0, TQualityFunction qualityFunc = CalcWeightQuality); - ~TAdaptiveHistogram() override { + ~TAdaptiveHistogram() override { } TQualityFunction GetQualityFunc(); void Clear() override; - void Add(double value, double weight) override; - void Add(const THistoRec& histoRec) override; + void Add(double value, double weight) override; + void Add(const THistoRec& histoRec) override; - void Merge(const THistogram& histo, double multiplier) final; - void Merge(const TVector<THistogram>& histogramsToMerge) final; - void Merge(TVector<IHistogramPtr> histogramsToMerge) final; + void Merge(const THistogram& histo, double multiplier) final; + void Merge(const TVector<THistogram>& histogramsToMerge) final; + void Merge(TVector<IHistogramPtr> histogramsToMerge) final; - void Multiply(double factor) final; + void Multiply(double factor) final; - void FromProto(const THistogram& histo) final; - void ToProto(THistogram& histo) final; + void FromProto(const THistogram& histo) final; + void ToProto(THistogram& histo) final; - void SetId(ui64 id) final; - ui64 GetId() final; - bool Empty() final; - double GetMinValue() final; - double GetMaxValue() final; - double GetSum() final; - double GetSumInRange(double leftBound, double rightBound) final; - double GetSumAboveBound(double bound) final; - double GetSumBelowBound(double bound) final; - double CalcUpperBound(double sum) final; - double CalcLowerBound(double sum) final; - double CalcUpperBoundSafe(double sum) final; - double CalcLowerBoundSafe(double sum) final; + void SetId(ui64 id) final; + ui64 GetId() final; + bool Empty() final; + double GetMinValue() final; + double GetMaxValue() final; + double GetSum() final; + double GetSumInRange(double leftBound, double rightBound) final; + double GetSumAboveBound(double bound) final; + double GetSumBelowBound(double bound) final; + double CalcUpperBound(double sum) final; + double CalcLowerBound(double sum) final; + double CalcUpperBoundSafe(double sum) final; + double CalcLowerBoundSafe(double sum) final; - void PrecomputePartialSums() final; + void PrecomputePartialSums() final; private: void FromIHistogram(IHistogram* histo); @@ -120,7 +120,7 @@ namespace NKiwiAggr { { } - ~TDefinedAdaptiveHistogram() override { + ~TDefinedAdaptiveHistogram() override { } }; diff --git a/library/cpp/histogram/hdr/histogram.cpp b/library/cpp/histogram/hdr/histogram.cpp index 82e7ed07e1..a213d5d8fd 100644 --- a/library/cpp/histogram/hdr/histogram.cpp +++ b/library/cpp/histogram/hdr/histogram.cpp @@ -1,6 +1,6 @@ #include "histogram.h" -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/yexception.h> #include <contrib/libs/hdr_histogram/src/hdr_histogram.h> @@ -24,7 +24,7 @@ namespace NHdr { IAllocator::TBlock mem = allocator->Allocate(histogramSize); struct hdr_histogram* histogram = - reinterpret_cast<struct hdr_histogram*>(mem.Data); + reinterpret_cast<struct hdr_histogram*>(mem.Data); // memset will ensure that all of the function pointers are null memset(histogram, 0, histogramSize); diff --git a/library/cpp/http/io/compression.h b/library/cpp/http/io/compression.h index 3287c6f34c..f16c4a18eb 100644 --- a/library/cpp/http/io/compression.h +++ b/library/cpp/http/io/compression.h @@ -2,7 +2,7 @@ #include "stream.h" -#include <util/generic/deque.h> +#include <util/generic/deque.h> #include <util/generic/hash.h> class TCompressionCodecFactory { @@ -44,7 +44,7 @@ private: TEncoderConstructor Encoder; }; - TDeque<TString> Strings_; + TDeque<TString> Strings_; THashMap<TStringBuf, TCodec> Codecs_; TVector<TStringBuf> BestCodecs_; }; diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp index 7f322ce0ea..e332a24e91 100644 --- a/library/cpp/http/misc/parsed_request.cpp +++ b/library/cpp/http/misc/parsed_request.cpp @@ -2,7 +2,7 @@ #include <util/string/strip.h> #include <util/generic/yexception.h> -#include <util/string/cast.h> +#include <util/string/cast.h> static inline TStringBuf StripLeft(const TStringBuf& s) noexcept { const char* b = s.begin(); diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 48498e6b8b..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -17,7 +17,7 @@ #include <util/system/mutex.h> #include <util/system/pipe.h> #include <util/system/thread.h> -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <cerrno> #include <cstring> diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index 517fcf9eb2..b292d38f27 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -3,14 +3,14 @@ #include "conn.h" #include "options.h" -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <library/cpp/http/io/stream.h> #include <util/memory/blob.h> #include <util/generic/ptr.h> #include <util/generic/vector.h> #include <util/system/atomic.h> -class IThreadFactory; +class IThreadFactory; class TClientRequest; class TClientConnection; @@ -62,7 +62,7 @@ public: }; typedef THttpServerOptions TOptions; - typedef TSimpleSharedPtr<IThreadPool> TMtpQueueRef; + typedef TSimpleSharedPtr<IThreadPool> TMtpQueueRef; THttpServer(ICallBack* cb, const TOptions& options = TOptions(), IThreadFactory* pool = nullptr); THttpServer(ICallBack* cb, TMtpQueueRef mainWorkers, TMtpQueueRef failWorkers, const TOptions& options = TOptions()); diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index 1199007496..cc62bb988e 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { bool Expect100Continue = false; }; - class TFailingMtpQueue: public TSimpleThreadPool { + class TFailingMtpQueue: public TSimpleThreadPool { private: bool FailOnAdd_ = false; @@ -297,16 +297,16 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { void SetFailOnAdd(bool fail = true) { FailOnAdd_ = fail; } - [[nodiscard]] bool Add(IObjectInQueue* pObj) override { + [[nodiscard]] bool Add(IObjectInQueue* pObj) override { if (FailOnAdd_) { return false; } - return TSimpleThreadPool::Add(pObj); + return TSimpleThreadPool::Add(pObj); } TFailingMtpQueue() = default; - TFailingMtpQueue(IThreadFactory* pool) - : TSimpleThreadPool(pool) + TFailingMtpQueue(IThreadFactory* pool) + : TSimpleThreadPool(pool) { } }; @@ -434,9 +434,9 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { THttpServer::TOptions options(port); options.EnableKeepAlive(true); options.EnableCompression(true); - using TFailingServerMtpQueue = TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; - THttpServer::TMtpQueueRef mainWorkers = new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); - THttpServer::TMtpQueueRef failWorkers = new TThreadPool(SystemThreadFactory()); + using TFailingServerMtpQueue = TThreadPoolBinder<TFailingMtpQueue, THttpServer::ICallBack>; + THttpServer::TMtpQueueRef mainWorkers = new TFailingServerMtpQueue(&serverImpl, SystemThreadFactory()); + THttpServer::TMtpQueueRef failWorkers = new TThreadPool(SystemThreadFactory()); THttpServer server(&serverImpl, mainWorkers, failWorkers, options); UNIT_ASSERT(server.Start()); @@ -703,7 +703,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { for (bool keepAlive : trueFalse) { server.ResetCounters(); - TVector<TAutoPtr<IThreadFactory::IThread>> threads; + TVector<TAutoPtr<IThreadFactory::IThread>> threads; server.Busy(3); server.BusyThread(); @@ -715,7 +715,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { r->KeepAliveConnection = keepAlive; r->Execute(); }; - threads.push_back(SystemThreadFactory()->Run(func)); + threads.push_back(SystemThreadFactory()->Run(func)); } server.FreeThread(); // all threads get connection & go to processing diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp index b94a2f4482..52d64c91ce 100644 --- a/library/cpp/http/server/response.cpp +++ b/library/cpp/http/server/response.cpp @@ -2,7 +2,7 @@ #include <util/stream/output.h> #include <util/stream/mem.h> -#include <util/string/cast.h> +#include <util/string/cast.h> THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) { for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) { diff --git a/library/cpp/iterator/mapped.h b/library/cpp/iterator/mapped.h index 97c730b66d..6c5e763184 100644 --- a/library/cpp/iterator/mapped.h +++ b/library/cpp/iterator/mapped.h @@ -6,7 +6,7 @@ #include <iterator> -namespace NIteratorPrivate { +namespace NIteratorPrivate { template <class TIterator> constexpr bool HasRandomAccess() { return std::is_same_v<typename std::iterator_traits<TIterator>::iterator_category, @@ -26,7 +26,7 @@ public: using value_type = TValue; using reference = TValue&; using pointer = std::remove_reference_t<TValue>*; - using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(), + using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(), std::random_access_iterator_tag, std::input_iterator_tag>; TMappedIterator(TIterator it, TMapper mapper) @@ -122,10 +122,10 @@ public: return {std::end(*Container.Ptr()), {*Mapper.Ptr()}}; } - bool empty() const { - return std::begin(*Container.Ptr()) == std::end(*Container.Ptr()); - } - + bool empty() const { + return std::begin(*Container.Ptr()) == std::end(*Container.Ptr()); + } + protected: mutable TContainerStorage Container; mutable TMapperStorage Mapper; @@ -154,7 +154,7 @@ public: using TBase::begin; using TBase::end; - using TBase::empty; + using TBase::empty; size_type size() const { return std::end(*this->Container.Ptr()) - std::begin(*this->Container.Ptr()); @@ -185,7 +185,7 @@ auto MakeMappedRange(TIterator begin, TIterator end, TMapper mapper) { template <class TContainer, class TMapper> auto MakeMappedRange(TContainer&& container, TMapper&& mapper) { - if constexpr (NIteratorPrivate::HasRandomAccess<decltype(std::begin(container))>()) { + if constexpr (NIteratorPrivate::HasRandomAccess<decltype(std::begin(container))>()) { return TRandomAccessMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); } else { return TInputMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); diff --git a/library/cpp/json/easy_parse/json_easy_parser.cpp b/library/cpp/json/easy_parse/json_easy_parser.cpp index 0d4e1c52ff..3c781f544b 100644 --- a/library/cpp/json/easy_parse/json_easy_parser.cpp +++ b/library/cpp/json/easy_parse/json_easy_parser.cpp @@ -1,6 +1,6 @@ #include "json_easy_parser.h" #include <library/cpp/json/json_reader.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/split.h> #include <util/string/strip.h> @@ -13,7 +13,7 @@ namespace NJson { TVector<const char*> parts; Split(path.begin(), '/', &parts); for (size_t n = 0; n < parts.size(); ++n) { - TString part = Strip(parts[n]); + TString part = Strip(parts[n]); if (!part.empty()) { if (part[0] != '[') { res->push_back(TPathElem(NImpl::MAP)); diff --git a/library/cpp/json/json_reader.cpp b/library/cpp/json/json_reader.cpp index 9cabc3efe0..072c8deafe 100644 --- a/library/cpp/json/json_reader.cpp +++ b/library/cpp/json/json_reader.cpp @@ -423,12 +423,12 @@ namespace NJson { } TJsonValue ReadJsonFastTree(TStringBuf in, bool notClosedBracketIsError) { - TJsonValue value; - // There is no way to report an error apart from throwing an exception when we return result by value. + TJsonValue value; + // There is no way to report an error apart from throwing an exception when we return result by value. ReadJsonFastTree(in, &value, /* throwOnError = */ true, notClosedBracketIsError); - return value; - } - + return value; + } + namespace { struct TJsonCallbacksWrapper { TJsonCallbacks& Impl; diff --git a/library/cpp/json/ut/json_reader_fast_ut.cpp b/library/cpp/json/ut/json_reader_fast_ut.cpp index 647804b998..60dffc91c7 100644 --- a/library/cpp/json/ut/json_reader_fast_ut.cpp +++ b/library/cpp/json/ut/json_reader_fast_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/string_utils/relaxed_escaper/relaxed_escaper.h> -#include <util/string/cast.h> +#include <util/string/cast.h> #include <util/string/printf.h> namespace NJson { diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index 6010b4e4d1..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -921,7 +921,7 @@ namespace NJson { } bool TJsonValue::Has(const TStringBuf& key) const noexcept { - return Type == JSON_MAP && Value.Map->contains(key); + return Type == JSON_MAP && Value.Map->contains(key); } bool TJsonValue::Has(size_t key) const noexcept { diff --git a/library/cpp/logger/filter_creator.cpp b/library/cpp/logger/filter_creator.cpp index bb7d98d083..fd5618087b 100644 --- a/library/cpp/logger/filter_creator.cpp +++ b/library/cpp/logger/filter_creator.cpp @@ -7,7 +7,7 @@ TFilteredBackendCreator::TFilteredBackendCreator(THolder<ILogBackendCreator> sla {} THolder<TLogBackend> TFilteredBackendCreator::DoCreateLogBackend() const { - return MakeHolder<TFilteredLogBackend>(Slave->CreateLogBackend(), Priority); + return MakeHolder<TFilteredLogBackend>(Slave->CreateLogBackend(), Priority); } bool TFilteredBackendCreator::Init(const IInitContext& ctx) { diff --git a/library/cpp/logger/global/common.cpp b/library/cpp/logger/global/common.cpp index 41138d8105..4fb05c19b4 100644 --- a/library/cpp/logger/global/common.cpp +++ b/library/cpp/logger/global/common.cpp @@ -1,26 +1,26 @@ #include "common.h" -#include <util/generic/yexception.h> - +#include <util/generic/yexception.h> + namespace NLoggingImpl { TString GetLocalTimeSSimple() { struct tm tm; return Strftime("%b%d_%H%M%S", Now().LocalTime(&tm)); } - - TString PrepareToOpenLog(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { - Y_ENSURE(logLevel >= 0 && logLevel <= (int)LOG_MAX_PRIORITY, "Incorrect log level"); - - if (rotation && TFsPath(logType).Exists()) { - TString newPath = Sprintf("%s_%s_%" PRIu64, logType.data(), NLoggingImpl::GetLocalTimeSSimple().data(), static_cast<ui64>(Now().MicroSeconds())); - TFsPath(logType).RenameTo(newPath); - } + + TString PrepareToOpenLog(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { + Y_ENSURE(logLevel >= 0 && logLevel <= (int)LOG_MAX_PRIORITY, "Incorrect log level"); + + if (rotation && TFsPath(logType).Exists()) { + TString newPath = Sprintf("%s_%s_%" PRIu64, logType.data(), NLoggingImpl::GetLocalTimeSSimple().data(), static_cast<ui64>(Now().MicroSeconds())); + TFsPath(logType).RenameTo(newPath); + } if (startAsDaemon && (logType == "console"sv || logType == "cout"sv || logType == "cerr"sv)) { - logType = "null"; - } - - return logType; - } + logType = "null"; + } + + return logType; + } } bool TLogFilter::CheckLoggingContext(TLog& log, const TLogRecordContext& context) { diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 56fa92f0b6..7dcf650dec 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -68,12 +68,12 @@ namespace NLoggingImpl { TString GetLocalTimeSSimple(); - // Returns correct log type to use + // Returns correct log type to use TString PrepareToOpenLog(TString logType, int logLevel, bool rotation, bool startAsDaemon); template <class TLoggerType> void InitLogImpl(TString logType, const int logLevel, const bool rotation, const bool startAsDaemon) { - TLoggerOperator<TLoggerType>::Set(new TLoggerType(PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), (ELogPriority)logLevel)); + TLoggerOperator<TLoggerType>::Set(new TLoggerType(PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), (ELogPriority)logLevel)); } } diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp index 32303ef60e..9fbd10f666 100644 --- a/library/cpp/logger/global/global.cpp +++ b/library/cpp/logger/global/global.cpp @@ -8,14 +8,14 @@ static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter TLoggerFormatterOperator::Set(formatter.Release()); } -void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { - DoInitGlobalLog( - MakeHolder<TGlobalLog>( - CreateLogBackend( - NLoggingImpl::PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), - (ELogPriority)logLevel, - threaded)), - std::move(formatter)); +void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { + DoInitGlobalLog( + MakeHolder<TGlobalLog>( + CreateLogBackend( + NLoggingImpl::PrepareToOpenLog(logType, logLevel, rotation, startAsDaemon), + (ELogPriority)logLevel, + threaded)), + std::move(formatter)); } void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) { diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index b1193ed403..cbe71b16ea 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -6,7 +6,7 @@ // ATTENTION! MUST CALL DoInitGlobalLog BEFORE USAGE bool GlobalLogInitialized(); -void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); +void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); inline void InitGlobalLog2Null() { diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index 0c17874294..e1d70cc3d2 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -19,7 +19,7 @@ THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priorit } THolder<TLogBackend> CreateFilteredOwningThreadedLogBackend(const TString& fname, ELogPriority priority, size_t queueLen) { - return MakeHolder<TFilteredLogBackend>(CreateOwningThreadedLogBackend(fname, queueLen), priority); + return MakeHolder<TFilteredLogBackend>(CreateOwningThreadedLogBackend(fname, queueLen), priority); } THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString& fname, size_t queueLen) { diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp index 124b36adde..0ccf9e374b 100644 --- a/library/cpp/logger/thread.cpp +++ b/library/cpp/logger/thread.cpp @@ -1,7 +1,7 @@ #include "thread.h" #include "record.h" -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/system/event.h> #include <util/memory/addstorage.h> #include <util/generic/ptr.h> diff --git a/library/cpp/lwtrace/custom_action.cpp b/library/cpp/lwtrace/custom_action.cpp index e8a2741c6a..a379b34ec0 100644 --- a/library/cpp/lwtrace/custom_action.cpp +++ b/library/cpp/lwtrace/custom_action.cpp @@ -14,7 +14,7 @@ TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustom } void TCustomActionFactory::Register(const TString& name, const TCustomActionFactory::TCallback& callback) { - if (Callbacks.contains(name)) { + if (Callbacks.contains(name)) { ythrow yexception() << "duplicate custom action '" << name << "'"; } Callbacks[name] = callback; diff --git a/library/cpp/lwtrace/mon/analytics/json_output.h b/library/cpp/lwtrace/mon/analytics/json_output.h index 1d867c3d05..189f9802d3 100644 --- a/library/cpp/lwtrace/mon/analytics/json_output.h +++ b/library/cpp/lwtrace/mon/analytics/json_output.h @@ -19,13 +19,13 @@ inline TString ToJsonFlot(const TTable& in, const TString& xno, const TVector<TS TString xn; THashSet<TString> xopts; ParseNameAndOpts(xno, xn, xopts); - bool xstack = xopts.contains("stack"); + bool xstack = xopts.contains("stack"); for (const TString& yno : ynos) { TString yn; THashSet<TString> yopts; ParseNameAndOpts(yno, yn, yopts); - bool ystackOpt = yopts.contains("stack"); + bool ystackOpt = yopts.contains("stack"); ss << (first? "": ",\n ") << "{ " << opts << (opts? ", ": "") << "\"label\": \"" << yn << "\", \"data\": [ "; bool first2 = true; diff --git a/library/cpp/lwtrace/mon/analytics/transform.h b/library/cpp/lwtrace/mon/analytics/transform.h index 32a175a63e..f7dc9adb5b 100644 --- a/library/cpp/lwtrace/mon/analytics/transform.h +++ b/library/cpp/lwtrace/mon/analytics/transform.h @@ -98,12 +98,12 @@ inline TTable HistogramAll(const TTable& in, const TString& xn, double x1, doubl if (i >= 0 && i < buckets) { out[i][yn + "_cnt"] = out[i].GetOrDefault(yn + "_cnt") + 1; out[i][yn + "_sum"] = out[i].GetOrDefault(yn + "_sum") + y; - if (out[i].contains(yn + "_min")) { + if (out[i].contains(yn + "_min")) { out[i][yn + "_min"] = Min(y, out[i].GetOrDefault(yn + "_min")); } else { out[i][yn + "_min"] = y; } - if (out[i].contains(yn + "_max")) { + if (out[i].contains(yn + "_max")) { out[i][yn + "_max"] = Max(y, out[i].GetOrDefault(yn + "_max")); } else { out[i][yn + "_max"] = y; diff --git a/library/cpp/lwtrace/mon/analytics/util.h b/library/cpp/lwtrace/mon/analytics/util.h index 777694781c..e07d06cc43 100644 --- a/library/cpp/lwtrace/mon/analytics/util.h +++ b/library/cpp/lwtrace/mon/analytics/util.h @@ -56,7 +56,7 @@ inline double MinValue(const TString& nameAndOpts, const TTable& table) TString name; THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); - bool stack = opts.contains("stack"); + bool stack = opts.contains("stack"); if (stack) { return 0.0; } else { @@ -73,7 +73,7 @@ inline double MaxValue(const TString& nameAndOpts, const TTable& table) TString name; THashSet<TString> opts; ParseNameAndOpts(nameAndOpts, name, opts); - bool stack = opts.contains("stack"); + bool stack = opts.contains("stack"); if (stack) { return AccumulateIfExist(name, table, 0.0, [] (double x, double y) { return x + y; diff --git a/library/cpp/lwtrace/mon/mon_lwtrace.cpp b/library/cpp/lwtrace/mon/mon_lwtrace.cpp index c2c9853813..a61ee9ce22 100644 --- a/library/cpp/lwtrace/mon/mon_lwtrace.cpp +++ b/library/cpp/lwtrace/mon/mon_lwtrace.cpp @@ -819,9 +819,9 @@ private: #if defined(_linux_) TStringStream linuxName; linuxName << TStringBuf(GetExecPath()).RNextTok('/') << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else - TThread::SetCurrentThreadName(name.data()); + TThread::SetCurrentThreadName(name.data()); #endif static_cast<TTraceCleaner*>(_this)->Exec(); return nullptr; @@ -1394,7 +1394,7 @@ void RequireMultipleSelection(TStringStream& ss, const TCgiParameters& e, const for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } - if (selectedValues.contains("")) { + if (selectedValues.contains("")) { throw TPageGen<TSelectorsContainer>(ss.Str()); } else { BtnHref<Button|ExtraSmall>(ss, "+", MakeUrlAddSub(e, param, "")); @@ -1435,7 +1435,7 @@ void OptionalMultipleSelection(TStringStream& ss, const TCgiParameters& e, const for (const TString& subvalue : Subvalues(e, param)) { DropdownSelector<Erasable, true>(ss, e, param, subvalue, "", variants); } - if (selectedValues.contains("")) { + if (selectedValues.contains("")) { throw TPageGen<TSelectorsContainer>(ss.Str()); } else { BtnHref<Button|ExtraSmall>(ss, selectedValues.empty()? text: "+", MakeUrlAddSub(e, param, "")); @@ -2116,7 +2116,7 @@ public: bool IsFiltered(const TString& paramName) const { - return FilteredParamValues.contains(paramName); + return FilteredParamValues.contains(paramName); } private: @@ -3550,7 +3550,7 @@ private: const NLWTrace::TSignature* sgn = &probe->Event.Signature; for (size_t pi = 0; pi < sgn->ParamCount; pi++) { TString param = sgn->ParamNames[pi]; - if (TrackIds.contains(param) || IsFiltered(param)) { + if (TrackIds.contains(param) || IsFiltered(param)) { continue; } os << "<li><a href=\"" diff --git a/library/cpp/lwtrace/signature.h b/library/cpp/lwtrace/signature.h index bf545ee070..868bd9bcf2 100644 --- a/library/cpp/lwtrace/signature.h +++ b/library/cpp/lwtrace/signature.h @@ -4,7 +4,7 @@ #include <library/cpp/lwtrace/protos/lwtrace.pb.h> -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/string.h> #include <util/generic/typetraits.h> #include <util/string/builder.h> @@ -80,12 +80,12 @@ namespace NLWTrace { template <class T> const T& Get() const { - return *reinterpret_cast<const T*>(Data); + return *reinterpret_cast<const T*>(Data); } template <class T> T& Get() { - return *reinterpret_cast<T*>(Data); + return *reinterpret_cast<T*>(Data); } template <class T> diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp index f3de2098cd..3c974c85a0 100644 --- a/library/cpp/lwtrace/trace.cpp +++ b/library/cpp/lwtrace/trace.cpp @@ -46,7 +46,7 @@ namespace NLWTrace { void TProbeRegistry::AddProbeNoLock(const TBoxPtr& box) { TProbe* probe = box->GetProbe(); - if (Probes.contains(probe)) { + if (Probes.contains(probe)) { return; // silently skip probe double registration } TIds::key_type key(probe->Event.GetProvider(), probe->Event.Name); @@ -1005,7 +1005,7 @@ namespace NLWTrace { bool TManager::HasTrace(const TString& id) const { TGuard<TMutex> g(Mtx); - return Traces.contains(id); + return Traces.contains(id); } const TSession* TManager::GetTrace(const TString& id) const { diff --git a/library/cpp/messagebus/actor/executor.cpp b/library/cpp/messagebus/actor/executor.cpp index 5b38e87495..7a2227a458 100644 --- a/library/cpp/messagebus/actor/executor.cpp +++ b/library/cpp/messagebus/actor/executor.cpp @@ -322,7 +322,7 @@ void TExecutor::RunWorker() { Y_VERIFY(!ThreadCurrentExecutor, "state check"); ThreadCurrentExecutor = this; - SetCurrentThreadName("wrkr"); + SetCurrentThreadName("wrkr"); for (;;) { TAutoPtr<IWorkItem> wi = DequeueWork(); diff --git a/library/cpp/messagebus/actor/thread_extra.cpp b/library/cpp/messagebus/actor/thread_extra.cpp index ad59d7113a..048480f255 100644 --- a/library/cpp/messagebus/actor/thread_extra.cpp +++ b/library/cpp/messagebus/actor/thread_extra.cpp @@ -19,12 +19,12 @@ namespace { #endif } -void SetCurrentThreadName(const char* name) { +void SetCurrentThreadName(const char* name) { #ifdef _linux_ TStringStream linuxName; linuxName << GetExecName() << "." << name; - TThread::SetCurrentThreadName(linuxName.Str().data()); + TThread::SetCurrentThreadName(linuxName.Str().data()); #else - TThread::SetCurrentThreadName(name); + TThread::SetCurrentThreadName(name); #endif } diff --git a/library/cpp/messagebus/actor/thread_extra.h b/library/cpp/messagebus/actor/thread_extra.h index 5e8e271beb..b5aa151618 100644 --- a/library/cpp/messagebus/actor/thread_extra.h +++ b/library/cpp/messagebus/actor/thread_extra.h @@ -24,7 +24,7 @@ namespace NTSAN { } -void SetCurrentThreadName(const char* name); +void SetCurrentThreadName(const char* name); namespace NThreadExtra { namespace NPrivate { diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h index 892f841abc..b79c0cc355 100644 --- a/library/cpp/messagebus/config/netaddr.h +++ b/library/cpp/messagebus/config/netaddr.h @@ -1,7 +1,7 @@ #pragma once #include <util/digest/numeric.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/ptr.h> #include <util/generic/strbuf.h> #include <util/generic/vector.h> @@ -73,13 +73,13 @@ namespace NBus { switch (s->sa_family) { case AF_INET: - return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port)); + return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port)); case AF_INET6: - return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa6->sin6_addr), sizeof(sa6->sin6_addr))), IntHashImpl(sa6->sin6_port)); + return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa6->sin6_addr), sizeof(sa6->sin6_addr))), IntHashImpl(sa6->sin6_port)); } - return ComputeHash(TStringBuf(reinterpret_cast<const char*>(s), a.Len())); + return ComputeHash(TStringBuf(reinterpret_cast<const char*>(s), a.Len())); } }; diff --git a/library/cpp/messagebus/event_loop.cpp b/library/cpp/messagebus/event_loop.cpp index 71f6f45d96..f685135bed 100644 --- a/library/cpp/messagebus/event_loop.cpp +++ b/library/cpp/messagebus/event_loop.cpp @@ -281,7 +281,7 @@ void TEventLoop::TImpl::Run() { Y_VERIFY(res, "Invalid mbus event loop state"); if (!!Name) { - SetCurrentThreadName(Name); + SetCurrentThreadName(Name); } while (AtomicGet(StopSignal) == 0) { diff --git a/library/cpp/messagebus/socket_addr.h b/library/cpp/messagebus/socket_addr.h index 7b28c8ce82..959eafe689 100644 --- a/library/cpp/messagebus/socket_addr.h +++ b/library/cpp/messagebus/socket_addr.h @@ -2,7 +2,7 @@ #include "hash.h" -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/generic/utility.h> #include <util/network/address.h> #include <util/network/init.h> @@ -101,7 +101,7 @@ namespace NBus { template <> struct THash<NBus::NPrivate::TBusIpAddr> { inline size_t operator()(const NBus::NPrivate::TBusIpAddr& a) const { - return ComputeHash(TStringBuf((const char*)&a, sizeof(a))); + return ComputeHash(TStringBuf((const char*)&a, sizeof(a))); } }; diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp index c3a084d5b6..8489319278 100644 --- a/library/cpp/messagebus/test/perftest/perftest.cpp +++ b/library/cpp/messagebus/test/perftest/perftest.cpp @@ -260,7 +260,7 @@ public: /// dispatch of requests is done here void Work() { - SetCurrentThreadName("FastClient::Work"); + SetCurrentThreadName("FastClient::Work"); while (!TheExit) { TBusClientConnection* connection; @@ -524,7 +524,7 @@ void stopsignal(int /*sig*/) { // -c <node:port,node:port> - start client void TTestStats::PeriodicallyPrint() { - SetCurrentThreadName("print-stats"); + SetCurrentThreadName("print-stats"); for (;;) { StopEvent.WaitT(TDuration::Seconds(1)); diff --git a/library/cpp/monlib/counters/counters_ut.cpp b/library/cpp/monlib/counters/counters_ut.cpp index 8e3cfb936f..2845efb97b 100644 --- a/library/cpp/monlib/counters/counters_ut.cpp +++ b/library/cpp/monlib/counters/counters_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/set.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> using namespace NMonitoring; @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TDeprecatedCountersTest) { } }; - TThreadPool q; + TThreadPool q; q.Start(THREADS_COUNT); for (ui32 i = 0; i < THREADS_COUNT; i++) { q.SafeAddFunc(adder); diff --git a/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp b/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp index 8d9d468232..53683cb39c 100644 --- a/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp +++ b/library/cpp/monlib/encode/legacy_protobuf/legacy_protobuf_ut.cpp @@ -97,7 +97,7 @@ void AssertSimpleMessage(const NProto::TMultiSamplesList& samples, TString pathP UNIT_ASSERT_EQUAL(s.PointsSize(), 1); const auto labelVal = s.GetLabels(0).GetValue(); - UNIT_ASSERT(expectedValues.contains(labelVal)); + UNIT_ASSERT(expectedValues.contains(labelVal)); if (labelVal == pathPrefix + "Foo") { UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::GAUGE); diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index bbd3dabda1..929efbf816 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -203,13 +203,13 @@ namespace NMonitoring { const TMtHttpServer& Parent; }; - TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool) + TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool) : THttpServer(this, options, pool) , Handler(std::move(handler)) { } - TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool) + TMtHttpServer::TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool) : THttpServer(this, /* mainWorkers = */pool, /* failWorkers = */pool, options) , Handler(std::move(handler)) { diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 270f42ef66..2f66dddaf8 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -60,8 +60,8 @@ namespace NMonitoring { class TMtHttpServer: public THttpServer, private THttpServer::ICallBack { public: - TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool = nullptr); - TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool); + TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool = nullptr); + TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool); /** * This will cause the server start to accept incoming connections. diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index a5508e0afe..96cc11bcfd 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -134,7 +134,7 @@ namespace NObjectFactory { template<class... Args> static THolder<TProduct> MakeHolder(Args&&... args) { - return THolder<TProduct>(Construct(std::forward<Args>(args)...)); + return THolder<TProduct>(Construct(std::forward<Args>(args)...)); } static bool Has(const TKey& key) { diff --git a/library/cpp/packedtypes/longs_ut.cpp b/library/cpp/packedtypes/longs_ut.cpp index c2ee49b9e1..8b06c934d2 100644 --- a/library/cpp/packedtypes/longs_ut.cpp +++ b/library/cpp/packedtypes/longs_ut.cpp @@ -5,7 +5,7 @@ #include <library/cpp/digest/old_crc/crc.h> #include <util/string/util.h> #include <util/stream/output.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> Y_UNIT_TEST_SUITE(TLongsTest) { Y_UNIT_TEST(TestLongs) { @@ -15,14 +15,14 @@ Y_UNIT_TEST_SUITE(TLongsTest) { 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)); + s += Sprintf("LO_8(x16)=0x%x HI_8(x16)=0x%x\n\n", (int)Lo8(x16), (int)Hi8(x16)); char buf[100]; memset(buf, 0, 100); char* p = buf; int l = out_long(x64, buf); s += Sprintf("x64=0x%" PRIi64 "\n", x64); - s += Sprintf("LO_32(x64)=0x%" PRIu32 " HI_32(x64)=0x%" PRIu32 "\n", (ui32)Lo32(x64), (ui32)Hi32(x64)); + s += Sprintf("LO_32(x64)=0x%" PRIu32 " HI_32(x64)=0x%" PRIu32 "\n", (ui32)Lo32(x64), (ui32)Hi32(x64)); s += Sprintf("buf=%s, l=%d: ", buf, l); for (int i = 0; i < l; i++) { s += Sprintf("0x%02x ", buf[i]); diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index 95d6dfdd47..88cff26ae2 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -65,7 +65,7 @@ struct TZCMemoryInput_traits { } }; -void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) { +void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) { char buf[sizeof(ui32)]; char* bufPtr = buf; size_t size; diff --git a/library/cpp/packedtypes/packedfloat.h b/library/cpp/packedtypes/packedfloat.h index 2d9f04064c..f178912ed3 100644 --- a/library/cpp/packedtypes/packedfloat.h +++ b/library/cpp/packedtypes/packedfloat.h @@ -1,8 +1,8 @@ #pragma once -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/ylimits.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <cmath> #include <cfloat> @@ -34,12 +34,12 @@ namespace NPackedFloat { self& operator=(float t) { assert(SIGNED == 1 || SIGNED == 0 && t >= 0.); - val = BitCast<ui32>(t) >> (15 + SIGNED); + val = BitCast<ui32>(t) >> (15 + SIGNED); return *this; } operator float() const { - return BitCast<float>((ui32)val << (15 + SIGNED)); + return BitCast<float>((ui32)val << (15 + SIGNED)); } static self New(float v) { @@ -81,15 +81,15 @@ namespace NPackedFloat { self& operator=(float t) { assert(SIGNED == 1 || SIGNED == 0 && t >= 0.); - ui16 hi16 = Hi16(t); + ui16 hi16 = Hi16(t); - ui8 sign = SIGNED ? Hi8(hi16) & 0x80 : 0; + ui8 sign = SIGNED ? Hi8(hi16) & 0x80 : 0; - hi16 <<= 1; + hi16 <<= 1; - ui8 fexp = Hi8(hi16); + ui8 fexp = Hi8(hi16); ui8 exp; - ui8 frac = (Lo8(hi16) & 0xf0) >> 4; + ui8 frac = (Lo8(hi16) & 0xf0) >> 4; if (fexp <= FMinExp) { exp = 0; @@ -106,25 +106,25 @@ namespace NPackedFloat { } operator float() const { - ui32 v = 0; + ui32 v = 0; - v |= SIGNED ? (val & 0x80) << 24 : 0; + v |= SIGNED ? (val & 0x80) << 24 : 0; ui8 frac = val & 0x0f; ui8 exp = val & MaxExp; if (exp) { - v |= ((exp >> 4) + FMinExp) << 23 | frac << 19; + v |= ((exp >> 4) + FMinExp) << 23 | frac << 19; } else if (DENORM && val & 0x0f) { while (!(frac & 0x10)) { frac <<= 1; ++exp; } - v |= (FMinExp - exp + 1) << 23 | (frac & 0x0f) << 19; + v |= (FMinExp - exp + 1) << 23 | (frac & 0x0f) << 19; } else - v |= 0; + v |= 0; - return BitCast<float>(v); + return BitCast<float>(v); } static self New(float v) { diff --git a/library/cpp/pop_count/benchmark/main.cpp b/library/cpp/pop_count/benchmark/main.cpp index 272a1c1fe2..41ea3c91cc 100644 --- a/library/cpp/pop_count/benchmark/main.cpp +++ b/library/cpp/pop_count/benchmark/main.cpp @@ -2,7 +2,7 @@ #include <util/datetime/cputimer.h> #include <util/system/type_name.h> -#include <library/cpp/pop_count/popcount.h> +#include <library/cpp/pop_count/popcount.h> #include <library/cpp/testing/benchmark/bench.h> template <class F, class I> diff --git a/library/cpp/pop_count/benchmark/ya.make b/library/cpp/pop_count/benchmark/ya.make index ba34ef196c..7fb54a519a 100644 --- a/library/cpp/pop_count/benchmark/ya.make +++ b/library/cpp/pop_count/benchmark/ya.make @@ -4,7 +4,7 @@ Y_BENCHMARK() PEERDIR( util/draft - library/cpp/pop_count + library/cpp/pop_count ) SRCS( diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index 71ea2721e6..3d67737ed2 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -1,9 +1,9 @@ #pragma once #include <util/generic/typelist.h> -#include <util/system/cpu_id.h> +#include <util/system/cpu_id.h> #include <util/system/defaults.h> -#include <util/system/hi_lo.h> +#include <util/system/hi_lo.h> #include <util/system/platform.h> #if defined(_MSC_VER) @@ -38,7 +38,7 @@ static inline ui32 PopCountImpl(ui32 n) { return __popcnt(n); #else #if defined(_x86_64_) - if (NX86::CachedHavePOPCNT()) { + if (NX86::CachedHavePOPCNT()) { ui32 r; __asm__("popcnt %1, %0;" @@ -61,7 +61,7 @@ static inline ui32 PopCountImpl(ui32 n) { #endif #endif - return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); + return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); #endif } @@ -70,7 +70,7 @@ static inline ui32 PopCountImpl(ui64 n) { return __popcnt64(n); #else #if defined(_x86_64_) - if (NX86::CachedHavePOPCNT()) { + if (NX86::CachedHavePOPCNT()) { ui64 r; __asm__("popcnt %1, %0;" @@ -93,7 +93,7 @@ static inline ui32 PopCountImpl(ui64 n) { #endif #endif - return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); + return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); #endif } diff --git a/library/cpp/pop_count/ut/ya.make b/library/cpp/pop_count/ut/ya.make index 02678db1c2..f0e6c014e5 100644 --- a/library/cpp/pop_count/ut/ya.make +++ b/library/cpp/pop_count/ut/ya.make @@ -1,4 +1,4 @@ -UNITTEST_FOR(library/cpp/pop_count) +UNITTEST_FOR(library/cpp/pop_count) OWNER(g:util) diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index aa185c28d1..640c10f5a5 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -400,7 +400,7 @@ namespace NProtobufJson { knownFields[GetFieldName(*field, config)] = 1; } for (const auto& f : json.GetMap()) { - Y_ENSURE(knownFields.contains(f.first), "unknown field " << f.first); + Y_ENSURE(knownFields.contains(f.first), "unknown field " << f.first); } } } diff --git a/library/cpp/protobuf/json/string_transform.cpp b/library/cpp/protobuf/json/string_transform.cpp index 818928ce91..7c42daa677 100644 --- a/library/cpp/protobuf/json/string_transform.cpp +++ b/library/cpp/protobuf/json/string_transform.cpp @@ -3,7 +3,7 @@ #include <google/protobuf/stubs/strutil.h> #include <library/cpp/string_utils/base64/base64.h> - + namespace NProtobufJson { void TCEscapeTransform::Transform(TString& str) const { str = google::protobuf::CEscape(str); @@ -54,11 +54,11 @@ namespace NProtobufJson { return result; } - void TBase64EncodeBytesTransform::TransformBytes(TString &str) const { - str = Base64Encode(str); - } - - void TBase64DecodeBytesTransform::TransformBytes(TString &str) const { - str = Base64Decode(str); - } + void TBase64EncodeBytesTransform::TransformBytes(TString &str) const { + str = Base64Encode(str); + } + + void TBase64DecodeBytesTransform::TransformBytes(TString &str) const { + str = Base64Decode(str); + } } diff --git a/library/cpp/protobuf/json/string_transform.h b/library/cpp/protobuf/json/string_transform.h index 0603e2f8c3..e4b296bc01 100644 --- a/library/cpp/protobuf/json/string_transform.h +++ b/library/cpp/protobuf/json/string_transform.h @@ -83,29 +83,29 @@ namespace NProtobufJson { TString Unescape(const TString& str) const; }; - class TBase64EncodeBytesTransform: public NProtobufJson::IStringTransform { - public: - int GetType() const override { - return 0; - } - - void Transform(TString&) const override { - // Do not transform strings - } - - void TransformBytes(TString &str) const override; - }; - - class TBase64DecodeBytesTransform: public NProtobufJson::IStringTransform { - public: - int GetType() const override { - return 0; - } - - void Transform(TString&) const override { - // Do not transform strings - } - - void TransformBytes(TString &str) const override; - }; + class TBase64EncodeBytesTransform: public NProtobufJson::IStringTransform { + public: + int GetType() const override { + return 0; + } + + void Transform(TString&) const override { + // Do not transform strings + } + + void TransformBytes(TString &str) const override; + }; + + class TBase64DecodeBytesTransform: public NProtobufJson::IStringTransform { + public: + int GetType() const override { + return 0; + } + + void Transform(TString&) const override { + // Do not transform strings + } + + void TransformBytes(TString &str) const override; + }; } diff --git a/library/cpp/random_provider/random_provider.cpp b/library/cpp/random_provider/random_provider.cpp index 1f04e36834..64cb48b8b7 100644 --- a/library/cpp/random_provider/random_provider.cpp +++ b/library/cpp/random_provider/random_provider.cpp @@ -1,7 +1,7 @@ #include "random_provider.h" #include <util/random/mersenne.h> #include <util/random/random.h> -#include <util/system/unaligned_mem.h> +#include <util/system/unaligned_mem.h> namespace { void SetV4(TGUID& g) { @@ -47,7 +47,7 @@ public: TGUID GenGuid() noexcept override { TGUID ret; - WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); ret.dw[2] = (ui32)Gen.GenRand(); ret.dw[3] = ++GuidCount; return ret; @@ -55,8 +55,8 @@ public: TGUID GenUuid4() noexcept override { TGUID ret; - WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); - WriteUnaligned<ui64>(ret.dw + 2, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw, Gen.GenRand()); + WriteUnaligned<ui64>(ret.dw + 2, Gen.GenRand()); SetV4(ret); return ret; } diff --git a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp index 2781cff8c2..9caa53f2e7 100644 --- a/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp +++ b/library/cpp/regex/hyperscan/ut/hyperscan_ut.cpp @@ -67,8 +67,8 @@ Y_UNIT_TEST_SUITE(HyperscanWrappers) { "fooBaR", callback); UNIT_ASSERT_EQUAL(foundIds.size(), 2); - UNIT_ASSERT(foundIds.contains(42)); - UNIT_ASSERT(foundIds.contains(241)); + UNIT_ASSERT(foundIds.contains(42)); + UNIT_ASSERT(foundIds.contains(241)); } // https://ml.yandex-team.ru/thread/2370000002965712422/ diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 9d03f5e0ce..5184e801cc 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -69,7 +69,7 @@ private: } else { result = "NM"; } - StripInPlace(result); + StripInPlace(result); UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); } } diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index d0803878fb..94bba4064b 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -63,7 +63,7 @@ namespace NRegExp { ucs4[outWritten] = 0; lexer.Assign(ucs4.begin(), - ucs4.begin() + std::char_traits<wchar32>::length(ucs4.data())); + ucs4.begin() + std::char_traits<wchar32>::length(ucs4.data())); } if (opts.CaseInsensitive) { diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 92878eff46..66001c4769 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -22,7 +22,7 @@ namespace { struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { void Store(const TStringBuf key, const TStringBuf data) override { - if (contains(key)) { + if (contains(key)) { const TStringBuf value = (*this)[key]->second; if (value != data) { size_t vsize = GetCodec()->DecompressedLength(value); diff --git a/library/cpp/scheme/domscheme_traits.h b/library/cpp/scheme/domscheme_traits.h index 18e1798fd9..a11c4dd444 100644 --- a/library/cpp/scheme/domscheme_traits.h +++ b/library/cpp/scheme/domscheme_traits.h @@ -1,7 +1,7 @@ #pragma once #include "scheme.h" -#include <util/string/cast.h> +#include <util/string/cast.h> struct TSchemeTraits { using TValue = NSc::TValue; diff --git a/library/cpp/scheme/scheme.cpp b/library/cpp/scheme/scheme.cpp index 3eb2e6c46e..3efd116d4f 100644 --- a/library/cpp/scheme/scheme.cpp +++ b/library/cpp/scheme/scheme.cpp @@ -2,7 +2,7 @@ #include "scimpl_private.h" #include <util/generic/algorithm.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NSc { TStringBufs& TValue::DictKeys(TStringBufs& vs, bool sorted) const { @@ -251,10 +251,10 @@ namespace NSc { } if (coreA.IsString()) { - std::string_view strA = coreA.String; - std::string_view strB = coreB.String; + std::string_view strA = coreA.String; + std::string_view strB = coreB.String; - if (strA != strB) { + if (strA != strB) { return false; } } else if (coreA.IsArray()) { @@ -507,7 +507,7 @@ namespace NSc { namespace NPrivate { int CompareStr(const NSc::TValue& a, TStringBuf b) { - return a.GetString().compare(b); + return a.GetString().compare(b); } int CompareInt(const NSc::TValue& a, i64 r) { diff --git a/library/cpp/scheme/scimpl.h b/library/cpp/scheme/scimpl.h index 5ab13a1955..4f68f16290 100644 --- a/library/cpp/scheme/scimpl.h +++ b/library/cpp/scheme/scimpl.h @@ -552,7 +552,7 @@ namespace NSc { } bool TValue::Has(TStringBuf s) const { - return GetDict().contains(s); + return GetDict().contains(s); } TValue& TValue::GetOrAddUnsafe(size_t idx) { diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp index 2a06e29f22..55a971d9e4 100644 --- a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp +++ b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.cpp @@ -102,23 +102,23 @@ namespace NSc::NUt { TRef TVMAction::GetRef(ui32 arg) const noexcept { - return std::get<TRef>(Arg[arg]); + return std::get<TRef>(Arg[arg]); } TSrc TVMAction::GetSrc(ui32 arg) const noexcept { - return std::get<TSrc>(Arg[arg]); + return std::get<TSrc>(Arg[arg]); } TDst TVMAction::GetDst(ui32 arg) const noexcept { - return std::get<TDst>(Arg[arg]); + return std::get<TDst>(Arg[arg]); } ui32 TVMAction::GetPos(ui32 arg) const noexcept { - return std::get<TPos>(Arg[arg]).Pos; + return std::get<TPos>(Arg[arg]).Pos; } ui32 TVMAction::GetIdx(ui32 arg) const noexcept { - return std::get<TIdx>(Arg[arg]).Idx; + return std::get<TIdx>(Arg[arg]).Idx; } TStringBuf TVMAction::GetKey(ui32 arg) const noexcept { @@ -134,7 +134,7 @@ namespace NSc::NUt { } TStringBuf TVMAction::GetPath(ui32 arg) const noexcept { - return std::get<TPath>(Arg[arg]).Path; + return std::get<TPath>(Arg[arg]).Path; } @@ -143,7 +143,7 @@ namespace NSc::NUt { : Out(out) {} - bool operator()(const std::monostate&) const { + bool operator()(const std::monostate&) const { return true; } //TIdx, TPos, TRef, TSrc, TDst, TPath @@ -159,7 +159,7 @@ namespace NSc::NUt { TStringBuilder out; out << Type; for (const auto& arg : Arg) { - if (std::visit(TActionPrinter(out.Out), arg)) { + if (std::visit(TActionPrinter(out.Out), arg)) { break; } } diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h index 7db4ddeda3..9a0ddf7351 100644 --- a/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h +++ b/library/cpp/scheme/tests/fuzz_ops/lib/vm_defs.h @@ -98,11 +98,11 @@ namespace NSc::NUt { return std::move(Memory[pos]); } - [[nodiscard]] + [[nodiscard]] bool TryPushBack(); template <class T> - [[nodiscard]] + [[nodiscard]] bool TryPushBack(T&& t) { if (MayAddMoreMemory()) { Memory.emplace_back(std::forward<T>(t)); @@ -112,11 +112,11 @@ namespace NSc::NUt { } } - [[nodiscard]] + [[nodiscard]] bool TryPushFront(); template <class T> - [[nodiscard]] + [[nodiscard]] bool TryPushFront(T&& t) { if (MayAddMoreMemory()) { Pos += 1; @@ -127,16 +127,16 @@ namespace NSc::NUt { } } - [[nodiscard]] + [[nodiscard]] bool TryPopBack(); - [[nodiscard]] + [[nodiscard]] bool TryPopFront(); TString ToString() const; private: - [[nodiscard]] + [[nodiscard]] bool MayAddMoreMemory() const noexcept { return Memory.size() < MaxMemory; } @@ -223,7 +223,7 @@ namespace NSc::NUt { TString ToString() const; }; - using TArg = std::variant<std::monostate, TIdx, TPos, TRef, TSrc, TDst, TPath>; + using TArg = std::variant<std::monostate, TIdx, TPos, TRef, TSrc, TDst, TPath>; struct TVMAction { using EType = EVMAction; @@ -269,7 +269,7 @@ namespace NSc::NUt { ui32 CurrArg = 0; }; - [[nodiscard]] + [[nodiscard]] inline ui32 GetCountWidth(ui32 cnt) { return MostSignificantBit(cnt - 1) + 1; } diff --git a/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp b/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp index b464bef666..ce3786a671 100644 --- a/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp +++ b/library/cpp/scheme/tests/fuzz_ops/ut/vm_parse_ut.cpp @@ -32,14 +32,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParsePos(st)); } - [[nodiscard]] + [[nodiscard]] ui32 DoTestParsePosSuccess(TVMState& st) { const auto pos = ParsePos(st); UNIT_ASSERT(pos); return pos->Pos; } - [[nodiscard]] + [[nodiscard]] ui32 DoTestParsePosSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParsePosSuccess(st); @@ -81,14 +81,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseRef(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseRefSuccess(TVMState& st) { const auto ref = ParseRef(st); UNIT_ASSERT(ref); return std::make_pair(ref->Pos, ref->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseRefSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseRefSuccess(st); @@ -118,14 +118,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseSrc(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseSrcSuccess(TVMState& st) { const auto src = ParseSrc(st); UNIT_ASSERT(src); return std::make_pair(src->Pos, src->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseSrcSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseSrcSuccess(st); @@ -153,14 +153,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParseDst(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseDstSuccess(TVMState& st) { const auto dst = ParseDst(st); UNIT_ASSERT(dst); return std::make_pair(dst->Pos, dst->Type); } - [[nodiscard]] + [[nodiscard]] auto DoTestParseDstSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParseDstSuccess(st); @@ -201,14 +201,14 @@ Y_UNIT_TEST_SUITE(TestParseNextAction) { UNIT_ASSERT(!ParsePath(st)); } - [[nodiscard]] + [[nodiscard]] auto DoTestParsePathSuccess(TVMState& st) { const auto path = ParsePath(st); UNIT_ASSERT(path); return path->Path; } - [[nodiscard]] + [[nodiscard]] auto DoTestParsePathSuccess(const TStringBuf inp, const ui32 memSz, const ui32 curPos) { TVMState st{inp, memSz, curPos}; return DoTestParsePathSuccess(st); diff --git a/library/cpp/scheme/ut_utils/scheme_ut_utils.h b/library/cpp/scheme/ut_utils/scheme_ut_utils.h index 58876a9b14..eb3ea15b2a 100644 --- a/library/cpp/scheme/ut_utils/scheme_ut_utils.h +++ b/library/cpp/scheme/ut_utils/scheme_ut_utils.h @@ -5,7 +5,7 @@ #include <library/cpp/json/json_value.h> #include <library/cpp/json/json_writer.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/string/cast.h> +#include <util/string/cast.h> namespace NSc { namespace NUt { diff --git a/library/cpp/string_utils/scan/ya.make b/library/cpp/string_utils/scan/ya.make index 9b05c04db1..2faae86b09 100644 --- a/library/cpp/string_utils/scan/ya.make +++ b/library/cpp/string_utils/scan/ya.make @@ -1,11 +1,11 @@ -OWNER( - g:util -) - -LIBRARY() - -SRCS( - scan.cpp -) - -END() +OWNER( + g:util +) + +LIBRARY() + +SRCS( + scan.cpp +) + +END() diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 5e4ce24fb0..85f4ac5d69 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -36,8 +36,8 @@ namespace { template <typename TChar1, typename TChar2> int Compare1Case2(const TChar1* s1, const TChar2* s2, size_t n) { for (size_t i = 0; i < n; ++i) { - if ((TChar1)ToLower(s1[i]) != s2[i]) - return (TChar1)ToLower(s1[i]) < s2[i] ? -1 : 1; + if ((TChar1)ToLower(s1[i]) != s2[i]) + return (TChar1)ToLower(s1[i]) < s2[i] ? -1 : 1; } return 0; } diff --git a/library/cpp/terminate_handler/terminate_handler.cpp b/library/cpp/terminate_handler/terminate_handler.cpp index dbc5fb43ed..d7e8fbed95 100644 --- a/library/cpp/terminate_handler/terminate_handler.cpp +++ b/library/cpp/terminate_handler/terminate_handler.cpp @@ -1,36 +1,36 @@ -#include <cstdlib> +#include <cstdlib> #include <exception> #include <util/stream/output.h> #include <util/system/backtrace.h> #include <util/generic/yexception.h> -namespace { - // Avoid infinite recursion if std::terminate is triggered anew by the - // FancyTerminateHandler. - thread_local int TerminateCount = 0; +namespace { + // Avoid infinite recursion if std::terminate is triggered anew by the + // FancyTerminateHandler. + thread_local int TerminateCount = 0; - void FancyTerminateHandler() { - switch (++TerminateCount) { - case 1: - break; - case 2: - Cerr << "FancyTerminateHandler called recursively" << Endl; + void FancyTerminateHandler() { + switch (++TerminateCount) { + case 1: + break; + case 2: + Cerr << "FancyTerminateHandler called recursively" << Endl; [[fallthrough]]; - default: - abort(); + default: + abort(); break; - } + } - if (std::current_exception()) { - Cerr << "Uncaught exception: " << CurrentExceptionMessage() << '\n'; - } else { - Cerr << "Terminate for unknown reason (no current exception)\n"; - } - PrintBackTrace(); - Cerr.Flush(); + if (std::current_exception()) { + Cerr << "Uncaught exception: " << CurrentExceptionMessage() << '\n'; + } else { + Cerr << "Terminate for unknown reason (no current exception)\n"; + } + PrintBackTrace(); + Cerr.Flush(); abort(); } - [[maybe_unused]] auto _ = std::set_terminate(&FancyTerminateHandler); + [[maybe_unused]] auto _ = std::set_terminate(&FancyTerminateHandler); } diff --git a/library/cpp/terminate_handler/ya.make b/library/cpp/terminate_handler/ya.make index b419b23718..70a9712fed 100644 --- a/library/cpp/terminate_handler/ya.make +++ b/library/cpp/terminate_handler/ya.make @@ -1,12 +1,12 @@ LIBRARY() -OWNER( - ilnurkh - eeight -) +OWNER( + ilnurkh + eeight +) SRCS( - GLOBAL terminate_handler.cpp + GLOBAL terminate_handler.cpp segv_handler.cpp ) diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index dd5c932542..ddd8b05ffc 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -193,7 +193,7 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) { * │ ↓ je 25 * │ xor %edi,%edi * │ xor %esi,%esi - * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char + * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char * │ nop * 100.00 │20:┌─→dec %rbx * │ └──jne 20 diff --git a/library/cpp/testing/gtest_extensions/pretty_printers.h b/library/cpp/testing/gtest_extensions/pretty_printers.h index ea2b850bb1..14d8284446 100644 --- a/library/cpp/testing/gtest_extensions/pretty_printers.h +++ b/library/cpp/testing/gtest_extensions/pretty_printers.h @@ -71,7 +71,7 @@ inline void PrintTo(TNothing /* value */, std::ostream* stream) { *stream << "nothing"; } -inline void PrintTo(std::monostate /* value */, std::ostream* stream) { +inline void PrintTo(std::monostate /* value */, std::ostream* stream) { *stream << "monostate"; } diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index f2b51de0b4..3679b768ed 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -10,7 +10,7 @@ #include <util/system/guard.h> #include <util/system/tls.h> #include <util/system/error.h> -#include <util/string/cast.h> +#include <util/string/cast.h> bool NUnitTest::ShouldColorizeDiff = true; bool NUnitTest::ContinueOnFail = false; diff --git a/library/cpp/threading/equeue/equeue.cpp b/library/cpp/threading/equeue/equeue.cpp index 4a708ef3ad..54a848e912 100644 --- a/library/cpp/threading/equeue/equeue.cpp +++ b/library/cpp/threading/equeue/equeue.cpp @@ -71,10 +71,10 @@ void TElasticQueue::Start(size_t threadCount, size_t maxQueueSize) { SlaveQueue_->Start(threadCount, maxQueueSize); } -void TElasticQueue::Stop() noexcept { +void TElasticQueue::Stop() noexcept { return SlaveQueue_->Stop(); } -size_t TElasticQueue::Size() const noexcept { +size_t TElasticQueue::Size() const noexcept { return SlaveQueue_->Size(); } diff --git a/library/cpp/threading/equeue/equeue.h b/library/cpp/threading/equeue/equeue.h index ff735399e6..40dd342585 100644 --- a/library/cpp/threading/equeue/equeue.h +++ b/library/cpp/threading/equeue/equeue.h @@ -1,11 +1,11 @@ #pragma once -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/system/atomic.h> #include <util/generic/ptr.h> //actual queue limit will be (maxQueueSize - numBusyThreads) or 0 -class TElasticQueue: public IThreadPool { +class TElasticQueue: public IThreadPool { public: explicit TElasticQueue(THolder<IThreadPool> slaveQueue); @@ -21,7 +21,7 @@ private: bool TryIncCounter(); private: - THolder<IThreadPool> SlaveQueue_; + THolder<IThreadPool> SlaveQueue_; size_t MaxQueueSize_ = 0; TAtomic ObjectCount_ = 0; TAtomic GuardCount_ = 0; diff --git a/library/cpp/threading/equeue/equeue_ut.cpp b/library/cpp/threading/equeue/equeue_ut.cpp index d08a94848b..9cf2aced44 100644 --- a/library/cpp/threading/equeue/equeue_ut.cpp +++ b/library/cpp/threading/equeue/equeue_ut.cpp @@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { Counters.Reset(); TryCounter = 0; - struct TSender: public IThreadFactory::IThreadAble { + struct TSender: public IThreadFactory::IThreadAble { void DoExecute() override { while ((size_t)AtomicIncrement(TryCounter) <= N) { if (!TryAdd()) { @@ -108,9 +108,9 @@ Y_UNIT_TEST_SUITE(TElasticQueueTest) { { TQueueSetup setup; - TVector< TAutoPtr<IThreadFactory::IThread> > senders; + TVector< TAutoPtr<IThreadFactory::IThread> > senders; for (size_t i = 0; i < ThreadCount; ++i) { - senders.push_back(::SystemThreadFactory()->Run(&sender)); + senders.push_back(::SystemThreadFactory()->Run(&sender)); } for (size_t i = 0; i < senders.size(); ++i) { diff --git a/library/cpp/threading/future/async.h b/library/cpp/threading/future/async.h index a7e84cc29b..8543fdd5c6 100644 --- a/library/cpp/threading/future/async.h +++ b/library/cpp/threading/future/async.h @@ -3,7 +3,7 @@ #include "future.h" #include <util/generic/function.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> namespace NThreading { /** @@ -18,7 +18,7 @@ namespace NThreading { * unittest. */ template <typename Func> - TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) { + TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) { auto promise = NewPromise<TFutureType<TFunctionResult<Func>>>(); auto lambda = [promise, func = std::forward<Func>(func)]() mutable { NImpl::SetValue(promise, func); diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp index 6901ed2621..a3699744e4 100644 --- a/library/cpp/threading/future/async_ut.cpp +++ b/library/cpp/threading/future/async_ut.cpp @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(Async) { } Y_UNIT_TEST(WorksWithIMtpQueue) { - auto queue = MakeHolder<TThreadPool>(); + auto queue = MakeHolder<TThreadPool>(); queue->Start(1); auto future = NThreading::Async([]() { return 5; }, *queue); @@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(Async) { Y_UNIT_TEST(ProperlyDeducesFutureType) { // Compileability test - auto queue = CreateThreadPool(1); + auto queue = CreateThreadPool(1); NThreading::TFuture<void> f1 = NThreading::Async([]() {}, *queue); NThreading::TFuture<int> f2 = NThreading::Async([]() { return 5; }, *queue); diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h index 5240f92992..6f1eabad73 100644 --- a/library/cpp/threading/future/legacy_future.h +++ b/library/cpp/threading/future/legacy_future.h @@ -3,13 +3,13 @@ #include "fwd.h" #include "future.h" -#include <util/thread/factory.h> +#include <util/thread/factory.h> #include <functional> namespace NThreading { template <typename TR, bool IgnoreException> - class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { + class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable { public: typedef TR(TFunctionSignature)(); using TFunctionObjectType = std::function<TFunctionSignature>; @@ -18,10 +18,10 @@ namespace NThreading { private: TFunctionObjectType Func_; TPromise<TResult> Result_; - THolder<IThreadFactory::IThread> Thread_; + THolder<IThreadFactory::IThread> Thread_; public: - inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory()) + inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory()) : Func_(func) , Result_(NewPromise<TResult>()) , Thread_(pool->Run(this)) diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp index 873c913d82..ff63db1725 100644 --- a/library/cpp/threading/future/legacy_future_ut.cpp +++ b/library/cpp/threading/future/legacy_future_ut.cpp @@ -43,7 +43,7 @@ namespace NThreading { TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3))); UNIT_ASSERT_VALUES_EQUAL(4, f11.Get()); - TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory()); + TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(4, f12.Get()); TSampleClass c(5); @@ -51,17 +51,17 @@ namespace NThreading { TLegacyFuture<int> f21(std::bind(&TSampleClass::Calc, std::ref(c))); UNIT_ASSERT_VALUES_EQUAL(6, f21.Get()); - TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory()); + TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(6, f22.Get()); } - struct TSomeThreadPool: public IThreadFactory {}; + struct TSomeThreadPool: public IThreadFactory {}; Y_UNIT_TEST(TestFunction) { std::function<int()> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get()); - UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get()); + UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get()); if (false) { TSomeThreadPool* q = nullptr; diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h index a80b65a933..2753d5446c 100644 --- a/library/cpp/threading/future/wait/wait-inl.h +++ b/library/cpp/threading/future/wait/wait-inl.h @@ -6,31 +6,31 @@ namespace NThreading { namespace NImpl { - template <typename TContainer> - TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) { - TVector<TFuture<void>> voidFutures; - voidFutures.reserve(futures.size()); + template <typename TContainer> + TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) { + TVector<TFuture<void>> voidFutures; + voidFutures.reserve(futures.size()); - for (const auto& future: futures) { - voidFutures.push_back(future.IgnoreResult()); + for (const auto& future: futures) { + voidFutures.push_back(future.IgnoreResult()); } - return voidFutures; + return voidFutures; } } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) { - return WaitAll(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) { + return WaitAll(NImpl::ToVoidFutures(futures)); } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { - return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { + return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); } template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) { - return WaitAny(NImpl::ToVoidFutures(futures)); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) { + return WaitAny(NImpl::ToVoidFutures(futures)); } } diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp index cc33f3189c..a173833a7f 100644 --- a/library/cpp/threading/future/wait/wait.cpp +++ b/library/cpp/threading/future/wait/wait.cpp @@ -1,17 +1,17 @@ -#include "wait.h" +#include "wait.h" #include "wait_group.h" #include "wait_policy.h" namespace NThreading { - namespace { + namespace { template <class WaitPolicy> - TFuture<void> WaitGeneric(const TFuture<void>& f1) { + TFuture<void> WaitGeneric(const TFuture<void>& f1) { return f1; } template <class WaitPolicy> - TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) { + TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) { TWaitGroup<WaitPolicy> wg; wg.Add(f1).Add(f2); @@ -19,13 +19,13 @@ namespace NThreading { return std::move(wg).Finish(); } - template <class WaitPolicy> - TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) { + template <class WaitPolicy> + TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) { if (futures.empty()) { return MakeFuture(); } if (futures.size() == 1) { - return futures.front(); + return futures.front(); } TWaitGroup<WaitPolicy> wg; @@ -39,44 +39,44 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitAll(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TAll>(f1); + TFuture<void> WaitAll(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TAll>(f1); } - TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TAll>(f1, f2); + TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TAll>(f1, f2); } - TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TAll>(futures); + TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TAll>(futures); } //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1); + TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1); } - TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2); + TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2); } - TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures); + TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures); } //////////////////////////////////////////////////////////////////////////////// - TFuture<void> WaitAny(const TFuture<void>& f1) { - return WaitGeneric<TWaitPolicy::TAny>(f1); + TFuture<void> WaitAny(const TFuture<void>& f1) { + return WaitGeneric<TWaitPolicy::TAny>(f1); } - TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) { - return WaitGeneric<TWaitPolicy::TAny>(f1, f2); + TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) { + return WaitGeneric<TWaitPolicy::TAny>(f1, f2); } - TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) { - return WaitGeneric<TWaitPolicy::TAny>(futures); + TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) { + return WaitGeneric<TWaitPolicy::TAny>(futures); } } diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index ade4c9a3ad..6ff7d57baa 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -5,35 +5,35 @@ #include <library/cpp/threading/future/core/future.h> #include <library/cpp/threading/future/wait/wait_group.h> -#include <util/generic/array_ref.h> - +#include <util/generic/array_ref.h> + namespace NThreading { - namespace NImpl { - template <class TContainer> - using EnableGenericWait = std::enable_if_t< - !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>, - TFuture<void>>; - } + namespace NImpl { + template <class TContainer> + using EnableGenericWait = std::enable_if_t< + !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>, + TFuture<void>>; + } // waits for all futures [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures); // waits for the first exception or for all futures [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); // waits for any future [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1); [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2); - [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures); + [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures); template <typename TContainer> - [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures); + [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures); } #define INCLUDE_FUTURE_INL_H diff --git a/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp b/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp index bf5b734411..e82063d959 100644 --- a/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp +++ b/library/cpp/threading/light_rw_lock/ut/rwlock_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/random/random.h> #include <util/system/atomic.h> -#include <util/thread/pool.h> +#include <util/thread/pool.h> class TRWMutexTest: public TTestBase { UNIT_TEST_SUITE(TRWMutexTest); @@ -116,7 +116,7 @@ private: #undef RUN_CYCLE private: TSharedData Data_; - TThreadPool Q_; + TThreadPool Q_; }; UNIT_TEST_SUITE_REGISTRATION(TRWMutexTest) diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 528f35a74d..1d3fbb4bf4 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -166,7 +166,7 @@ void* NPar::TLocalExecutor::TImpl::HostWorkerThread(void* p) { static const int FAST_ITERATIONS = 200; auto* const ctx = (TImpl*)p; - TThread::SetCurrentThreadName("ParLocalExecutor"); + TThread::SetCurrentThreadName("ParLocalExecutor"); ctx->WorkerThreadId = AtomicAdd(ctx->ThreadId, 1); for (bool cont = true; cont;) { TSingleJob job; diff --git a/library/cpp/threading/poor_man_openmp/thread_helper.h b/library/cpp/threading/poor_man_openmp/thread_helper.h index d1744f217d..0ecee0590b 100644 --- a/library/cpp/threading/poor_man_openmp/thread_helper.h +++ b/library/cpp/threading/poor_man_openmp/thread_helper.h @@ -1,6 +1,6 @@ #pragma once -#include <util/thread/pool.h> +#include <util/thread/pool.h> #include <util/generic/utility.h> #include <util/generic/yexception.h> #include <util/system/info.h> @@ -17,7 +17,7 @@ public: TMtpQueueHelper() { SetThreadCount(NSystemInfo::CachedNumberOfCpus()); } - IThreadPool* Get() { + IThreadPool* Get() { return q.Get(); } size_t GetThreadCount() { @@ -25,14 +25,14 @@ public: } void SetThreadCount(size_t threads) { ThreadCount = threads; - q = CreateThreadPool(ThreadCount); + q = CreateThreadPool(ThreadCount); } static TMtpQueueHelper& Instance(); private: size_t ThreadCount; - TAutoPtr<IThreadPool> q; + TAutoPtr<IThreadPool> q; }; namespace NYmp { @@ -49,7 +49,7 @@ namespace NYmp { chunkSize = Max<size_t>(chunkSize, 1); size_t threadCount = TMtpQueueHelper::Instance().GetThreadCount(); - IThreadPool* queue = TMtpQueueHelper::Instance().Get(); + IThreadPool* queue = TMtpQueueHelper::Instance().Get(); TCondVar cv; TMutex mutex; TAtomic counter = threadCount; diff --git a/library/cpp/threading/skip_list/perf/main.cpp b/library/cpp/threading/skip_list/perf/main.cpp index 8194a660cb..4ad52049e7 100644 --- a/library/cpp/threading/skip_list/perf/main.cpp +++ b/library/cpp/threading/skip_list/perf/main.cpp @@ -198,7 +198,7 @@ namespace { } for (size_t i = 0; i < tests.size(); ++i) { - if (!AllTests.contains(tests[i])) { + if (!AllTests.contains(tests[i])) { LogError() << "unknown test name: " << tests[i] << Endl; return false; } diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp index d428a0f8a3..174dde4bf7 100644 --- a/library/cpp/threading/task_scheduler/task_scheduler.cpp +++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp @@ -21,7 +21,7 @@ public: TString DebugState = "?"; TString DebugId = ""; private: - void* ThreadProc() noexcept override { + void* ThreadProc() noexcept override { Scheduler_.WorkerFunc(this); return nullptr; } diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp index 8b3fea5494..5986318b9a 100644 --- a/library/cpp/timezone_conversion/civil.cpp +++ b/library/cpp/timezone_conversion/civil.cpp @@ -70,7 +70,7 @@ namespace NDatetime { return GetFixedTimeZone(offset); } TTimeZone result; - if (!cctz::load_time_zone(static_cast<std::string>(name), &result)) { + if (!cctz::load_time_zone(static_cast<std::string>(name), &result)) { ythrow TInvalidTimezone() << "Failed to load time zone " << name << ", " << result.name(); } return result; diff --git a/library/cpp/timezone_conversion/civil.h b/library/cpp/timezone_conversion/civil.h index 4030dd3305..0e95b807ed 100644 --- a/library/cpp/timezone_conversion/civil.h +++ b/library/cpp/timezone_conversion/civil.h @@ -213,7 +213,7 @@ namespace NDatetime { */ template <typename TP> TString Format(TStringBuf fmt, const TP& tp, const TTimeZone& tz) { - return TString(cctz::format(static_cast<std::string>(fmt), TTimePoint(cctz::convert(tp, tz)), tz)); + return TString(cctz::format(static_cast<std::string>(fmt), TTimePoint(cctz::convert(tp, tz)), tz)); } /** Returns the weekday by day. diff --git a/library/cpp/tld/tld.cpp b/library/cpp/tld/tld.cpp index 61d3f0e4ef..e31f3f0322 100644 --- a/library/cpp/tld/tld.cpp +++ b/library/cpp/tld/tld.cpp @@ -38,11 +38,11 @@ namespace NTld { } bool IsTld(const TStringBuf& s) { - return Default<TTLDHash>().contains(s); + return Default<TTLDHash>().contains(s); } bool IsVeryGoodTld(const TStringBuf& s) { - return Default<TVeryGoodTld>().contains(s); + return Default<TVeryGoodTld>().contains(s); } } diff --git a/library/cpp/tvmauth/client/misc/src_checker.h b/library/cpp/tvmauth/client/misc/src_checker.h index b2de25dd94..25e8e72602 100644 --- a/library/cpp/tvmauth/client/misc/src_checker.h +++ b/library/cpp/tvmauth/client/misc/src_checker.h @@ -28,7 +28,7 @@ namespace NTvmAuth { return ticket; } - TServiceTicketImplPtr impl = THolder(NInternal::TCanningKnife::GetS(ticket)); + TServiceTicketImplPtr impl = THolder(NInternal::TCanningKnife::GetS(ticket)); impl->SetStatus(ETicketStatus::NoRoles); return TCheckedServiceTicket(std::move(impl)); } diff --git a/library/cpp/unicode/normalization/custom_encoder.cpp b/library/cpp/unicode/normalization/custom_encoder.cpp index 2e8ca0c575..c6f186405f 100644 --- a/library/cpp/unicode/normalization/custom_encoder.cpp +++ b/library/cpp/unicode/normalization/custom_encoder.cpp @@ -64,7 +64,7 @@ void TCustomEncoder::Create(const CodePage* target, bool extended) { Y_ASSERT(decomp_p != nullptr); dw = decomp_p[0]; - if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) + if (std::char_traits<wchar32>::length(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'(')) dw = decomp_p[1]; } if (Code(dw) != 0 && isGoodDecomp(w, dw)) diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index a16b360d56..800d1f19fe 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -106,7 +106,7 @@ TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { CheckIdnaResult(rc); TUtf16String decoded; - AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); + AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); return decoded; } diff --git a/library/cpp/uri/other.cpp b/library/cpp/uri/other.cpp index 687c31df7b..b23a5b68a9 100644 --- a/library/cpp/uri/other.cpp +++ b/library/cpp/uri/other.cpp @@ -35,12 +35,12 @@ void UnTrspChars(const char* s, char* d) { void InvertDomain(char* begin, char* end) { // skip schema if it is present - const auto dotPos = TStringBuf{begin, end}.find('.'); - if (dotPos == TStringBuf::npos) + const auto dotPos = TStringBuf{begin, end}.find('.'); + if (dotPos == TStringBuf::npos) return; // no need to invert anything - const auto schemaendPos = TStringBuf{begin, end}.find("://", 3); - if (schemaendPos < dotPos) - begin += schemaendPos + 3; + const auto schemaendPos = TStringBuf{begin, end}.find("://", 3); + if (schemaendPos < dotPos) + begin += schemaendPos + 3; char* sl = (char*)memchr(begin, '/', end - begin); char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin); end = cl ? cl : (sl ? sl : end); diff --git a/library/cpp/xml/document/xml-textreader_ut.cpp b/library/cpp/xml/document/xml-textreader_ut.cpp index aea1b249b6..6232dfe47e 100644 --- a/library/cpp/xml/document/xml-textreader_ut.cpp +++ b/library/cpp/xml/document/xml-textreader_ut.cpp @@ -159,20 +159,20 @@ Y_UNIT_TEST_SUITE(TestXmlTextReader) { UNIT_ASSERT_EQUAL(data.size(), 3); - UNIT_ASSERT(data.contains(225)); + UNIT_ASSERT(data.contains(225)); const TCountry& russia = data.at(225); UNIT_ASSERT_EQUAL(russia.Name, "Россия"); UNIT_ASSERT_EQUAL(russia.Cities.size(), 2); UNIT_ASSERT_EQUAL(russia.Cities[0], "Москва"); UNIT_ASSERT_EQUAL(russia.Cities[1], "Санкт-Петербург"); - UNIT_ASSERT(data.contains(149)); + UNIT_ASSERT(data.contains(149)); const TCountry& belarus = data.at(149); UNIT_ASSERT_EQUAL(belarus.Name, "Беларусь"); UNIT_ASSERT_EQUAL(belarus.Cities.size(), 1); UNIT_ASSERT_EQUAL(belarus.Cities[0], "Минск"); - UNIT_ASSERT(data.contains(187)); + UNIT_ASSERT(data.contains(187)); const TCountry& ukraine = data.at(187); UNIT_ASSERT_EQUAL(ukraine.Name, "Украина"); UNIT_ASSERT_EQUAL(ukraine.Cities.size(), 1); diff --git a/library/cpp/ya.make b/library/cpp/ya.make index a66c9ebf25..8c1193b007 100644 --- a/library/cpp/ya.make +++ b/library/cpp/ya.make @@ -41,7 +41,7 @@ RECURSE( clustered_hnsw clustered_hnsw/ut codecs - codecs/float_huffman_bench + codecs/float_huffman_bench codecs/greedy_dict/ut codecs/static/tools codecs/static/tools/tests @@ -86,8 +86,8 @@ RECURSE( dot_product dot_product/bench dot_product/ut - dwarf_backtrace - dwarf_backtrace/registry + dwarf_backtrace + dwarf_backtrace/registry edit_distance edit_distance/ut enumbitset @@ -120,8 +120,8 @@ RECURSE( file_checker/test file_checker/test/tests file_checker/ut - flatbuffers64_introspection - flatbuffers64_introspection/example + flatbuffers64_introspection + flatbuffers64_introspection/example float16 float16/ut framing @@ -274,9 +274,9 @@ RECURSE( packers/ut par perceptron - pop_count - pop_count/benchmark - pop_count/ut + pop_count + pop_count/benchmark + pop_count/ut presort presort/ut prob_counter @@ -321,9 +321,9 @@ RECURSE( scheme/ut_utils scores scores/ut - select_in_word - select_in_word/bench - select_in_word/ut + select_in_word + select_in_word/bench + select_in_word/ut semver semver/ut shingles diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index a7daf0f2f6..b39e070718 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -4,8 +4,8 @@ #include <library/cpp/yson/writer.h> -#include <util/generic/overloaded.h> - +#include <util/generic/overloaded.h> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -279,17 +279,17 @@ size_t TNode::Size() const TNode::EType TNode::GetType() const { - return std::visit(TOverloaded{ - [](const TUndefined&) { return Undefined; }, - [](const TString&) { return String; }, - [](i64) { return Int64; }, - [](ui64) { return Uint64; }, - [](double) { return Double; }, - [](bool) { return Bool; }, - [](const TListType&) { return List; }, - [](const TMapType&) { return Map; }, - [](const TNull&) { return Null; } - }, Value_); + return std::visit(TOverloaded{ + [](const TUndefined&) { return Undefined; }, + [](const TString&) { return String; }, + [](i64) { return Int64; }, + [](ui64) { return Uint64; }, + [](double) { return Double; }, + [](bool) { return Bool; }, + [](const TListType&) { return List; }, + [](const TMapType&) { return Map; }, + [](const TNull&) { return Null; } + }, Value_); } const TString& TNode::AsString() const diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 98f3f217e4..7440ac3fdd 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -3,7 +3,7 @@ #include <library/cpp/yt/assert/assert.h> -#include <util/generic/hash.h> +#include <util/generic/hash.h> #include <util/string/ascii.h> @@ -220,7 +220,7 @@ size_t TCaseInsensitiveStringHasher::operator()(TStringBuf arg) const for (size_t index = 0; index < arg.length(); ++index) { buffer[index] = AsciiToLower(arg[index]); } - return ComputeHash(TStringBuf(buffer, arg.length())); + return ComputeHash(TStringBuf(buffer, arg.length())); }; const size_t SmallSize = 256; if (arg.length() <= SmallSize) { |