Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/source/detail/device_image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class device_image_impl
updateSpecConstSymMap();
}

device_image_impl(const std::string &Src, context Context,
device_image_impl(const std::string &Src, const context &Context,
Copy link
Contributor

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".

Copy link
Contributor Author

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.

devices_range Devices, syclex::source_language Lang,
include_pairs_t &&IncludePairsVec, private_tag)
: MBinImage(Src), MContext(Context),
Expand Down
Loading