Skip to content

Commit fafe088

Browse files
committed
static inline is bad. Generates way too much code that the linker is unable to optimize and remove on final link. This causes these symbols from every class in godot-cpp to be included in the final link, even if completely unused by the lib. Removing changes a basic shared library from being ~1.5MB on almost all platforms to now ~200kB.
1 parent 6facde3 commit fafe088

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

include/godot_cpp/classes/ref.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class Ref {
219219

220220
// Used exclusively in the bindings to recreate the Ref Godot encapsulates in return values,
221221
// without adding to the refcount.
222-
inline static Ref<T> _gde_internal_constructor(Object *obj) {
222+
static Ref<T> _gde_internal_constructor(Object *obj) {
223223
Ref<T> r;
224224
r.reference = (T *)obj;
225225
return r;

include/godot_cpp/classes/wrapped.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Wrapped {
7777
GDExtensionObjectPtr owner;
7878
RecreateInstance *next;
7979
};
80-
inline static RecreateInstance *recreate_instance = nullptr;
80+
static RecreateInstance *recreate_instance;
8181
#endif
8282

8383
void _notification(int p_what) {}
@@ -408,7 +408,7 @@ protected:
408408
// Don't use this for your classes, use GDCLASS() instead.
409409
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \
410410
private: \
411-
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
411+
static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
412412
void operator=(const m_class &p_rval) {} \
413413
friend class ::godot::ClassDB; \
414414
friend class ::godot::Wrapped; \

src/classes/wrapped.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ namespace godot {
4242
thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr;
4343
thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr;
4444

45+
#ifdef HOT_RELOAD_ENABLED
46+
Wrapped::RecreateInstance *Wrapped::recreate_instance = nullptr;
47+
#endif
48+
4549
const StringName *Wrapped::_get_extension_class_name() {
4650
return nullptr;
4751
}

0 commit comments

Comments
 (0)