diff options
author | tobo <tobo@yandex-team.ru> | 2022-02-24 11:58:08 +0300 |
---|---|---|
committer | tobo <tobo@yandex-team.ru> | 2022-02-24 11:58:08 +0300 |
commit | 0cd396f47ddebe98614ce96b7b0394a0a892b7cc (patch) | |
tree | 11335611c65e163e7633020597acd396ca68450f /util/system | |
parent | 42f6e0ffddb92ca389ac4bcd01acb0caa905c6df (diff) | |
download | ydb-0cd396f47ddebe98614ce96b7b0394a0a892b7cc.tar.gz |
fix CLion perf warnings - use const references instead of passing by value
ref:e94e72a813a3aa41c543fd1d9f7d73f02cca8bc0
Diffstat (limited to 'util/system')
-rw-r--r-- | util/system/filemap.cpp | 23 | ||||
-rw-r--r-- | util/system/filemap.h | 14 | ||||
-rw-r--r-- | util/system/fs_win.cpp | 2 | ||||
-rw-r--r-- | util/system/fs_win.h | 2 |
4 files changed, 21 insertions, 20 deletions
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index f6b12c3d74..957ad4ab32 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -70,8 +70,9 @@ namespace { #define GRANULARITY (TSysInfo::Instance().GRANULARITY_) #define PAGE_SIZE (TSysInfo::Instance().PAGE_SIZE_) -TString TMemoryMapCommon::UnknownFileName() { - return "Unknown_file_name"; +const TString& TMemoryMapCommon::UnknownFileName() { + static const TString unknownFileName = "Unknown_file_name"; + return unknownFileName; } static inline i64 DownToGranularity(i64 offset) noexcept { @@ -195,9 +196,9 @@ public: CreateMapping(); } - inline TImpl(const TFile& file, EOpenMode om, TString dbgName) + inline TImpl(const TFile& file, EOpenMode om, const TString& dbgName) : File_(file) - , DbgName_(File_.GetName() ? File_.GetName() : std::move(dbgName)) + , DbgName_(File_.GetName() ? File_.GetName() : dbgName) , Length_(File_.GetLength()) , Mode_(om) { @@ -370,13 +371,13 @@ TMemoryMap::TMemoryMap(FILE* f, EOpenMode om, TString dbgName) { } -TMemoryMap::TMemoryMap(const TFile& file, TString dbgName) - : Impl_(new TImpl(file, EOpenModeFlag::oRdOnly, std::move(dbgName))) +TMemoryMap::TMemoryMap(const TFile& file, const TString& dbgName) + : Impl_(new TImpl(file, EOpenModeFlag::oRdOnly, dbgName)) { } -TMemoryMap::TMemoryMap(const TFile& file, EOpenMode om, TString dbgName) - : Impl_(new TImpl(file, om, std::move(dbgName))) +TMemoryMap::TMemoryMap(const TFile& file, EOpenMode om, const TString& dbgName) + : Impl_(new TImpl(file, om, dbgName)) { } @@ -459,11 +460,11 @@ TFileMap::TFileMap(const TString& name, i64 length, EOpenMode om) } TFileMap::TFileMap(FILE* f, EOpenMode om, TString dbgName) - : Map_(f, om, dbgName) + : Map_(f, om, std::move(dbgName)) { } -TFileMap::TFileMap(const TFile& file, EOpenMode om, TString dbgName) +TFileMap::TFileMap(const TFile& file, EOpenMode om, const TString& dbgName) : Map_(file, om, dbgName) { } @@ -575,7 +576,7 @@ void TMappedAllocation::Dealloc() { Size_ = 0; } -void TMappedAllocation::swap(TMappedAllocation& with) { +void TMappedAllocation::swap(TMappedAllocation& with) noexcept { DoSwap(Ptr_, with.Ptr_); DoSwap(Size_, with.Size_); #if defined(_win_) diff --git a/util/system/filemap.h b/util/system/filemap.h index 11be64bff4..edae96228b 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -64,7 +64,7 @@ struct TMemoryMapCommon { * Name that will be printed in exceptions if not specified. * Overridden by name obtained from `TFile` if it's not empty. */ - static TString UnknownFileName(); + static const TString& UnknownFileName(); }; Y_DECLARE_OPERATORS_FOR_FLAGS(TMemoryMapCommon::EOpenMode) @@ -75,8 +75,8 @@ public: TMemoryMap(const TString& name, i64 length, EOpenMode om); TMemoryMap(FILE* f, TString dbgName = UnknownFileName()); TMemoryMap(FILE* f, EOpenMode om, TString dbgName = UnknownFileName()); - TMemoryMap(const TFile& file, TString dbgName = UnknownFileName()); - TMemoryMap(const TFile& file, EOpenMode om, TString dbgName = UnknownFileName()); + TMemoryMap(const TFile& file, const TString& dbgName = UnknownFileName()); + TMemoryMap(const TFile& file, EOpenMode om, const TString& dbgName = UnknownFileName()); ~TMemoryMap(); @@ -113,7 +113,7 @@ public: TFileMap(const TString& name, EOpenMode om); TFileMap(const TString& name, i64 length, EOpenMode om); TFileMap(FILE* f, EOpenMode om = oRdOnly, TString dbgName = UnknownFileName()); - TFileMap(const TFile& file, EOpenMode om = oRdOnly, TString dbgName = UnknownFileName()); + TFileMap(const TFile& file, EOpenMode om = oRdOnly, const TString& dbgName = UnknownFileName()); TFileMap(const TFileMap& fm) noexcept; ~TFileMap(); @@ -293,10 +293,10 @@ public: ~TMappedAllocation() { Dealloc(); } - TMappedAllocation(TMappedAllocation&& other) { + TMappedAllocation(TMappedAllocation&& other) noexcept { this->swap(other); } - TMappedAllocation& operator=(TMappedAllocation&& other) { + TMappedAllocation& operator = (TMappedAllocation&& other)noexcept { this->swap(other); return *this; } @@ -317,7 +317,7 @@ public: size_t MappedSize() const { return Size_; } - void swap(TMappedAllocation& with); + void swap(TMappedAllocation& with) noexcept; private: void* Ptr_ = nullptr; diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp index 94016c9fc4..e9f4e5ac33 100644 --- a/util/system/fs_win.cpp +++ b/util/system/fs_win.cpp @@ -138,7 +138,7 @@ namespace NFsPrivate { return SetCurrentDirectoryW(wname); } - bool WinMakeDirectory(const TString path) { + bool WinMakeDirectory(const TString& path) { TUtf16String buf; LPCWSTR ptr = UTF8ToWCHAR(path, buf); return CreateDirectoryW(ptr, (LPSECURITY_ATTRIBUTES) nullptr); diff --git a/util/system/fs_win.h b/util/system/fs_win.h index 2dfdcb2f92..b91f869106 100644 --- a/util/system/fs_win.h +++ b/util/system/fs_win.h @@ -27,5 +27,5 @@ namespace NFsPrivate { bool WinSetCurrentWorkingDirectory(const TString& path); - bool WinMakeDirectory(const TString path); + bool WinMakeDirectory(const TString& path); } |