-
Notifications
You must be signed in to change notification settings - Fork 70
Use std::move to reduce copies in VideoEncoder #1056
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
Conversation
| VideoStreamOptions videoStreamOptions; | ||
| videoStreamOptions.codec = codec; | ||
| videoStreamOptions.pixelFormat = pixel_format; | ||
| videoStreamOptions.codec = std::move(codec); |
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.
Can you share the lint warning related to that? I'm surprised we need std::move for codec and pixel_format but not for preset?
Made me realize we should make this a string_view like the rest, instead of a string. Same below in the other function.
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.
This comes from clang-tidy:
parameter 'codec' is passed by value and only copied once; consider moving it to avoid unnecessary copies.
Perhaps because preset can be an int, the lint is not raised?
we should make this a string_view like the rest, instead of a string
Thanks for catching this, I'll update this PR
src/torchcodec/_core/custom_ops.cpp
Outdated
| #include <cstdint> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <utility> |
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.
Can you double check whether that's needed?
This PR resolves lints and other miscellaneous fixes:
std::moveoncodec,pixel_formatcodectostd::string_viewrather thanstd::stringtryToValidateCodecOption()Noneas default inops.pyextra_optionsto be keyword param invideo_encoder.py