1
0
Fork 0

Merge pull request #105761 from Ivorforce/string-name-paged-allocator

Use `PagedAllocator` for `StringName` to accelerate and localize allocations.
This commit is contained in:
Thaddeus Crews 2025-04-28 10:01:27 -05:00
commit 09a26f043c
No known key found for this signature in database
GPG Key ID: 8C6E5FEB5FC03CCC
1 changed files with 5 additions and 4 deletions

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);