-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed to initialize with substr #46
Conversation
d74d762
to
f26a42b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biwiki , please have a look at comment.
@@ -44,14 +44,17 @@ void Process::_initPaths( const char * fullPath ) | |||
if ( pos != std::string::npos ) | |||
{ | |||
mProcessPath = mProcessFullPath.substr(0, pos); | |||
mProcessName = mProcessFullPath.substr(pos + 1); | |||
// looks weird, but substr does not work without <str> | |||
std::string str = mProcessFullPath.substr(pos + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biwiki, if we change the type of mProcessName
and other members from String
to std::string
, there will be no need for intermediate variable, which has impact on speed and memory (defragmentation). Can you please change the type of object members?
mProcessPath = std::filesystem::absolute(fullProcessPath).parent_path().c_str(); | ||
mProcessName = std::filesystem::absolute(fullProcessPath).filename().c_str(); | ||
mAppName = std::filesystem::absolute(fullProcessPath).stem().c_str(); | ||
mProcessExt = std::filesystem::absolute(fullProcessPath).extension().c_str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can optimize here, because mProcessFullPath = std::filesystem::absolute(fullProcessPath)
and there is no need to re-calculate the full path.
@biwiki, can you please fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I still have something to do with this method, build is failing for Windows and I will fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think this class should hold an instance of std::filesystem::path for the full process path. Other information can be extracted at runtime via C++17 filesystem. Different string members in the current class declaration is kind of duplicated info.
The MS Build failed. |
I'll make some changes later. One test build fails because of MFC dependencies. |
Couple of bug fixes