MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / search

Method search

modules/gui/gui/src/backend/text_server/string_name.cpp:467–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467StringName 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
509StringName StringName::search(const char32_t* p_name)
510{

Callers 3

writeMethod · 0.45
writeFunction · 0.45
writeFunction · 0.45

Calls 6

StringNameClass · 0.85
hashFunction · 0.50
get_nameMethod · 0.45
refMethod · 0.45
is_emptyMethod · 0.45
hashMethod · 0.45

Tested by

no test coverage detected