-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL][NFC] Fix a Coverity hit in device_image_impl ctor #20579
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
base: sycl
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| device_image_impl(const std::string &Src, context Context, | ||
| device_image_impl(const std::string &Src, const context &Context, |
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.
Not an expert on the best practices, but I think std::move could be better on average:
device_image_impl obj(..., create_rval_context(), ...); // 1
device_image_impl obj(..., lval_context, ...); // 2
For by-value param followed by a std::move we'd have two move-ctors (1) and copy-ctor + move-ctor (2).
For by-const-ref we'll have copy-ctor (1) and copy-ctor. Effectively, we remove one move-ctor (cheap) in either case and introduce a more expensive copy-ctor in (1).
That said, it's probably unlikely to matter in practice, so LGTM.
+ @vinser52 in case we need to update our "informal style guides".
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 changed it this way mostly to align with the rest of the constructors, but I do prefer pass-by-value then move as well. And, on closer inspection, we actually have a weird mix of the two in this file, so I'll update the PR to use that instead.
No description provided.