From 474983e1fd553fb7c3927ede1a60d7f93d2785d5 Mon Sep 17 00:00:00 2001 From: Yehor Shapanov Date: Mon, 22 Jan 2024 10:52:38 +0200 Subject: [PATCH 1/2] Replaced TList with std::list --- contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h | 2 +- contrib/libs/tcmalloc/tcmalloc/huge_region.h | 2 +- contrib/libs/tcmalloc/tcmalloc/span.h | 2 +- library/cpp/dbg_output/dumpers.h | 2 +- library/cpp/getopt/small/last_getopt_parser.h | 5 ++--- library/cpp/monlib/counters/counters.h | 6 +++--- library/cpp/testing/unittest/utmain.cpp | 2 +- util/generic/list_ut.cpp | 4 ++-- util/generic/queue_ut.cpp | 2 +- util/system/shellcommand.cpp | 8 ++++---- util/system/shellcommand.h | 5 ++--- util/ysaveload.h | 4 ---- util/ysaveload_ut.cpp | 3 +-- 13 files changed, 20 insertions(+), 27 deletions(-) diff --git a/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h b/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h index 2f72b438818..c4395ae5cba 100644 --- a/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h +++ b/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h @@ -907,7 +907,7 @@ class HugePageFiller { void PrintInPbtxt(PbtxtRegion* hpaa) const; private: - typedef TList TrackerList; + typedef std::list TrackerList; // This class wraps an array of N TrackerLists and a Bitmap storing which // elements are non-empty. diff --git a/contrib/libs/tcmalloc/tcmalloc/huge_region.h b/contrib/libs/tcmalloc/tcmalloc/huge_region.h index 0262c007b21..f3902273649 100644 --- a/contrib/libs/tcmalloc/tcmalloc/huge_region.h +++ b/contrib/libs/tcmalloc/tcmalloc/huge_region.h @@ -213,7 +213,7 @@ class HugeRegionSet { size_t n_; // Sorted by longest_free increasing. - TList list_; + std::list list_; }; // REQUIRES: r.len() == size(); r unbacked. diff --git a/contrib/libs/tcmalloc/tcmalloc/span.h b/contrib/libs/tcmalloc/tcmalloc/span.h index c589709094c..03aaabfe1eb 100644 --- a/contrib/libs/tcmalloc/tcmalloc/span.h +++ b/contrib/libs/tcmalloc/tcmalloc/span.h @@ -67,7 +67,7 @@ inline constexpr size_t kBitmapScalingDenominator = 65536; // and is on returned PageHeap list. // location_ == ON_RETURNED_FREELIST. class Span; -typedef TList SpanList; +typedef std::list SpanList; class Span : public SpanList::Elem { public: diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index 4868e97da07..86f14849105 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -111,7 +111,7 @@ struct TDumper>: public TSeqDumper { }; template -struct TDumper>: public TSeqDumper { +struct TDumper>: public TSeqDumper { }; //associatives diff --git a/library/cpp/getopt/small/last_getopt_parser.h b/library/cpp/getopt/small/last_getopt_parser.h index 2cf8a6c308d..07e6c16d67e 100644 --- a/library/cpp/getopt/small/last_getopt_parser.h +++ b/library/cpp/getopt/small/last_getopt_parser.h @@ -3,9 +3,8 @@ #include "last_getopt_opts.h" #include - +#include #include -#include namespace NLastGetopt { /** @@ -53,7 +52,7 @@ namespace NLastGetopt { typedef THashSet TdOptSet; TdOptSet OptsSeen_; //the set of options that have been met during parsing - TList OptsDefault_; + std::list OptsDefault_; private: void Init(const TOpts* options, int argc, const char* argv[]); diff --git a/library/cpp/monlib/counters/counters.h b/library/cpp/monlib/counters/counters.h index d3943d65787..2baa6fa0659 100644 --- a/library/cpp/monlib/counters/counters.h +++ b/library/cpp/monlib/counters/counters.h @@ -1,8 +1,8 @@ #pragma once +#include #include #include -#include #include #include #include @@ -248,7 +248,7 @@ namespace NMonitoring { private: TCollection* Groups; - TList OldGroups; + std::list OldGroups; TSpinLock AddMutex; ui64 Timeout; @@ -295,7 +295,7 @@ namespace NMonitoring { Groups->Free(); delete Groups; Groups = nullptr; - typename TList::iterator i; + typename std::list::iterator i; for (i = OldGroups.begin(); i != OldGroups.end(); ++i) { delete i->Collection; i->Collection = nullptr; diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 6ecfc3a64f3..0e383e5f38a 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -525,7 +525,7 @@ class TColoredProcessor: public ITestSuiteProcessor, public NColorizer::TColors return f(); } - TList args(1, "--is-forked-internal"); + std::list args(1, "--is-forked-internal"); args.push_back(Sprintf("+%s::%s", suite.data(), name)); // stdin is ignored - unittest should not need them... diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp index 9e60ecf01b4..e0febc5f00b 100644 --- a/util/generic/list_ut.cpp +++ b/util/generic/list_ut.cpp @@ -4,8 +4,8 @@ Y_UNIT_TEST_SUITE(TYListSuite) { Y_UNIT_TEST(TestInitializerList) { - TList l = {3, 42, 6}; - TList expected; + std::list l = {3, 42, 6}; + std::list expected; expected.push_back(3); expected.push_back(42); expected.push_back(6); diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp index a33399e1048..0fd19392abc 100644 --- a/util/generic/queue_ut.cpp +++ b/util/generic/queue_ut.cpp @@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { } Y_UNIT_TEST(queue1) { - TQueue> q; + TQueue> q; q.push(42); q.push(101); diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index 6742f46c641..a2c87dea3b3 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -190,7 +190,7 @@ class TShellCommand::TImpl : public TAtomicRefCount { private: TString Command; - TList Arguments; + std::list Arguments; TShellCommandOptions Options_; TString WorkDir; @@ -263,7 +263,7 @@ class TShellCommand::TImpl #endif public: - inline TImpl(const TStringBuf cmd, const TList& args, const TShellCommandOptions& options, const TString& workdir) + inline TImpl(const TStringBuf cmd, const std::list& args, const TShellCommandOptions& options, const TString& workdir) : Command(ToString(cmd)) , Arguments(args) , Options_(options) @@ -1087,14 +1087,14 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) { TerminateIsRequired(pi); } -TShellCommand::TShellCommand(const TStringBuf cmd, const TList& args, const TShellCommandOptions& options, +TShellCommand::TShellCommand(const TStringBuf cmd, const std::list& args, const TShellCommandOptions& options, const TString& workdir) : Impl(new TImpl(cmd, args, options, workdir)) { } TShellCommand::TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options, const TString& workdir) - : Impl(new TImpl(cmd, TList(), options, workdir)) + : Impl(new TImpl(cmd, std::list(), options, workdir)) { } diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h index 6c2b9e276c8..0bd1b9272da 100644 --- a/util/system/shellcommand.h +++ b/util/system/shellcommand.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -13,7 +12,7 @@ #include "thread.h" #include "mutex.h" #include - +#include #include class TShellCommandOptions { @@ -369,7 +368,7 @@ class TShellCommand: public TNonCopyable { * @param options execution options * @todo store entire options structure */ - TShellCommand(const TStringBuf cmd, const TList& args, const TShellCommandOptions& options = TShellCommandOptions(), + TShellCommand(const TStringBuf cmd, const std::list& args, const TShellCommandOptions& options = TShellCommandOptions(), const TString& workdir = TString()); TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options = TShellCommandOptions(), const TString& workdir = TString()); ~TShellCommand(); diff --git a/util/ysaveload.h b/util/ysaveload.h index 52fd5bd8ef0..59d21557d94 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -356,10 +356,6 @@ template class TSerializer>: public TVectorSerializer> { }; -template -class TSerializer>: public TVectorSerializer> { -}; - template class TSerializer>: public TVectorSerializer> { }; diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp index 38f1e3bde5d..f55fe17e9b1 100644 --- a/util/ysaveload_ut.cpp +++ b/util/ysaveload_ut.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -391,7 +390,7 @@ class TSaveLoadTest: public TTestBase { void TestList() { TBufferStream s; - TList list = {0, 1, 10}; + std::list list = {0, 1, 10}; Save(&s, list); list.clear(); From e6a656ab8a801a379cace13599daa45baa922032 Mon Sep 17 00:00:00 2001 From: Yehor Shapanov Date: Tue, 23 Jan 2024 00:54:21 -0800 Subject: [PATCH 2/2] Implement review comments --- .gitignore | 1 + contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h | 2 +- contrib/libs/tcmalloc/tcmalloc/huge_region.h | 2 +- contrib/libs/tcmalloc/tcmalloc/span.h | 2 +- util/generic/list_ut.cpp | 14 -------------- util/generic/ut/ya.make | 1 - 6 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 util/generic/list_ut.cpp diff --git a/.gitignore b/.gitignore index 9ac309e6e9e..4277c3e01dd 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,4 @@ util/all_thread.cpp util/all_util.cpp util/charset/all_charset.cpp +cmake-build-debug diff --git a/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h b/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h index c4395ae5cba..2f72b438818 100644 --- a/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h +++ b/contrib/libs/tcmalloc/tcmalloc/huge_page_filler.h @@ -907,7 +907,7 @@ class HugePageFiller { void PrintInPbtxt(PbtxtRegion* hpaa) const; private: - typedef std::list TrackerList; + typedef TList TrackerList; // This class wraps an array of N TrackerLists and a Bitmap storing which // elements are non-empty. diff --git a/contrib/libs/tcmalloc/tcmalloc/huge_region.h b/contrib/libs/tcmalloc/tcmalloc/huge_region.h index f3902273649..0262c007b21 100644 --- a/contrib/libs/tcmalloc/tcmalloc/huge_region.h +++ b/contrib/libs/tcmalloc/tcmalloc/huge_region.h @@ -213,7 +213,7 @@ class HugeRegionSet { size_t n_; // Sorted by longest_free increasing. - std::list list_; + TList list_; }; // REQUIRES: r.len() == size(); r unbacked. diff --git a/contrib/libs/tcmalloc/tcmalloc/span.h b/contrib/libs/tcmalloc/tcmalloc/span.h index 03aaabfe1eb..c589709094c 100644 --- a/contrib/libs/tcmalloc/tcmalloc/span.h +++ b/contrib/libs/tcmalloc/tcmalloc/span.h @@ -67,7 +67,7 @@ inline constexpr size_t kBitmapScalingDenominator = 65536; // and is on returned PageHeap list. // location_ == ON_RETURNED_FREELIST. class Span; -typedef std::list SpanList; +typedef TList SpanList; class Span : public SpanList::Elem { public: diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp deleted file mode 100644 index e0febc5f00b..00000000000 --- a/util/generic/list_ut.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "list.h" - -#include - -Y_UNIT_TEST_SUITE(TYListSuite) { - Y_UNIT_TEST(TestInitializerList) { - std::list l = {3, 42, 6}; - std::list expected; - expected.push_back(3); - expected.push_back(42); - expected.push_back(6); - UNIT_ASSERT_VALUES_EQUAL(l, expected); - } -} diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make index 98dda8111e4..59dfa43d414 100644 --- a/util/generic/ut/ya.make +++ b/util/generic/ut/ya.make @@ -26,7 +26,6 @@ SRCS( generic/iterator_range_ut.cpp generic/iterator_ut.cpp generic/lazy_value_ut.cpp - generic/list_ut.cpp generic/map_ut.cpp generic/mapfindptr_ut.cpp generic/maybe_ut.cpp