Commit 5eb3a65c authored by Ben Boeckel's avatar Ben Boeckel
Browse files

SystemTools: Don't construct a string just for its length

Using strlen is much smarter here since we don't have to allocate for
it.

Change-Id: I62f46039a8b5ebc5ab1535a00859a824d77dbaec
parent 29e3b1d8
......@@ -3970,30 +3970,30 @@ bool SystemTools::LocateFileInDir(const char *filename,
bool SystemTools::FileIsFullPath(const char* in_name)
{
kwsys_stl::string name = in_name;
size_t len = strlen(in_name);
#if defined(_WIN32) || defined(__CYGWIN__)
// On Windows, the name must be at least two characters long.
if(name.length() < 2)
if(len < 2)
{
return false;
}
if(name[1] == ':')
if(in_name[1] == ':')
{
return true;
}
if(name[0] == '\\')
if(in_name[0] == '\\')
{
return true;
}
#else
// On UNIX, the name must be at least one character long.
if(name.length() < 1)
if(len < 1)
{
return false;
}
#endif
#if !defined(_WIN32)
if(name[0] == '~')
if(in_name[0] == '~')
{
return true;
}
......@@ -4001,7 +4001,7 @@ bool SystemTools::FileIsFullPath(const char* in_name)
// On UNIX, the name must begin in a '/'.
// On Windows, if the name begins in a '/', then it is a full
// network path.
if(name[0] == '/')
if(in_name[0] == '/')
{
return true;
}
......
Supports Markdown
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