Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector
This commit is contained in:
@@ -41,9 +41,12 @@ StringName _scs_create(const char *p_chr) {
|
||||
}
|
||||
|
||||
bool StringName::configured=false;
|
||||
Mutex* StringName::lock=NULL;
|
||||
|
||||
void StringName::setup() {
|
||||
|
||||
lock = Mutex::create();
|
||||
|
||||
ERR_FAIL_COND(configured);
|
||||
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
||||
|
||||
@@ -54,7 +57,8 @@ void StringName::setup() {
|
||||
|
||||
void StringName::cleanup() {
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
int lost_strings=0;
|
||||
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
||||
|
||||
@@ -78,7 +82,9 @@ void StringName::cleanup() {
|
||||
if (OS::get_singleton()->is_stdout_verbose() && lost_strings) {
|
||||
print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit.");
|
||||
}
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
|
||||
memdelete(lock);
|
||||
}
|
||||
|
||||
void StringName::unref() {
|
||||
@@ -87,7 +93,7 @@ void StringName::unref() {
|
||||
|
||||
if (_data && _data->refcount.unref()) {
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
if (_data->prev) {
|
||||
_data->prev->next=_data->next;
|
||||
@@ -103,7 +109,7 @@ void StringName::unref() {
|
||||
|
||||
}
|
||||
memdelete(_data);
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
}
|
||||
|
||||
_data=NULL;
|
||||
@@ -186,7 +192,7 @@ StringName::StringName(const char *p_name) {
|
||||
if (!p_name || p_name[0]==0)
|
||||
return; //empty, ignore
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = String::hash(p_name);
|
||||
|
||||
@@ -206,7 +212,7 @@ StringName::StringName(const char *p_name) {
|
||||
if (_data) {
|
||||
if (_data->refcount.ref()) {
|
||||
// exists
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -226,8 +232,7 @@ StringName::StringName(const char *p_name) {
|
||||
_table[idx]=_data;
|
||||
|
||||
|
||||
_global_unlock();
|
||||
|
||||
lock->unlock();
|
||||
}
|
||||
|
||||
StringName::StringName(const StaticCString& p_static_string) {
|
||||
@@ -238,7 +243,7 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||
|
||||
ERR_FAIL_COND( !p_static_string.ptr || !p_static_string.ptr[0]);
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = String::hash(p_static_string.ptr);
|
||||
|
||||
@@ -258,7 +263,7 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||
if (_data) {
|
||||
if (_data->refcount.ref()) {
|
||||
// exists
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -278,7 +283,8 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||
_table[idx]=_data;
|
||||
|
||||
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -292,7 +298,7 @@ StringName::StringName(const String& p_name) {
|
||||
if (p_name==String())
|
||||
return;
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = p_name.hash();
|
||||
|
||||
@@ -311,7 +317,7 @@ StringName::StringName(const String& p_name) {
|
||||
if (_data) {
|
||||
if (_data->refcount.ref()) {
|
||||
// exists
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -332,7 +338,7 @@ StringName::StringName(const String& p_name) {
|
||||
_table[idx]->prev=_data;
|
||||
_table[idx]=_data;
|
||||
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
|
||||
}
|
||||
|
||||
@@ -344,7 +350,7 @@ StringName StringName::search(const char *p_name) {
|
||||
if (!p_name[0])
|
||||
return StringName();
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = String::hash(p_name);
|
||||
|
||||
@@ -361,12 +367,13 @@ StringName StringName::search(const char *p_name) {
|
||||
}
|
||||
|
||||
if (_data && _data->refcount.ref()) {
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
|
||||
return StringName(_data);
|
||||
|
||||
}
|
||||
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return StringName(); //does not exist
|
||||
|
||||
|
||||
@@ -380,7 +387,7 @@ StringName StringName::search(const CharType *p_name) {
|
||||
if (!p_name[0])
|
||||
return StringName();
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = String::hash(p_name);
|
||||
|
||||
@@ -397,12 +404,12 @@ StringName StringName::search(const CharType *p_name) {
|
||||
}
|
||||
|
||||
if (_data && _data->refcount.ref()) {
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return StringName(_data);
|
||||
|
||||
}
|
||||
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return StringName(); //does not exist
|
||||
|
||||
}
|
||||
@@ -410,7 +417,7 @@ StringName StringName::search(const String &p_name) {
|
||||
|
||||
ERR_FAIL_COND_V( p_name=="", StringName() );
|
||||
|
||||
_global_lock();
|
||||
lock->lock();
|
||||
|
||||
uint32_t hash = p_name.hash();
|
||||
|
||||
@@ -427,12 +434,12 @@ StringName StringName::search(const String &p_name) {
|
||||
}
|
||||
|
||||
if (_data && _data->refcount.ref()) {
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return StringName(_data);
|
||||
|
||||
}
|
||||
|
||||
_global_unlock();
|
||||
lock->unlock();
|
||||
return StringName(); //does not exist
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user