MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / intern

Method intern

Engine/source/core/util/str.cpp:566–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

564//-----------------------------------------------------------------------------
565
566String String::intern() const
567{
568 if( isInterned() )
569 return *this;
570
571 // Create the intern table, if we haven't already.
572
573 if( !sInternTable )
574 sInternTable = new StringInternTable;
575
576 // Lock the string table.
577
578 MutexHandle mutex;
579 mutex.lock( &sInternTable->mMutex );
580
581 // Lookup.
582
583 StringInternTable::Iterator iter = sInternTable->find( _string );
584 if( iter != sInternTable->end() )
585 return ( *iter ).value;
586
587 // Create new.
588
589 StringData* data = StringData::Create(c_str(), length(), sInternTable->mChunker, true);
590 iter = sInternTable->insertUnique( data, data );
591
592 return ( *iter ).value;
593}
594
595//-----------------------------------------------------------------------------
596

Callers 7

addElementMethod · 0.80
_updateDirtyMethod · 0.80
TESTFunction · 0.80
MatStateHintMethod · 0.80
initMethod · 0.80
_rebuildDescMethod · 0.80

Calls 7

CreateFunction · 0.85
insertUniqueMethod · 0.80
c_strFunction · 0.50
lengthFunction · 0.50
lockMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.64