1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Use PagedAllocator for StringName to accelerate and localize allocations.

This commit is contained in:
Lukas Tenbrink
2025-04-25 19:19:03 +02:00
parent 1b4ed4c038
commit f064a415b3

View File

@@ -40,6 +40,7 @@ struct StringName::Table {
static inline _Data *table[TABLE_LEN];
static inline Mutex mutex;
static inline PagedAllocator<_Data> allocator;
};
void StringName::setup() {
@@ -95,7 +96,7 @@ void StringName::cleanup() {
}
Table::table[i] = Table::table[i]->next;
memdelete(d);
Table::allocator.free(d);
}
}
if (lost_strings) {
@@ -123,7 +124,7 @@ void StringName::unref() {
if (_data->next) {
_data->next->prev = _data->prev;
}
memdelete(_data);
Table::allocator.free(_data);
}
_data = nullptr;
@@ -250,7 +251,7 @@ StringName::StringName(const char *p_name, bool p_static) {
return;
}
_data = memnew(_Data);
_data = Table::allocator.alloc();
_data->name = p_name;
_data->refcount.init();
_data->static_count.set(p_static ? 1 : 0);
@@ -306,7 +307,7 @@ StringName::StringName(const String &p_name, bool p_static) {
return;
}
_data = memnew(_Data);
_data = Table::allocator.alloc();
_data->name = p_name;
_data->refcount.init();
_data->static_count.set(p_static ? 1 : 0);