Commit 672f1697 authored by Artem Golubikhin's avatar Artem Golubikhin

Merge branch 'backport-removed-unnecessary-copying-in-UTIL_string-parsing-functions' into 'master'

Removed unnecessary copying in UTIL_* string parsing functions

See merge request !5
parents c9b355f3 d20cdf2e
......@@ -1248,28 +1248,18 @@ bool UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2)
void UTIL_StringToVector(float *pVector, const char *pString)
{
char *pstr;
char *pfront;
char tempString[128];
int j;
Q_strlcpy(tempString, pString);
pstr = tempString;
pfront = tempString;
for (j = 0; j < 3; j++)
{
pVector[j] = Q_atof(pfront);
pVector[j] = Q_atof(pString);
while (*pstr && *pstr != ' ')
pstr++;
while (*pString != '\0' && *pString != ' ')
pString++;
if (!*pstr)
if (*pString == '\0')
break;
pstr++;
pfront = pstr;
pString++;
}
for (j++; j < 3; j++)
......@@ -1284,27 +1274,17 @@ void UTIL_StringToVector(Vector &vecIn, const char *pString, char cSeparator)
void UTIL_StringToVectorND(Vector &vecIn, int nCount, const char *pString, char cSeparator)
{
int i;
char *pstr;
char *pfront;
char tempString[128];
Q_strlcpy(tempString, pString);
pstr = tempString;
pfront = tempString;
for (i = 0; i < nCount; i++)
{
vecIn[i] = Q_atof(pfront);
vecIn[i] = Q_atof(pString);
while (*pstr && *pstr != cSeparator)
pstr++;
while (*pString != '\0' && *pString != cSeparator)
pString++;
if (!*pstr)
if (*pString == '\0')
break;
pstr++;
pfront = pstr;
pString++;
}
if (++i < nCount)
......@@ -1315,28 +1295,18 @@ void UTIL_StringToVectorND(Vector &vecIn, int nCount, const char *pString, char
void UTIL_StringToIntArray(int *pVector, int count, const char *pString)
{
char *pstr;
char *pfront;
char tempString[128];
int j;
Q_strlcpy(tempString, pString);
pstr = tempString;
pfront = tempString;
for (j = 0; j < count; j++)
{
pVector[j] = Q_atoi(pfront);
pVector[j] = Q_atoi(pString);
while (*pstr && *pstr != ' ')
pstr++;
while (*pString != '\0' && *pString != ' ')
pString++;
if (!*pstr)
if (*pString == '\0')
break;
pstr++;
pfront = pstr;
pString++;
}
for (j++; j < count; j++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment