mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-19 19:35:26 +00:00
As suggested, extract strlen calls from sizes into variables so it isn't called twice
This commit is contained in:
parent
ed10ce2511
commit
6b024b21bf
33 changed files with 171 additions and 114 deletions
|
|
@ -908,8 +908,9 @@ const char* ActionMap::getDeadZone( const char* device, const char* action )
|
|||
{
|
||||
char buf[64];
|
||||
dSprintf( buf, sizeof( buf ), "%g %g", mapNode->deadZoneBegin, mapNode->deadZoneEnd );
|
||||
char* returnString = Con::getReturnBuffer( dStrlen( buf ) + 1 );
|
||||
dStrcpy( returnString, buf, dStrlen(buf) + 1 );
|
||||
dsize_t returnLen = dStrlen(buf) + 1;
|
||||
char* returnString = Con::getReturnBuffer( returnLen );
|
||||
dStrcpy( returnString, buf, returnLen );
|
||||
return( returnString );
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -96,8 +96,9 @@ U32 NetStringTable::addString(const char *string)
|
|||
size = newSize;
|
||||
}
|
||||
table[e].refCount++;
|
||||
table[e].string = (char *) allocator->alloc(dStrlen(string) + 1);
|
||||
dStrcpy(table[e].string, string, dStrlen(string) + 1);
|
||||
dsize_t stringLen = dStrlen(string) + 1;
|
||||
table[e].string = (char *) allocator->alloc(stringLen);
|
||||
dStrcpy(table[e].string, string, stringLen);
|
||||
table[e].next = hashTable[bucket];
|
||||
hashTable[bucket] = e;
|
||||
table[e].link = firstValid;
|
||||
|
|
@ -178,8 +179,9 @@ void NetStringTable::repack()
|
|||
const char *prevStr = table[walk].string;
|
||||
|
||||
|
||||
table[walk].string = (char *) newAllocator->alloc(dStrlen(prevStr) + 1);
|
||||
dStrcpy(table[walk].string, prevStr, dStrlen(prevStr) + 1);
|
||||
dsize_t prevStrLen = dStrlen(prevStr) + 1;
|
||||
table[walk].string = (char *) newAllocator->alloc(prevStrLen);
|
||||
dStrcpy(table[walk].string, prevStr, prevStrLen);
|
||||
}
|
||||
delete allocator;
|
||||
allocator = newAllocator;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue