You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Use PagedAllocator for StringName to accelerate and localize allocations.
This commit is contained in:
@@ -40,6 +40,7 @@ struct StringName::Table {
|
|||||||
|
|
||||||
static inline _Data *table[TABLE_LEN];
|
static inline _Data *table[TABLE_LEN];
|
||||||
static inline Mutex mutex;
|
static inline Mutex mutex;
|
||||||
|
static inline PagedAllocator<_Data> allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
void StringName::setup() {
|
void StringName::setup() {
|
||||||
@@ -95,7 +96,7 @@ void StringName::cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Table::table[i] = Table::table[i]->next;
|
Table::table[i] = Table::table[i]->next;
|
||||||
memdelete(d);
|
Table::allocator.free(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lost_strings) {
|
if (lost_strings) {
|
||||||
@@ -123,7 +124,7 @@ void StringName::unref() {
|
|||||||
if (_data->next) {
|
if (_data->next) {
|
||||||
_data->next->prev = _data->prev;
|
_data->next->prev = _data->prev;
|
||||||
}
|
}
|
||||||
memdelete(_data);
|
Table::allocator.free(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = nullptr;
|
_data = nullptr;
|
||||||
@@ -250,7 +251,7 @@ StringName::StringName(const char *p_name, bool p_static) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = Table::allocator.alloc();
|
||||||
_data->name = p_name;
|
_data->name = p_name;
|
||||||
_data->refcount.init();
|
_data->refcount.init();
|
||||||
_data->static_count.set(p_static ? 1 : 0);
|
_data->static_count.set(p_static ? 1 : 0);
|
||||||
@@ -306,7 +307,7 @@ StringName::StringName(const String &p_name, bool p_static) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = Table::allocator.alloc();
|
||||||
_data->name = p_name;
|
_data->name = p_name;
|
||||||
_data->refcount.init();
|
_data->refcount.init();
|
||||||
_data->static_count.set(p_static ? 1 : 0);
|
_data->static_count.set(p_static ? 1 : 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user