As suggested, extract strlen calls from sizes into variables so it isn't called twice

This commit is contained in:
Glenn Smith 2018-03-08 20:59:40 -05:00
parent ed10ce2511
commit 6b024b21bf
33 changed files with 171 additions and 114 deletions

View file

@ -547,8 +547,9 @@ const char * Component::getDescriptionText(const char *desc)
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
if (!Platform::isFile(desc))
{
newDesc = new char[dStrlen(desc) + 1];
dStrcpy(newDesc, desc, dStrlen(desc) + 1);
dsize_t newDescLen = dStrlen(desc) + 1;
newDesc = new char[newDescLen];
dStrcpy(newDesc, desc, newDescLen);
return newDesc;
}

View file

@ -594,8 +594,9 @@ bool ParticleData::preload(bool server, String &errorStr)
animTexFrames.clear();
char* tokCopy = new char[dStrlen(animTexFramesString) + 1];
dStrcpy(tokCopy, animTexFramesString, dStrlen(animTexFramesString) + 1);
dsize_t tokLen = dStrlen(animTexFramesString) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, animTexFramesString, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -608,8 +608,9 @@ bool ParticleEmitterData::onAdd()
// First we parse particleString into a list of particle name tokens
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(particleString) + 1];
dStrcpy(tokCopy, particleString, dStrlen(particleString) + 1);
dsize_t tokLen = dStrlen(particleString) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, particleString, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)