Refactorization: avoid string copying in Path::getPathFromFilename()
This commit is contained in:
parent
d29117c4b2
commit
5bc775e43e
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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 "";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue