| 465 | } |
| 466 | |
| 467 | StringName StringName::search(const char* p_name) |
| 468 | { |
| 469 | ERR_FAIL_COND_V(!configured, StringName()); |
| 470 | |
| 471 | ERR_FAIL_COND_V(!p_name, StringName()); |
| 472 | if (!p_name[0]) |
| 473 | { |
| 474 | return StringName(); |
| 475 | } |
| 476 | |
| 477 | MutexLock lock(mutex); |
| 478 | |
| 479 | uint32_t hash = String::hash(p_name); |
| 480 | uint32_t idx = hash & STRING_TABLE_MASK; |
| 481 | |
| 482 | _Data* _data = _table[idx]; |
| 483 | |
| 484 | while (_data) |
| 485 | { |
| 486 | // compare hash first |
| 487 | if (_data->hash == hash && _data->get_name() == p_name) |
| 488 | { |
| 489 | break; |
| 490 | } |
| 491 | _data = _data->next; |
| 492 | } |
| 493 | |
| 494 | if (_data && _data->refcount.ref()) |
| 495 | { |
| 496 | #ifdef DEBUG_ENABLED |
| 497 | if (unlikely(debug_stringname)) |
| 498 | { |
| 499 | _data->debug_references++; |
| 500 | } |
| 501 | #endif |
| 502 | |
| 503 | return StringName(_data); |
| 504 | } |
| 505 | |
| 506 | return StringName(); // does not exist |
| 507 | } |
| 508 | |
| 509 | StringName StringName::search(const char32_t* p_name) |
| 510 | { |