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

@ -238,10 +238,11 @@ StrConstNode *StrConstNode::alloc(S32 lineNumber, char *str, bool tag, bool doc)
StrConstNode *ret = (StrConstNode *)consoleAlloc(sizeof(StrConstNode));
constructInPlace(ret);
ret->dbgLineNumber = lineNumber;
ret->str = (char *)consoleAlloc(dStrlen(str) + 1);
dsize_t retStrLen = dStrlen(str) + 1;
ret->str = (char *)consoleAlloc(retStrLen);
ret->tag = tag;
ret->doc = doc;
dStrcpy(ret->str, str, dStrlen(str) + 1);
dStrcpy(ret->str, str, retStrLen);
return ret;
}