Skip to content

Commit 3037b71

Browse files
lgritz1div0
authored andcommitted
perf: Improve perf of IBA::channels in-place operation (AcademySoftwareFoundation#4088)
For the in-place case (where src and dst refer to the same IB), we were doing an unnecessary full-image copy. Signed-off-by: Larry Gritz <[email protected]> Signed-off-by: Peter Kovář <[email protected]>
1 parent f6f9e26 commit 3037b71

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libOpenImageIO/imagebufalgo_channels.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ ImageBufAlgo::channels(ImageBuf& dst, const ImageBuf& src, int nchannels,
5656
{
5757
// Handle in-place case
5858
if (&dst == &src) {
59-
ImageBuf tmp = src;
60-
return channels(dst, tmp, nchannels, channelorder, channelvalues,
61-
newchannelnames, shuffle_channel_names, nthreads);
59+
ImageBuf tmp;
60+
bool ok = channels(tmp, src, nchannels, channelorder, channelvalues,
61+
newchannelnames, shuffle_channel_names, nthreads);
62+
dst = std::move(tmp);
63+
return ok;
6264
}
6365

6466
pvt::LoggedTimer logtime("IBA::channels");

0 commit comments

Comments
 (0)