aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.com>2024-02-12 00:51:14 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:07 +0000
commitdfe7a3135e811997b28db9bd3ad4fe7d210e392d (patch)
tree10f9470ea4eb6c3e680263f5e131b7296eca0d0a
parentb6e44f4ba5e8f176efccc22dfa6084d1258bc74a (diff)
downloadydb-dfe7a3135e811997b28db9bd3ad4fe7d210e392d.tar.gz
discourage inlining of the NResource::TRegHelper's constructor
Микрооптимизация, уменьшающая в два раза число вызовов функций на каждый helper: компилятор пытается встраивать тело конструктора, хотя не имеет никаких шансов что-то в нём соптимизировать без LTO или без знания о том, что `CommonStore()` всегда возвращает одно и то же значнеие, .
-rw-r--r--library/cpp/resource/registry.cpp6
-rw-r--r--library/cpp/resource/registry.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp
index c5d6543c65..e403ba8ede 100644
--- a/library/cpp/resource/registry.cpp
+++ b/library/cpp/resource/registry.cpp
@@ -20,7 +20,7 @@ namespace {
typedef std::pair<TStringBuf, TStringBuf> TDescriptor;
- struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> {
+ struct TStore final: public IStore, public THashMap<TStringBuf, TDescriptor*> {
void Store(const TStringBuf key, const TStringBuf data) override {
if (contains(key)) {
const TStringBuf value = (*this)[key]->second;
@@ -115,3 +115,7 @@ TString NResource::Decompress(const TStringBuf data) {
IStore* NResource::CommonStore() {
return SingletonWithPriority<TStore, 0>();
}
+
+NResource::TRegHelper::TRegHelper(const TStringBuf key, const TStringBuf data) {
+ CommonStore()->Store(key, data);
+}
diff --git a/library/cpp/resource/registry.h b/library/cpp/resource/registry.h
index 698ca5354d..d7f687cff8 100644
--- a/library/cpp/resource/registry.h
+++ b/library/cpp/resource/registry.h
@@ -29,8 +29,6 @@ namespace NResource {
IStore* CommonStore();
struct TRegHelper {
- inline TRegHelper(const TStringBuf key, const TStringBuf data) {
- CommonStore()->Store(key, data);
- }
+ TRegHelper(const TStringBuf key, const TStringBuf data);
};
}