ENH: string += is very slow, so don't use it
This commit is contained in:
parent
ca90e8002b
commit
dc43a3d265
@ -311,8 +311,10 @@ const char* cmDependsC::ParseFileName(const char* in, std::string& name)
|
|||||||
|
|
||||||
// Parse the possibly quoted file name.
|
// Parse the possibly quoted file name.
|
||||||
bool quoted = false;
|
bool quoted = false;
|
||||||
|
char* buf = new char[strlen(in)+1];
|
||||||
|
char* pos = buf;
|
||||||
for(;*c && (quoted ||
|
for(;*c && (quoted ||
|
||||||
((*c != ':' || name.size() == 1) && !isspace(*c))); ++c)
|
((*c != ':' || pos > buf+1) && !isspace(*c))); ++c)
|
||||||
{
|
{
|
||||||
if(*c == '"')
|
if(*c == '"')
|
||||||
{
|
{
|
||||||
@ -320,14 +322,18 @@ const char* cmDependsC::ParseFileName(const char* in, std::string& name)
|
|||||||
}
|
}
|
||||||
else if(!quoted && *c == '\\' && isspace(*(c+1)))
|
else if(!quoted && *c == '\\' && isspace(*(c+1)))
|
||||||
{
|
{
|
||||||
name += *(++c);
|
*pos = *(++c);
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name += *c;
|
*pos = *c;
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*pos =0;
|
||||||
|
name += pos;
|
||||||
|
delete [] buf;
|
||||||
// Return the ending position.
|
// Return the ending position.
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user