Refactorization: avoid string copying in Path::getPathFromFilename()

This commit is contained in:
PKEuS 2014-10-17 17:16:34 +02:00
parent d29117c4b2
commit 5bc775e43e
2 changed files with 3 additions and 4 deletions

View File

@ -140,6 +140,7 @@ private:
* If no errors are found, 0 is returned.
*/
int check_internal(CppCheck& cppcheck, int argc, const char* const argv[]);
/**
* Pointer to current settings; set while check() is running.
*/

View File

@ -109,14 +109,12 @@ std::string Path::simplifyPath(std::string originalPath)
std::string Path::getPathFromFilename(const std::string &filename)
{
std::string path = "";
std::size_t pos = filename.find_last_of("\\/");
if (pos != std::string::npos)
path = filename.substr(0, 1 + pos);
return filename.substr(0, 1 + pos);
return path;
return "";
}