summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-01-01 19:08:49 +0100
committerLéo Lam <leo@leolam.fr>2021-01-01 19:10:46 +0100
commit117e6891b02a9487488ead012fc6216a40316c44 (patch)
tree61236fd904f40641d15becb43c2eaa6eb89d2c9f /src/KingSystem/ActorSystem
parentcb33d236a3286ef5660a712b4b065d413e41f21f (diff)
Reduce code size by avoiding static inline member variables
Static inline member variables require the compiler to emit a static runtime constructor in all translation units that can see the variables in question. This normally wouldn't be a problem, but it gets expensive really quickly when you have ~3000 classes and ~3000 duplicate static constructors. This drops the ELF size from ~270MB to ~220MB and probably speeds up builds a little bit.
Diffstat (limited to 'src/KingSystem/ActorSystem')
-rw-r--r--src/KingSystem/ActorSystem/actAiAction.cpp2
-rw-r--r--src/KingSystem/ActorSystem/actAiAction.h2
-rw-r--r--src/KingSystem/ActorSystem/actAiAi.cpp2
-rw-r--r--src/KingSystem/ActorSystem/actAiAi.h2
-rw-r--r--src/KingSystem/ActorSystem/actAiQueries.cpp2
-rw-r--r--src/KingSystem/ActorSystem/actAiQueries.h2
6 files changed, 9 insertions, 3 deletions
diff --git a/src/KingSystem/ActorSystem/actAiAction.cpp b/src/KingSystem/ActorSystem/actAiAction.cpp
index 0f87ac9f..78632dfc 100644
--- a/src/KingSystem/ActorSystem/actAiAction.cpp
+++ b/src/KingSystem/ActorSystem/actAiAction.cpp
@@ -165,4 +165,6 @@ void Actions::setFactories(int count, ActionFactory* factories) {
sFactories.setBuffer(count, factories);
}
+sead::Buffer<ActionFactory> Actions::sFactories;
+
} // namespace ksys::act::ai
diff --git a/src/KingSystem/ActorSystem/actAiAction.h b/src/KingSystem/ActorSystem/actAiAction.h
index fb94f1a0..e6c9a7e4 100644
--- a/src/KingSystem/ActorSystem/actAiAction.h
+++ b/src/KingSystem/ActorSystem/actAiAction.h
@@ -49,7 +49,7 @@ public:
static void setFactories(int count, ActionFactory* factories);
private:
- static inline sead::Buffer<ActionFactory> sFactories;
+ static sead::Buffer<ActionFactory> sFactories;
sead::Buffer<Action*> mClasses;
// Non-owning buffer.
sead::Buffer<Action*> mOnPreDeleteCbs;
diff --git a/src/KingSystem/ActorSystem/actAiAi.cpp b/src/KingSystem/ActorSystem/actAiAi.cpp
index 0f9dcb5e..aa013208 100644
--- a/src/KingSystem/ActorSystem/actAiAi.cpp
+++ b/src/KingSystem/ActorSystem/actAiAi.cpp
@@ -397,4 +397,6 @@ void Ais::setFactories(int count, AiFactory* factories) {
sFactories.setBuffer(count, factories);
}
+sead::Buffer<AiFactory> Ais::sFactories;
+
} // namespace ksys::act::ai
diff --git a/src/KingSystem/ActorSystem/actAiAi.h b/src/KingSystem/ActorSystem/actAiAi.h
index 11d93b30..bab91af8 100644
--- a/src/KingSystem/ActorSystem/actAiAi.h
+++ b/src/KingSystem/ActorSystem/actAiAi.h
@@ -88,7 +88,7 @@ public:
static void setFactories(int count, AiFactory* factories);
private:
- static inline sead::Buffer<AiFactory> sFactories;
+ static sead::Buffer<AiFactory> sFactories;
sead::Buffer<Ai*> mClasses;
// Non-owning buffer.
sead::Buffer<Ai*> mOnPreDeleteCbs;
diff --git a/src/KingSystem/ActorSystem/actAiQueries.cpp b/src/KingSystem/ActorSystem/actAiQueries.cpp
index 5d900bcc..ac5e03a6 100644
--- a/src/KingSystem/ActorSystem/actAiQueries.cpp
+++ b/src/KingSystem/ActorSystem/actAiQueries.cpp
@@ -140,4 +140,6 @@ void Queries::setFactories(int count, QueryFactory* factories) {
sFactories.setBuffer(count, factories);
}
+sead::Buffer<QueryFactory> Queries::sFactories;
+
} // namespace ksys::act::ai
diff --git a/src/KingSystem/ActorSystem/actAiQueries.h b/src/KingSystem/ActorSystem/actAiQueries.h
index 867c3081..d055174e 100644
--- a/src/KingSystem/ActorSystem/actAiQueries.h
+++ b/src/KingSystem/ActorSystem/actAiQueries.h
@@ -30,7 +30,7 @@ public:
static void setFactories(int count, QueryFactory* factories);
private:
- static inline sead::Buffer<QueryFactory> sFactories;
+ static sead::Buffer<QueryFactory> sFactories;
sead::Buffer<Query*> mClasses;
// Non-owning buffer.
sead::Buffer<Query*> mOnPreDeleteCbs;