Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing bad suggestion. In theory, we could change this signature to…
… take a const reference to a string, but for now, I'm reverting it.
- Loading branch information
Showing
2 changed files
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,7 +253,7 @@ namespace openshot { | |
|
||
/// @brief Constructor for FFmpegWriter. Throws one of the following exceptions. | ||
/// @param path The file path of the video file you want to open and read | ||
FFmpegWriter(const std::string path); | ||
FFmpegWriter(std::string path); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ferdnyc
Contributor
|
||
|
||
/// Close the writer | ||
void Close(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think the issue here was that FFmpegWriter should take
path
by const reference — not a const path. IOW, the recommendation was to declare this as:And then it would be defined the same way in the
.cpp
:That should work transparently (but more efficiently) in all situations. It just tells the compiler that it doesn't have to copy
path
before passing it to the constructor — it can just pass a reference, because the original won't be modified. (The constructor will make a copy anyway, when it stores the referenced string to the member variablepath
in the initializer list.)If you pass a
const
string, then you have to cast away theconst
-ness before you can store it in a non-const
member variable. But aconst
reference shouldn't have that issue.