From 5eb3a65cba9508070a0334d69fe930a9ff610d00 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Sat, 8 Feb 2014 03:49:37 -0500 Subject: [PATCH] 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 --- SystemTools.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index 7e6ab87..85ea807 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -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; } -- GitLab