Skip to content

Commit eb3d060

Browse files
committed
Merge pull request #105876 from KoBeWi/dynamic_outline
Inline static variables (part 1)
2 parents d849ebb + 5af4bef commit eb3d060

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+85
-247
lines changed

core/config/engine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ String Engine::get_shader_cache_path() const {
400400
return shader_cache_path;
401401
}
402402

403-
Engine *Engine::singleton = nullptr;
404-
405403
Engine *Engine::get_singleton() {
406404
return singleton;
407405
}

core/config/engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Engine {
9090

9191
bool _print_header = true;
9292

93-
static Engine *singleton;
93+
static inline Engine *singleton = nullptr;
9494

9595
String write_movie_path;
9696
String shader_cache_path;

core/config/project_settings.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
#include "modules/modules_enabled.gen.h" // For mono.
4949
#endif // TOOLS_ENABLED
5050

51-
const String ProjectSettings::PROJECT_DATA_DIR_NAME_SUFFIX = "godot";
52-
53-
ProjectSettings *ProjectSettings::singleton = nullptr;
54-
5551
ProjectSettings *ProjectSettings::get_singleton() {
5652
return singleton;
5753
}

core/config/project_settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ProjectSettings : public Object {
4444

4545
public:
4646
typedef HashMap<String, Variant> CustomMap;
47-
static const String PROJECT_DATA_DIR_NAME_SUFFIX;
47+
static inline const String PROJECT_DATA_DIR_NAME_SUFFIX = "godot";
4848

4949
// Properties that are not for built in values begin from this value, so builtin ones are displayed first.
5050
constexpr static const int32_t NO_BUILTIN_ORDER_BASE = 1 << 16;
@@ -116,7 +116,7 @@ class ProjectSettings : public Object {
116116
void _queue_changed();
117117
void _emit_changed();
118118

119-
static ProjectSettings *singleton;
119+
static inline ProjectSettings *singleton = nullptr;
120120

121121
Error _load_settings_text(const String &p_path);
122122
Error _load_settings_binary(const String &p_path);

core/core_bind.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ namespace CoreBind {
4646

4747
////// ResourceLoader //////
4848

49-
ResourceLoader *ResourceLoader::singleton = nullptr;
50-
5149
Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, CacheMode p_cache_mode) {
5250
return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads, ResourceFormatLoader::CacheMode(p_cache_mode));
5351
}
@@ -195,8 +193,6 @@ ResourceUID::ID ResourceSaver::get_resource_id_for_path(const String &p_path, bo
195193
return ::ResourceSaver::get_resource_id_for_path(p_path, p_generate);
196194
}
197195

198-
ResourceSaver *ResourceSaver::singleton = nullptr;
199-
200196
void ResourceSaver::_bind_methods() {
201197
ClassDB::bind_method(D_METHOD("save", "resource", "path", "flags"), &ResourceSaver::save, DEFVAL(""), DEFVAL((uint32_t)FLAG_NONE));
202198
ClassDB::bind_method(D_METHOD("set_uid", "resource", "uid"), &ResourceSaver::set_uid);
@@ -722,8 +718,6 @@ void OS::remove_logger(const Ref<Logger> &p_logger) {
722718
logger_bind->loggers.erase(p_logger);
723719
}
724720

725-
OS *OS::singleton = nullptr;
726-
727721
void OS::_bind_methods() {
728722
ClassDB::bind_method(D_METHOD("get_entropy", "size"), &OS::get_entropy);
729723
ClassDB::bind_method(D_METHOD("get_system_ca_certificates"), &OS::get_system_ca_certificates);
@@ -877,8 +871,6 @@ OS::~OS() {
877871

878872
////// Geometry2D //////
879873

880-
Geometry2D *Geometry2D::singleton = nullptr;
881-
882874
Geometry2D *Geometry2D::get_singleton() {
883875
return singleton;
884876
}
@@ -1138,8 +1130,6 @@ void Geometry2D::_bind_methods() {
11381130

11391131
////// Geometry3D //////
11401132

1141-
Geometry3D *Geometry3D::singleton = nullptr;
1142-
11431133
Geometry3D *Geometry3D::get_singleton() {
11441134
return singleton;
11451135
}
@@ -1282,8 +1272,6 @@ void Geometry3D::_bind_methods() {
12821272

12831273
////// Marshalls //////
12841274

1285-
Marshalls *Marshalls::singleton = nullptr;
1286-
12871275
Marshalls *Marshalls::get_singleton() {
12881276
return singleton;
12891277
}
@@ -2128,8 +2116,6 @@ void Engine::_bind_methods() {
21282116
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
21292117
}
21302118

2131-
Engine *Engine::singleton = nullptr;
2132-
21332119
////// EngineDebugger //////
21342120

21352121
bool EngineDebugger::is_active() {
@@ -2275,8 +2261,6 @@ EngineDebugger::~EngineDebugger() {
22752261
captures.clear();
22762262
}
22772263

2278-
EngineDebugger *EngineDebugger::singleton = nullptr;
2279-
22802264
void EngineDebugger::_bind_methods() {
22812265
ClassDB::bind_method(D_METHOD("is_active"), &EngineDebugger::is_active);
22822266

core/core_bind.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ResourceLoader : public Object {
4848

4949
protected:
5050
static void _bind_methods();
51-
static ResourceLoader *singleton;
51+
static inline ResourceLoader *singleton = nullptr;
5252

5353
public:
5454
enum ThreadLoadStatus {
@@ -93,7 +93,7 @@ class ResourceSaver : public Object {
9393

9494
protected:
9595
static void _bind_methods();
96-
static ResourceSaver *singleton;
96+
static inline ResourceSaver *singleton = nullptr;
9797

9898
public:
9999
enum SaverFlags {
@@ -162,7 +162,7 @@ class OS : public Object {
162162

163163
protected:
164164
static void _bind_methods();
165-
static OS *singleton;
165+
static inline OS *singleton = nullptr;
166166

167167
#ifndef DISABLE_DEPRECATED
168168
Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments);
@@ -322,7 +322,7 @@ class OS : public Object {
322322
class Geometry2D : public Object {
323323
GDCLASS(Geometry2D, Object);
324324

325-
static Geometry2D *singleton;
325+
static inline Geometry2D *singleton = nullptr;
326326

327327
protected:
328328
static void _bind_methods();
@@ -388,7 +388,7 @@ class Geometry2D : public Object {
388388
class Geometry3D : public Object {
389389
GDCLASS(Geometry3D, Object);
390390

391-
static Geometry3D *singleton;
391+
static inline Geometry3D *singleton = nullptr;
392392

393393
protected:
394394
static void _bind_methods();
@@ -419,7 +419,7 @@ class Geometry3D : public Object {
419419
class Marshalls : public Object {
420420
GDCLASS(Marshalls, Object);
421421

422-
static Marshalls *singleton;
422+
static inline Marshalls *singleton = nullptr;
423423

424424
protected:
425425
static void _bind_methods();
@@ -570,7 +570,7 @@ class Engine : public Object {
570570

571571
protected:
572572
static void _bind_methods();
573-
static Engine *singleton;
573+
static inline Engine *singleton = nullptr;
574574

575575
public:
576576
static Engine *get_singleton() { return singleton; }
@@ -650,7 +650,7 @@ class EngineDebugger : public Object {
650650

651651
protected:
652652
static void _bind_methods();
653-
static EngineDebugger *singleton;
653+
static inline EngineDebugger *singleton = nullptr;
654654

655655
public:
656656
static EngineDebugger *get_singleton() { return singleton; }

core/core_globals.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

core/core_globals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
class CoreGlobals {
3737
public:
38-
static bool leak_reporting_enabled;
39-
static bool print_line_enabled;
40-
static bool print_error_enabled;
38+
static inline bool leak_reporting_enabled = true;
39+
static inline bool print_line_enabled = true;
40+
static inline bool print_error_enabled = true;
4141
};

core/debugger/engine_debugger.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
#include "core/debugger/script_debugger.h"
3737
#include "core/os/os.h"
3838

39-
EngineDebugger *EngineDebugger::singleton = nullptr;
40-
ScriptDebugger *EngineDebugger::script_debugger = nullptr;
41-
42-
HashMap<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
43-
HashMap<StringName, EngineDebugger::Capture> EngineDebugger::captures;
44-
HashMap<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols;
45-
4639
void (*EngineDebugger::allow_focus_steal_fn)();
4740

4841
void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) {

core/debugger/engine_debugger.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ class EngineDebugger {
9191
uint32_t poll_every = 0;
9292

9393
protected:
94-
static EngineDebugger *singleton;
95-
static ScriptDebugger *script_debugger;
94+
static inline EngineDebugger *singleton = nullptr;
95+
static inline ScriptDebugger *script_debugger = nullptr;
9696

97-
static HashMap<StringName, Profiler> profilers;
98-
static HashMap<StringName, Capture> captures;
99-
static HashMap<String, CreatePeerFunc> protocols;
97+
static inline HashMap<StringName, Profiler> profilers;
98+
static inline HashMap<StringName, Capture> captures;
99+
static inline HashMap<String, CreatePeerFunc> protocols;
100100

101101
static void (*allow_focus_steal_fn)();
102102

0 commit comments

Comments
 (0)